+ Reply to Thread
Results 1 to 5 of 5

Edit main timeline from an external swf

This is a discussion on Edit main timeline from an external swf within the Actionscript 3.0 newbies forums, part of the Flash English category; Okay, I have been going crazy all weekend trying to figure this out. All I want to do is communicate ...

  1. #1
    Junior Member Settled In oswader2 is on a distinguished road
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Edit main timeline from an external swf

    Okay, I have been going crazy all weekend trying to figure this out. All I want to do is communicate with the main timeline from a loaded external swf.

    So, I have loaded a external swf called "test.swf" from the main swf called "basetest.swf"

    So, on basetest.swf I have this code, simply loading test.swf:

    var request2:URLRequest = new URLRequest("test.swf");
    var loader:Loader = new Loader()
    loader.load(request2);
    addChild(loader);
    stop();

    On test.swf i have a button, upon clicking this button i want it to go to the second frame of basetest.swf:

    thebutton.addEventListener( MouseEvent.CLICK, button_function );
    thebutton.buttonMode = true;
    function button_function( evt:MouseEvent ) {
    trace( "button" );
    }

    thebutton.addEventListener(MouseEvent.CLICK, click);
    function click(evt:MouseEvent):void {
    //How do i get to the second frame of basetest.swf!?!
    }

    Again, on test.swf I want to gotoAndPlay(2); on the timeline of basetest.swf. This is a very simple thing to do in AS2, but doesn't seem clear to me how to accomplish this in AS3.

    Any help would be VERY MUCH appreciated.

  2. #2
    Junior Member Settled In RamNik is on a distinguished road
    Join Date
    May 2009
    Posts
    1
    Rep Power
    0

    Talking Re: Edit main timeline from an external swf


    I'm happy to say that I had the same problem and after searching around a lot found out that:
    1- if you use a MovieClip object in your "basetest.swf" like this:
    var loader:Loader;
    var holder:MovieClip;
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,onMovieComplete);
    loader.load(new URLRequest("01Intro.swf"));

    function onMovieComplete(e:Event):void
    {
    holder = MovieClip(e.target.content);
    holder.x = 251.95;

    addChildAt(holder,12);
    }

    2- then in your "test.swf" you could use the gotoAndPlay like this to access the main movie time line:
    MovieClip(this.parent).gotoAndPlay(2);

    I think this solves your problem
    Also if you noticed, I use addChildAt to enable me to put my external clip in desired layer (top layer of your time line is 1 and so on)

    Last edited by RamNik; 09-05-09 at 13:03.

  3. #3
    Junior Member Settled In egilarntzen is on a distinguished road
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Re: Edit main timeline from an external swf

    does that mean that "addChildAt(holder,12);", holder is the name of the layer and 12 is frame 12?

    Thanks.

  4. #4
    Junior Member Settled In graphicguru_india is on a distinguished road
    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    Unhappy Re: Edit main timeline from an external swf

    Hi,
    Iam using this code to load my external swf's on a movie clip for each one seperatly by clicking on each button.
    function loadarvswf(e:Event):void
    {
    emc.removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("Aerial_View.swf");
    loader.load(newSWFRequest);
    MapTitle.text = "Aerial View of Map";
    emc.addChild(loader);
    legndpopup.visible = false;
    mappopup.visible = false;
    pdfToLoad = "pdfs/Aerial_View.pdf";

    }
    in this extenal swf i have some area's to hightlight. This should be happen from main movie because the same hightlights will be in other swf's as well. So i need your deep help in this.
    in AS2 we use to do in levels.
    _level1.mc_name.mc_shape._x +=5;
    how to do this in AS3?
    //this is the function to scale the shape
    function iconscale(e:Event):void
    {
    //loaded swf mc.shapemc.action
    emc.shape1.scaleX = emc.shape1.scaleY = 50;
    }
    //mainmovie movieclip.submovieclip.buttoninmc.eventfire
    legndpopup.legndicons.btn_1.addEventListener(Mouse Event.CLICK,iconscale);

    please help me friends.

  5. #5
    Junior Member Settled In lkristoffersen is on a distinguished road
    Join Date
    Oct 2011
    Posts
    1
    Rep Power
    0

    Thumbs up Re: Edit main timeline from an external swf

    Quote Originally Posted by RamNik View Post

    I'm happy to say that I had the same problem and after searching around a lot found out that:
    1- if you use a MovieClip object in your "basetest.swf" like this:
    var loader:Loader;
    var holder:MovieClip;
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,onMovieComplete);
    loader.load(new URLRequest("01Intro.swf"));

    function onMovieComplete(e:Event):void
    {
    holder = MovieClip(e.target.content);
    holder.x = 251.95;

    addChildAt(holder,12);
    }

    2- then in your "test.swf" you could use the gotoAndPlay like this to access the main movie time line:
    MovieClip(this.parent).gotoAndPlay(2);

    I think this solves your problem
    Also if you noticed, I use addChildAt to enable me to put my external clip in desired layer (top layer of your time line is 1 and so on)

    Awsome, it works, it took me ages to find a good solution for this, it enables easy calls to the swf using mclipname.gotoAndPlay(#) and can be killed with a simple removechild(mclipname);
    Thanks a bunch Ramnik

+ Reply to Thread

Similar Threads

  1. External SWF communication problems to main timeline
    By hankodonnell in forum Flash English
    Replies: 5
    Last Post: 08-05-10, 18:57
  2. Add value to main timeline variable
    By xPINKMERCEDESx in forum advanced Actionscript 3.0
    Replies: 1
    Last Post: 06-05-09, 10:19
  3. communicating from one MC to another both in main timeline
    By terraform in forum Actionscript 3.0 newbies
    Replies: 1
    Last Post: 27-02-09, 12:39
  4. flvplayback control from main timeline HELP!
    By wuzzi2ya in forum advanced Actionscript 3.0
    Replies: 3
    Last Post: 30-10-08, 16:45
  5. Unloading my external .swf within main timeline
    By Jack o Lantern in forum Actionscript 3.0 newbies
    Replies: 0
    Last Post: 23-08-08, 08:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts