Targeting the timeline of a loaded swf - AS2

I'm loading an external swf into a project and I want to be able to start and stop the loaded swfs timeline at will....
I'm loading swf into an MC:
loadMovie("myFile.swf", swfHolder_mc);

you can reference the loaded swf's main timeline by referencing swfHolder_mc AFTER loading is complete and the swf is initialized.

Similar Messages

  • Moving the timeline from a loaded swf file

    Hi,
    I have been at this problem for awhile now.
    I have a two swf files, whic are loaded using ths code as an example:
    stop();
    var req:URLRequest = new URLRequest("Enchilada_A.swf");
    var loader:Loader = new Loader();
    function imageLoaded(event:Event):void {
        ldContainerB.addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    loader.load(req);
    The first one is triggerrd by a MC button that is on the timeline.
    That first swf loads fine.
    At the end of that file(which is short animation)
    I have code that says:
    MovieClip(parent).gotoAndStop("frameThree");
    I have also tried:
    MovieClip(root) and
    if (movie Clip is parent) {
    MovieClip(parent).gotoAndStop("frameThree");
    and/MovieClip(parent).nextFrame();
    I have also tried placing this. or root. into the code.
    I am not talking to the timeline from this swf file.
    Once the timeline moves to the next Frame the new swf file can load.
    My solution was to combine both swf files into one, which loads from the timeline button.
    It works and I can gt by but I really woud like to learn how to load a swf and talk to the timeline fro more flexibilty.
    I'm out of strategies.
    Is my code in the wrong place(at the last frame of the animation?
    Should it be written on the timeline by creating a new var that has a function once the animation is completed.
    Any suggestions and/or commens would be greatly appreciated.
    Thanks.

    Thanks,
    I finally had a chance to get back to this project and used your suggestions, whichare definitiley helpful. I also, created a new and very basic version of the project so I could easily see what was happening.
    This is the code that works:
    stop();
    MovieClip(parent.parent).nextFrame();
    trace(container_mc);
    I'm still trying to understand how the child parent relationship is working but this will get me going in the right direction.

  • Controlling a Movie Clip on the Main Timeline from a loaded SWF?

    Is it possible to control a MovieClip on the main timelne from another loaded clip?
    I see posts that control loaded clips, but most are all from the loader in the main timeline.  I have a moviclip on the main timeline that I want to make visible or invisible depending on what keyframe is playing in another loaded swf.
    If I try to call the movieClip from the loaded SWF I get "error #1119.  Access of possibly undefined property...." because it doesn't exist in the loaded SWF, just the main timeline. 
    The old AS2 way just used "_root".  Since "_root" doesn't exist any more, how do you control items on the main TimeLine from a loaded SWF?

    I am not clear what you mean because you are saying you are trying to target a movieclip that does not exist where you are trying to target it.
    Try using a trace to see what you are targeting when you you target the MovieClip(parent.parent)....
    trace(MovieClip(parent.parent));
    The other approach I mentioned earlier is the more OOP-correct approach if you would rather try that way.  Here's a rough outline of it...
    AS3 - Dispatch Event
    http://forums.adobe.com/thread/470135?tstart=120
    Example:
    Add something to trigger the event in the child (your loaded swf):
    dispatchEvent(new Event("eventTriggered")); (
    if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
    In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf.
    // event handler triggered when external swf is loaded
    function loaderCompleteHandler(event:Event) {
        MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
    function eventHandler(event:Event):void {
        trace("event dispatched in loaded swf");
       // this is where your main file can set the visible property of your movieclip

  • Tracing the level of a loaded .swf

    I'm using a loadMovie script to load in my .swf files.
    How can I trace the level of a loaded .swf?
    Also, here are my load scripts:
    loadMovie("movie1.swf", 1)
    loadMovie("movie2.swf", 2)
    I thought level 2 would be behind level 1, but movie2.swf is showing up overtop of movie1.swf?

    If you are loading into levels you should use loadMovieNum or you should look into using the MovieClipLoader class—which is waaaayyy better than loadMovie/loadMovieNum!
    However levels are difficult to work with since there isn't really a class that represents them and so the number of methods, events, and properties are a little limited and not really documented.
    In fact is AS3 levels completely go away, so it really isn't the best thing to use.
    However. If you put code on a timeline:
    trace("Hello from movie1.swf I'm at: "+this);
    The trace will show which _level the clip is on.
    Also a little known trick is to do something like:
    _level1.swapDepths(_level2)
    which will swap the stacking order of the levels. Of course you have to wait until the content is loaded into the level because it doesn't exist before that. And they won't be renamed so it can get very confusing if higher number usually means higher in the stacking order...

  • Can't target main stage from dynamically loaded swf...

    A part of the Flash app. I'm working on right now does the following -
    Main stage loads an external swf using the following function:
    function loadAsset(evt:String):void{
    var assetName:String = evt;
    if (assetName != null){
      var assetLdr:Loader = new Loader(); 
      var assetURL:String = assetName; 
      var assetURLReq:URLRequest = new URLRequest(assetURL); 
      assetLdr.load(assetURLReq); 
      assetLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded) 
      assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);  
      function loaded(event:Event):void { 
       var targetLoader:Loader = Loader(event.target.loader); 
       assetWindow.addChild(targetLoader);
    The externally loaded swf loads another external swf into itself using the following function:
    function loadQuiz(evt:String):void{   
    var quizName:String = evt;
    if (quizName != null){
      var quizLdr:Loader = new Loader();
      var quizURL:String = quizName;
      var quizURLReq:URLRequest = new URLRequest(quizURL);
      quizLdr.load(quizURLReq);
      quizLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)       
      quizLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayQuizLoaderProgress); 
      function loaded(event:Event):void {
       var targetLoader:Loader = Loader(event.target.loader);
       quizWindow.assetLoader.addChild(targetLoader);     
    Everything loads fine, but from the quizWindow.assetLoader.addChild(targetLoader) level, I want to send a message/fill in a dynamic text box on the Main Stage. I have been "parenting" my brains out and I'm not sure how to communicate with that level.
    can anyone show me the proper path or method based off the above, or have a suggestion?
    Cheers,
    ~Chipleh

    Andrei1,
    Thanks again for your help. I was finally able to get the solution you posted below to work for me.
    Much appreciation,
    ~Chipleh
    "In your loaded movie write:
    function traceMyself(e:MouseEvent):void{
         dispatchEvent(new Event("I_WANT_TEXT"));
    function writeText(text:String):void {
         xmlFileName1.text = text;
    In the top movie that loads external swfs something like that:
    loadedSwf.addEventListener("I_WANT_TEXT", onTextRequest, true);
    function onTextRequest(e:Event):void {
         Object(e.target).writeText(tQuizXmlFile1.theQuizXmlFile.text);
    This way these two entities are independent and, most importantly, don't care who is the parent or grandparent."

  • How to detect the end of a loaded swf file

    Hello Guys
    This is my first time on this forum, come here with a great
    hope
    I have loaded a picture file (jpeg) and a video file (swf)
    into the main flash file using xml
    on frame 3, I load the picture and on frame 7, I load the
    video, there is a stop action on frame 6
    Now when the flash is executed the picture is displayed ( it
    says "Click here to view the video")
    when the user click the picture , the video is loaded and
    starts to play ---- so far everything is working fine
    now what I want to do is, once the video finishes playing (
    not stoped) I want to display the picture again
    can you tell me how to detect the end of an external loaded
    swf files,
    Please help me
    Thanking You
    Shriram

  • Trouble Playing A loaded 'SWF' file in the pain timeline

    Hey there. I have created a presentation that loads
    interactive SWF movies into a 'target' movie clip on the main
    timeline.
    As you progress through the presentation different SWF movies
    are loaded into the presentation. And this in turn allows me to
    change the presentations content quickly and easily for different
    clients.
    These SWF's use some of the flash preloaded content objects
    like combo box's and the like.
    However when these SWF's are called into the main
    presentation they cease to work properly.
    They work fine when tested independently of the main
    presentation.
    Does anyone know how I may be able to get these SWF's to work
    properly?
    Cheers Fletch

    The first thing to do is check the scoping in your loaded
    SWF. Any references to _root, for example, mean something different
    once the SWF is loaded into your wrapper movie.
    Also, some of the V2 components don't work properly when
    their SWF is loaded into another SWF. There's a Tech Note and easy
    workaround here:
    http://www.adobe.com/go/tn_19278
    Good luck!

  • Access the property of main class in loaded swf.

    Hi
    i have one main.fla, its document class is main.as. the code in main.as is
    package
    import flash.display.MovieClip;
    public class Main extends MovieClip
    private var loading:Loading;
    public var trovami:Number=10;
    public function Main()
    stage.frameRate=31;
    loadSWF();
    private function loadSWF():void
    loading=new Loading(this);
    Loadind.as is another class where i load another swf its name is my_swf.
    the code of loading class is:
    package
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.text.TextField;
    import flash.display.Loader;
    import flash.events.*;
    import flash.net.URLRequest;
    public class Loading extends MovieClip
    private var _fla:MovieClip;
    private var url:String;
    public var val:String;
    private var loader:Loader;
    public function Loading(fla:MovieClip)
    _fla=fla;
    init();
    private function init():void
    url='my_swf.swf';
    var request:URLRequest=new URLRequest(url);
    loader=new Loader();
    initListeners(loader.contentLoaderInfo);
    loader.load(request);
    private function initListeners(dispatcher:IEventDispatcher):void
    dispatcher.addEventListener(Event.COMPLETE,completato);
    private function completato(event:Event):void
    _fla.addChild(loader);
    loader.y=10;
    val="hello"
    and the document class of loaded swf is Main2. in my_swf.fla there is one text its name is:
    a_txt.
    so i have to use property of Loading class in Main2 for text.
    code of Main.as is
    package
    import flash.display.MovieClip;
    import flash.text.*;
    public class Main2 extends MovieClip
    public function Main2()
    a_txt.text=val;
    where val is the property of Loading class.
    so how can i access.

    You have a reference to your loaded movie within your Loading class - instead of just setting val to a string - add a method in your Main2 class - and call that from Loading - passing the string to it. Push not pull...
    Main 2 becomes:
    public function Main2() {
         //a_txt.text=val;
    public function setText(val:String):void {
        a_txt.text = val;
    And then in your Loading class - when you're done loading just call setText:
    private function completato(e:Event):void
        addChild(loader);
        loader.y=10;
        MovieClip(loader.content).setText("hello");
        //val="hello";

  • Loaded SWF not displaying

    I've created a 'plugin' SWF file in CS3 using actionscript 3.
    The purpose of this file is to be included as a postroll in the
    open source flash media player JW FLV/Media Player (
    http://www.jeroenwijering.com/?item=JW_Media_Player).
    I have heavily customized the media player libraries to do
    various new things/alter how things worked, and now want to be able
    to include the SWF file within this into a child sprite/movie clip.
    HOWEVER, the problem lies in that the media player is written
    completely in AS2, and therefore I have to use the MovieClipLoader
    class to load in the SWF. Updating the source to AS3 isn't an
    option unfortunatly, and downgrading the AS3 SWF to AS2 isn't an
    option either, mainly due to the fact I've learnt AS3, not AS2, and
    find it frustrating trying to find the AS2 equivalent to the AS3
    methods I know.
    The problem though lies in that MovieClipLoader does not like
    my SWF at all. Initially I was presented with a load of sandbox
    errors from when it was loaded in, which I then resolved so that no
    security errors are produced. However, whenever I load in the clip,
    the target sprite/clip is empty. I have gone through checking that
    no errors occur on load, and it reports that the loaded SWF has
    been initialized, yet I see nothing. Also, the code loading the SWF
    is not at fault as it loads any other SWF (even another AS3 SWF
    which just creates a rectangle) no problem.
    Oddly enough, using the MovieClip.loadMovie method works in
    one situation - when you load it into the root of the AS2 file.
    When loading it into an empty movie clip, the same problem of a
    blank clip occurs. The problem is not specific to the media player
    either, as it happened in any AS2 file where I was testing how to
    load in the AS3 SWF.
    If it is of any use, the sandbox errors produced by the AS3
    file when loaded into AS2 swf I had to resolve where to do with
    stage access for getting the stage height and width, and a
    Loader.content error when pulling out the BitmapData. These were
    resolved via setting the allowed domains policy and eliminating any
    reference to stage.stageHeight/With.
    Does anyone have any ideas on how to solve this? The only
    possible solution I've been able to think of so far since the AS3
    swf won't display is to play with the LocalConnection class as
    tests showed I can communicate between the AS2 and AS3 files, but
    this would have to be a last resort, and is less than ideal when
    there can be multiple instances of the player running (I would need
    to use unique connection names for each instance so as to prevent
    player A interacting with player B, and also as only one of the
    players can listen on the connection at once).

    I have the component in the top level also,
    I get this error:
    TypeError: Error #2007: Parameter child must be non-null.
              at flash.display::DisplayObjectContainer/addChildAt()
              at fl.controls::BaseButton/drawBackground()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\BaseButton.as:615]
              at fl.controls::LabelButton/draw()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\LabelButton.as:724]
              at fl.core::UIComponent/drawNow()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\core\UIComponent.as:1343]
              at fl.controls::List/drawList()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\List.as:594]
              at fl.controls::List/draw()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\List.as:474]
              at .tree::TreeList/draw()
              at fl.core::UIComponent/callLaterDispatcher()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\core\UIComponent.as:1532]
    I've checked the definitions for the tree component,
    The LabelButton and List I don't have much control over.
    I'm not sure how to fix this.  The xml is correct and loads easily if it's in the root document.
    The list component doesn't load the labels, It stops on the first one.
      What do I do next?

  • How can I get stage width of an loaded swf?

    Is there any way to get the real stageWidth of an loaded swf?
    The problem comes when the loaded swf has some elements outside the scene. In this case content.width becomes bigger then the scene.
    My code looks like this:
    var request:URLRequest = new URLRequest(file.url);
    var loader:Loader = new Loader();
    loader.load(request);
    loader.contentLoaderInfo.addEventListener(Event.INIT, checkSize);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addImg);
    private function checkSize(e:Event) {
                // this is where I need to see the width of my loaded swf
    trace(e.target.content.width);
    private function addImg(e:Event) {
                    trace("complete");
    Thanks,
    Andrei

    I don't think you can get the stage width of the loaded file unless you assign it as a constant somewhere within the file.  The loaded file forfeits its stage when it is loaded into another swf

  • Trying to call a root level function from within a loaded swf

    I'm not very familiar with AS3... I'm trying to have a loaded swf file call a function from the parent to unload itself when it comes to the end (on the timeline, not as a button). I'm assuming I need to be calling the function (that is used for the close button) from the loaded swf (perhaps I'm mistaken though?).
    Here's the code from one of my buttons that loads an swf. I'm guessing I need to call the closeSWF function from the timeline of my loaded movie but having no luck figuring out how to do that.
    Any help would be appreciated.
    // 01 ------------------------------------------------------
    function loadWeaving(ev:MouseEvent):void {
      // load SWF
      var movieClip:MovieClip = new holder_mc;
      //add it to the stage
      addChild(holderSWF);
      holderSWF.x=0;
      holderSWF.y=0;
      var requestEN:URLRequest = new URLRequest("WhatIsWeaving_Eng.swf"); // english
      holderSWF.load(requestEN);
      close_bt.addEventListener(MouseEvent.CLICK, closeSWF);
      function closeSWF(infoObject:Object):void {
      trace("close SWF");
      removeChild(holderSWF);
      // reset switch
      close_bt.visible = false;
      showAllButtons();
      infoObject.currentTarget.removeEventListener(infoObject.type, closeSWF);
      setChildIndex(close_bt,numChildren - 1);
      close_bt.visible = true;
      hideAllButtons();
      // - start timer last
      myTimer.addEventListener(TimerEvent.TIMER, closeSWF);

    You're exactly right. If you attach an event listener to the Loader before you add it to the stage, you can then use event.currentTarget to refer to the loader. And this is definitely the better way to do it if you're planning to use the loaded swf from multiple places or could ever need to do this in the future.
    So:
    protected function initLoader():void {
         var loader:Loader = new Loader();
         loader.addEventListener('closeMe', closeLoader);
         loader.load(new URLRequest(...));
         addChild(loader);
    protected function closeLoader(e:Event):void {
         var loader:Loader = e.currentTarget as Loader;
         if (loader) {
              loader.unloadAnstop(true);
              loader.removeEventListener('closeMe', closeLoader);
              removeChild(loader);

  • Getting properties from loaded swf

    hi there,
    I am loading different swfs into my loader object "loader"
    and I also have a description of each swf below it ("desc"
    "desc_back").. Each swf is different in size and i want to move/
    scale "desc" and "desc_back" it to fit. This seems to be kind of
    working but it changes to fit the loaded swf before the one I want
    it to. it is if it is taking the properties of the last loaded swf
    instead of the one just loaded...I have tryed using an onload
    listener amoung a number of things. my action script is not very
    strong so it could be something simple.
    thanks :)

    you must wait until loading is complete before trying to
    access the _width and _height of the about-to-be-loaded swf. ie,
    use preloader code or the onLoadInit() method of the
    moviecliploader class.

  • Control the property of an object in main stage from a loaded swf timeline

    please someone help me here, im loosing my mind
    i have a UILoader that loads an image from an xml list when you click its thumbnail ( in its thumbnails mc on mainstage aswell)
    thing is, i have another UILoader on the layer above that loads in a swf ( a slideshow that fades in and out the pictures when they change to the next,
    with all the coding on frame 1, frame 2 only has a stop and some code for when the mouse is idle for 5 secs it goes back to frame 1)
    so when you go to "portraits" it takes you to frame "x" where the slideshow ( loaded external swf ) starts playing automaticly right,
    if i click any thumbnail the slideshow goes to frame 2 ( wich is perfect and the mouse idle thing i wanted works great ) the ONLY THING IS
    after the slideshow runs by default for the first time ( i enter the category portraits )
    and i click any thumbnail ( moving slideshow swf to frame 2 enabling mouse idle event )
    and the mouse is idle ( so it does the event and starts playing the slideshow again ( goes back to frame 1 ) )
    I CANT MAKE THE UILOADER OF THE THUMBS IMAGE TO DISSAPPEAR!!!
    i have tried everything i can think of and everything i have read trying to adapt it with what i know,
    im no guru at this i reeeeally need some help
    THANK YOU  SO VERY MUCH ! 

    and where would i put the remove.simpleScreen ( simpleScreen is the loader i would want to remove )
    would it be on the external swf on frame 1 where the slideshow plays?
    or in the main timeline's category's frame?
    the problem ( that i see ) is that both loaders are on the same frame ( different layers tho )
    so if i put a the remove simplescreen there it wont show me the pictures when i click the thumbs
    or could i make it so that it removes it BECAUSE its playing on frame 1 ?

  • Loaded SWF communicating with Main Timeline

    Let's say I load an external SWF to my main timeline. In that
    loaded SWF, I'd like to have a button that when clicked, removes a
    Movie Clip from the main timeline.
    How do I do that? Should be simple, right?

    Sorry I misunderstood your question, but here is the code.
    The second part is original swf altering a movie clip in the
    external (mov2.swf), just making an mc 50% transparent....
    circle_btn.addEventListener(MouseEvent.CLICK, printButton);
    function printButton(myevent:MouseEvent){
    var portLoader:Loader=new Loader();
    var printThumbRequest:URLRequest=new URLRequest("mov2.swf");
    portLoader.load(printThumbRequest);
    stage.addChild(portLoader);
    portLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    loaded);
    function loaded(event:Event) {
    circle2_btn.addEventListener(MouseEvent.CLICK,
    talkToExternal);
    function talkToExternal(myevent:MouseEvent){
    event.target.content.green_mc.alpha=.5;
    }

  • Dynamically loaded swf to communicate with MovieClip on the stage

    I have a heck of time here with an issue. I have an xml document that when a certain button on the stage is clicked it loads it's corresponding external swf into an empty movieclip on the stage. This empty movie clip is a holder for all external swfs.
    So what I'm trying to do is when an external swf is loaded that has buttons on it, I need those buttons to communicate with the main timeline and remove a mc that is on the Stage. I need the currently loaded swf(s) to be able to do this. So whatever the currently loaded external swf is that's loaded, I need it to talk to the main timeline. (I have quite a few external swfs that need to do this) So I imagine I need to somehow target the currently loaded external swf to get it to talk to the main timeline.
    The code below in summary doesn't work but it doesn't give errors either. I don't pretend to know what I'm doing and I haven't been successful in searching for a solution to this particular issue. If someone could give me guidance or direct me to a solution. I'd so much appreciate it.
    // main timeline object
    var index:Object=this;
    function loadComplete (e:Event) {
            TweenMax.to(index.mcholder,1, {alpha: .5});
    // add the current module to the mcholder movieclip by using addChild
            index.mcholder.addChild(e.currentTarget.content);
           (e.currentTarget.content as MovieClip).addEventListener("eventTriggered", startListener);
    function startListener(e:Event):void {
    var ext_swf:MovieClip;
    ext_swf = e.currentTarget.content as MovieClip;
    trace("external swf");
    ext_swf.button1.addEventListener(MouseEvent.CLICK, talktomainswf);
    function talktomainswf():void {
    TweenMax.to(index.mc_thatsonthestage, 1, {x:1000});
    // now we have the first load we set firstLoad to false
            index.firstLoad = false;
        function loadError (e:Event) {
            trace("error");

    You can use the event dispatcher to communicate between external swfs and a main timeline,
    like so:
    //in an external swf
    //Once loaded
    function onLoadComplete(event:Event):void
         //dispatch an event in the form of a string
         dispatchEvent(new Event("Talk to Main Timeline")); 
    //On the Main timeline
    //listen for "Talk to Main Timeline"
    stage.addEventListener("Talk to Main Timeline", listenForCallsFromExternalFiles, true);
    //if the event is heard, do this:
    function listenForCallsFromExternalFiles(e:Event):void
         trace("I heard ya, now do stuff...");
    That's the basic idea anyways, I use it all the time.
    hope that helps,
    ~chipleh

Maybe you are looking for