-
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!
-
Senior Member
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);
-
Originally Posted by somlemeg
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!
-
Senior Member
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.COMPLETE, gotoMyFrame);
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);
}
-
Senior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|