PDA

View Full Version : load external file and go to specific frame in as3


initialk
04-14-2009, 10:03 PM
I've been trying to load an external SWf file that would go directly to a specific frame. Although there may be a way to do so by adding a gotoAndStop line in the first frame of that SWF file, I'm trying to find a way to do so on the parent file instead (where the button activating this is located). This is my code thus far:

page2.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
removeChild(loader);
var newSWF:URLRequest = new URLRequest("chpIntro.swf");
loader.load(newSWF);
addChild(loader);
MovieClip(loader.content).gotoAndStop(2);}

Any help is appreciated.

Stroke
04-15-2009, 01:13 AM
MovieClip(loader.content).gotoAndStop(2);

As it was for AS2.0, think you can only do that if your above action is within the loader's complete handler, as the movie needs to be fully loaded, before you can target a specidfic frame.

initialk
04-15-2009, 01:53 PM
okay, so i have my codes mixed up - go figure! Does anyone know how to set this right in as3 then?

kkbbcute
04-15-2009, 02:07 PM
Use this:
public function firstConstructor():void
{
addEventListener( Event.ADDED_TO_STAGE, myFunction );
}

private function myFunction( event:Event ):void
{
MovieClip(loader.content).gotoAndStop(2);
}