Calls to functions from loaded SWF files

I have a Flex application that uses the SWFLoader object to load an external SWF file (which has also been developed in Flex) in a section of the page. The parent SWF file defines several variables and global functions in ActionScript I would use from all SWF files loaded in the SWFLoader. Is it possible in ActionScript to access the functions and variables that are defined in the SWF file the SWF load/child parent? The two SWF files are on the same domain, so there should not be problems of security.

Peter thank you very much for your answer. I have tried loading in the same ApplicationDomain, but he did not what I expected from him. I, however, found the solution to my problem. I needed to understand how cross-script from a SWF file loaded the loaded SWF file. I discovered how and published a description of my conclusions on another thread that was no longer relevant to my question. The described solution has allowed me to do what I needed without touching the ApplicationDomain.

Tags: Flex

Similar Questions

  • call the parent of a loaded swf file functions?

    Hi all

    I have a main Flash file that load other SWF files using loader objects.  I want to be able to call the methods of this main purpose since then in the loaded SWF files.  For example, I want the file loaded in order to add an event listener on the stage of the main file.  I found this example:

    http://flexcomps.WordPress.com/2008/09/01/AS3-calling-MyFunction-on-main-timeline-from-Loa ded - swf.

    That seems to do what I want, but I can't understand how to implement it in my setup.

    My "main" file that loads other sovereign funds is called "main.swf" and has a main document class.

    My loaded file is called start.swf and has a class of documents 'Start '.

    in my main constructor:

    var ethics_content:Loader = new Loader();

    ethics_content. Load (new URLRequest ('start.swf'));

    in the constructor of my departure:


    If (this.parent.parent! = null) {/ / IF the STATEMENT FAILS}
    var parentObj:Object = this.parent.parent as an object;
    trace ("parentObj has been found.'");
    } else {}
    trace ("this .parent .parent is null.");
    }

    stage.addEventListener (MouseEvent.CLICK, handle_click); GENERATES AN ERROR WHEN IT IS LOADED TO THE HAND. SWF

    trace ("step: ' + Stadium");  RETURNS A [STAGE] OBJECT BY OPERATING BY ITSELF, BUT NULL WHEN IT IS EXECUTED IN THE HAND. SWF
    trace ("root:" + root); RETURNS AN OBJECT [START] WHEN RUN BY ITSELF OR WITHIN THE HAND. SWF
    trace ("parent: ' + parent"); RETURNS A [STAGE] OBJECT BY OPERATING BY ITSELF, BUT NOTHING OF IN THE HAND. SWF
    trace ("this .parent:" + this.parent); RETURNS OBJECT STAGE ITSELF, NOTHING OF IN THE HAND. SWF
    trace ("root.parent:" + root.parent); RETURNS THE SCENE OBJECT BY ITSELF

    How to get to the scene of a loaded SWF file?  Or at least, how can I call a function in my main class from the loaded file start.swf so I can move the functionality I need the main.swf file?

    Any help is greatly appreciated.

    If your main swf loader is not added to the display list when it try {branch} is running, the charger will not have a parent.

  • How to call the function lavel root & variable external loaded swf file

    I have little problem in as3.  I load 'mainmenu.swf' file "main.swf". through class loader. so now "main.swf" is children of parents 'mainmenu.swf' file how can call "main.swf" variable and function of "mainmenu.swf".

    The parent of the loaded swf file is the charger.  The main SWF is the parent of the charger.  Then to communicate with the main storyline of the loaded file can use:

    MovieClip (parent.parent) .someFunction ();

  • How the get function is available or not on the loaded swf file

    I have 100 swf file in one of my projects. And there is a common feature in some of the SWFs. All these files are loadded in the file main.swf. Here's my Question, "If have the common function is the swf file that is loaded, int how to trigger this funciton of the main.swf.

    Quite simply,.

                if(movieclip.test){
                    movieclip.test();
                }
    

    ('movieclip' is the loaded SWF file and "test()" is the function)

  • To access the MovieClip instances in a loaded SWF file

    The situation as follows:

    loadedSWF.swf (published with Flash Player 8 AS2 or AS3 of Alpha Flash Player 9), contains on the symbols of the stage with the instance names: clipA, clipB, clipC, etc... No ActionScript is included in the file.

    In a Flex Builder 2.0 project, a component that extends mx.core.UIComponent load loadedSWF.swf:

    script
    var request: URLRequest = new URLRequest ("loadedSWF.swf");
    loaded var: Loader = new Loader();
    Loaded.Load (request);
    addChildAt(loaded,0);


    loadedSWF.swf successfully is displayed in the component's display list, but MovieClip instances that it contains are inaccessible.

    Its existence is verified:

    script
    trace (getChildAt (0)) / / result: [object Loader]
    trace (getChildAt (0) .root) / / result: [object _system_mx_managers_SystemManager]

    However, even if .root getChildAt (0) returns a mx.managers.SystemManager and mx.managers.SystemManager supports the numChildren property, trace (getChildAt (0).root.numChildren) survey error: 1119: access of the numChildren property possibly not defined through a reference with static type flash.display:DisplayObject.. Other methods like getChildAt(), etc. are also impossible to call. Direct access with getChildAt (0).root.clipA also throws an error, etc...

    Is it possible to access instances of the MovieClip on the stage of the loaded SWF file of a component that loads? I would appreciate any advice on this issue.

    a.Neko


    Note:
    The goal is to be able to load multiple clips into a component in a single loading of SWF file, then to instantiate the separately if necessary with addChild() and addChildAt() methods.

    Solution found:

    (Checked for loadedSWF.swf published with Adobe Flash Professional 9 Alpha Public)

    script (excerpt from Flex 2.0 AS3 component class)

    protected var clip: MovieClip = new MovieClip();

    protected final void requestSWF(value:String):void {}
    var request: URLRequest = new URLRequest (value);
    var asked: Loader = new Loader();
    requested.contentLoaderInfo.addEventListener (Event.COMPLETE, this.onRequestSWFComplete);
    requested. Load (request);
    return;
    };

    protected final void onRequestSWFComplete(event:Event):void {}
    event.stopPropagation ();
    This.clip = event.target.content.clipA; conversion of a local variable.
    this.addChild (this.clip);
    return;
    };

    this.requestSWF ("loadedSWF.swf");

    Result: clipA is added separately to the display of the component list.

    a.Neko

  • call a .obj from a dll file

    Greetings!

    I have a question calling a function in a .obj file (running specifically) in a .dll file.

    At present, it will load the obj file and get a valid (non-NULL) pointer to the function, but then I get a general protection fault when I try to call the function.  If I mouse over the function pointer, the address is valid (although not NULL anyway) but the name of claims "unknown function.

    I guess I'm not to expose the functions available in the obj file correctly, but the United States of __stdcall seems to make no difference.

    It is new territory for me, so do not assume that this isn't something obvious that I'm just missing!

    Any help is the aprpeciated

    First of all, your code looks correct. This leads me to think that it is perhaps a question Data Execution Prevention (DEP). The mechanism of LoadExternalModule/GetExternalModuleAddr was developed long before DEP has been poured, and it happens in time (for LoadLibrary/GetProcAddress). If you go into system settings Advanced window, it has a button for the Performance parameters. Click on that and it will bring up some tabs, which is Data Execution Prevention. Set it to "Turn on DEP for programs Windows and services only," restart the computer, then try your program.

    I realize that even if this solves your problem, it may not be not possible to ensure that the DEP is disabled on your program must be running on all machines. Since you're at the point where you have to choose the way of the future, I highly recommend that you try to replace the static lib with a DLL. Certainly, a DLL must be related, and it cannot directly access the functions and variables in the program; This can make it difficult to adapt the code of the existing static lib. However, if it really is a separate logical element, it should be possible.

    A. Mert

    National Instruments

  • Problem with playing a loaded "SWF" file in the chronology of the pain

    Hey there. I created a presentation that loads the SWF interactive movies in a clip of 'target' on the main timeline.
    As you progress through the different presentation SWF movies are loaded into the presentation. And this in turn allows me to change the content of the presentations quickly and easily for different customers.
    These sovereign funds use part of the preloaded flash content like the other and drop-down list box objects.
    However, when these sovereign funds are called in the main charge they stop working properly.
    They work fine when tested independently of the main charge.

    Does anyone know how I can be able to get these sovereign funds work properly?

    At soon fofana

    The first thing to do is to check the range of your loaded SWF file. All references to _root, for example, means something different when the SWF is loaded in your film of wrapper.

    In addition, some of the V2 components do not work correctly when the SWF is loaded into another SWF. There is a technical Note and simple workaround here:

    http://www.Adobe.com/go/tn_19278

    Good luck!

  • How do I know if a loaded SWF file have the source code?

    Hi!, I need to know if a loaded SWF file have the source code. I develop an application running on iOS and admin can upload SWF files that show in the APP, but I must know before show (mobile Adobe AIR APP) or activate (PHP script server), if this SWF file have the source code for no show or enable him not it.,.

    Thank you!

    I have it!

    Only that we need to do is:

    1. If the first tank is:

    F-the swf is uncompressed

    C - compressed with Deflate

    Z - compressed with LZMA

    2. If it is compressed, uncompress it with the right method

    3. search MainTimeline string, if concluded the SWF actionscript so it is not found, the code is not actionscript.

  • control the loaded swf file

    Hi all

    I am loading a swf into another SWF, I want to controll loaded swf such as play and pause the swf. The loaded swf file is an animation file, all animations are kept in a movieclip, then please tell me how I can control the animation.

    In your first assignment, you tell the animation is present in a movieclip.  If this movieclip is in the loaded swf file you will probably need to target this movieclip to tell him to play rather than the SWF itself, as in...

    currentSWF.movieclipName.play ();

    where movieclipName is replaced with the name of the instance of movieclip in the loaded swf file.

  • How to use a link to execute an ActionScript function in a SWF file?

    In the Actionscript 3.0 language and components reference > all categories > class TextField > properties > HTML htmlText supported tags table, the description of the anchor tag has this sentence: "you can use the link event causes the link execute an ActionScript function in a SWF file instead of opening a URL. I do not understand how to do this. Can someone tell me how to proceed? Alternatively, can anyone point me to an example or a reference that explains how to run an ActionScript function in a SWF file using the event of links?

    Thank you

    Tim Persinger

    You put a href as you normally would, just by using events: define as follows:

    someTextField.htmlText = "Hello World";
    someTextField.addEventListener (TextEvent.LINK, hwPressed);
    function hwPressed(e:TextEvent) {}
    trace (e.Text);
    }

    will trace "hw".

  • Firefox showing only 300 pixels or so from the swf file?

    What would make Firefox appear only the first 300 pixels or so from the swf file? Everything works fine it just cover the lower part of the film? Doesn't do this on IE or Safari.

    Found is the value of 100% of the height. 100% for width, but not the height was not serious

  • Calling a function in the main sequence of a loaded swf file

    I know this is probably a very basic question, but I loaded a SWF file in another film. Now, I want to call a function in the main SWF file. Is it possible to do? Otherwise, I have a custom class where I could put the function, but I was not able to understand how to call it from the SWF loaded either. Can I somehow associate the class with the main movie, or...?

    Nevermind - I did something very stupid and was not calling the function as a method of a clip. I was just calling checkTarget (event) and not event.currentTarget.checkTarget (event); that seems to work.

  • referencing the main timeline from a loaded swf file

    I just poked around google as both of these forums, but the only answer I see that was a success, is kglad, and for some reason that its messages are not, I just see ":" and then the guy say thank you! Not uber useful.

    In any case, I'm just trying to understand how to reference an image tag on my main timeline to a swf loaded (through my imageLoader). Does anyone have a link or can tell me what I should look for in? dispatchers of the event?

    to reference the main timeline of the SWF loading from the main timeline of the swf file that is loaded, use:

    MovieClip (this.parent.parent)

  • How can I control a button from a swf file to another swf file?

    Hello

    I have a file main.swf . From this file I can access the file external.swf which is an external file.

    Now, how can I write code on my file main.swf to the button that is on my external.swf file?

    Activities.MainPanel.close_btn.addEventListener (MouseEvent.CLICK, btnClickClose);

    Activities.MainPanel.close_btn (This button is actually the external.swf file, but I want to write code on main.swf file to run it on external.swf) How can I control a single swf in another swf file button?

    Thank you.

    Some examples of code that you should be able to adapt to your needs.

    create a new instance of the loader object.

    var loader: Loader = new Loader();

    make the download request...

    var request: URLRequest = new URLRequest ("external.swf");

    Add a full event for the loader listener

    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, completeHandler);

    start the actual loading process...

    Loader.Load (request);

    Create a new empty movieClip instance, you place the movie loaded into this movieClip after loading

    var externalMovie:MovieClip;

    This function is called when the download is complete and the file is ready for use.

    function completeHandler(event:Event):void {}

    set the contents of the film to the new empty movieClip...

    externalMovie = MovieClip (event.target.content);

    Add this new film to the display list.

    addChild (externalMovie);

    }

    Now you can reference the film loaded with the name of the instance 'externalMovie '. So if, for example, you want to address a button in the film loaded, you can write something like that on the main timeline:

    externalMovie.addEventListener (MouseEvent.CLICK, btnClickClose);

    function btnClickClose(event:MouseEvent):void {}

    }

  • Call a function from C++ QML

    How to get there? How to call a function QML file c ++.

    I have a list view, and an indicator of activity in the qml and after extraction of xml data from a web service call, I'm unable to fix the datamodel as the XMLDatamodel does not work GroupDataModel works, but to make it work I have to use the data source and I can't set the property type of the DataSoure in c ++

    I'm getting below the code to load the data to GroupDataModel

    dataModel = new GroupDataModel();
    
    DataSource *ds = new DataSource(this);
    ds->setSource(QUrl("file://" + QDir::homePath() + "/model.xml"));
    
    ds->setType(bb::data::DataSourceType::Type.Xml);
    ds->setQuery("/ArrayOfPeople/People");
    

    Hereby, I get Compilation error to

    ds->setType(bb::data::DataSourceType.Xml);
    

    error: wait before create primary expression '.' token

    To work around, I want to load the data source and model of QML function, but this function must be called those the network connection has data extracted and stored in the file.

    Hel me please on this...

    You must give a signal of c ++ and set up a slot in qml connect.

    Example:

    C++

    mQmlDocument->setContextProperty("_myClass", myClass);
    
    emit mySignal()
    

    QML:

    _myClass.mySignal.connect(doSomething);
    
    function doSomething() {
        // logic here
    }
    

Maybe you are looking for