A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Controlling Externally Loaded SWF in AS3

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Posts
    103

    Controlling Externally Loaded SWF in AS3

    I'm a little new to AS3 so there are a few things that I'm trying to learn from knowing AS2 before. One of them is loading external SWF files. Here's what I have going on... On the first frame of my main container file, I have this:

    var iwgResults = new Loader();
    iwgResults.load(new URLRequest("win1.swf"));
    iwgContainer.addChild(iwgResults);
    This loads up "win1.swf" and places the "iwgResults" child in my "iwgContainer" movie clip I already have set up. This works wonderfully and loads it in the right spot. The problem comes when I want to send a simple gotoAndPlay action to the main timeline of win1.swf. This is what I currently have later on in the timeline of my main container file:

    iwgContainer.iwgResults.gotoAndPlay(2);
    Obviously this isn't how it's done in AS3, but that's what I remember from AS2. What do I have to do differently when I have to tell win1.swf to gotoAndPlay from the main container file? I'd really appreciate the help... Thanks!

  2. #2
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171
    I think it goes something like this:
    Code:
    var myChildren:Array = new Array([])
    function addSwf
    {
    var iwgResults = new Loader();
    iwgResults.load(new URLRequest("win1.swf"));
    iwgContainer.addChild(iwgResults);
    myChildren.push(iwgResults);
    }
    // go to and play
    myChildren[0].gotoAndPlay(2);

  3. #3
    Senior Member
    Join Date
    Jan 2003
    Posts
    103
    Quote Originally Posted by somlemeg View Post
    I think it goes something like this:
    Code:
    var myChildren:Array = new Array([])
    function addSwf
    {
    var iwgResults = new Loader();
    iwgResults.load(new URLRequest("win1.swf"));
    iwgContainer.addChild(iwgResults);
    myChildren.push(iwgResults);
    }
    // go to and play
    myChildren[0].gotoAndPlay(2);
    Hmm, that doesn't seem to be working for me. It's outputting syntax errors. I've never dealt with arrays before so I'm not sure what the problem is!

  4. #4
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171
    This is probably not the best way to do it, but it works.

    PHP Code:
    var iwgContainer:MovieClip = new MovieClip();
    stage.addChild(iwgContainer);
    var 
    iwgResults = new Loader();
    function 
    addSwf():void
    {
        
    iwgResults.contentLoaderInfo.addEventListener(Event.COMPLETEgotoMyFrame);
        
    iwgResults.load(new URLRequest("win1.swf"));
    }
    addSwf();
    // go to and play;
    function gotoMyFrame(e:Event):void
    {
        
    iwgContainer.addChild(iwgResults);
        
    MovieClip(iwgResults.getChildAt(0)).gotoAndPlay(2);


  5. #5
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171
    skip the two first lines if iwgContainer is already an movieClip.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center