Why does my imported MovieClip (imported from SWF) not behave like a MovieClip?

25 Views Asked by At
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.Loader;
import flash.net.URLRequest;

stop();

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, CreateCG_POST_LOAD);

loader.load(new URLRequest("TestMovieClip.swf"));

function CreateCG_POST_LOAD( e:Event ):void{

    var newMC:MovieClip = MovieClip(loader.content);
    stage.addChild(newMC);

    newMC.gotoAndStop(4); //seemingly does nothing

    trace("currentFrame " + newMC.currentFrame); //outputs 1, should be 4
    trace("totalFrames " + newMC.totalFrames); //outputs 1, should be 4
}
  1. The above code appears on frame 1 (of the stage) of my test project.

  2. TestMovieClip is only 4 frames, with NO AS3 code.

  3. I created TestMovieClip.swf by right-click (in library) -> 'Export SWF...'

GOAL: I would like to load an external swf and treat it as a MovieClip. I want to be able to navigate to specific frames.

RESULT: The clip appears, but plays on an endless loop. The trace output seems nonsensical.

1

There are 1 best solutions below

0
Orange On

I discovered that the MovieClip is created WITHIN loader.content as a child object.

I was able to reach it with this:

var newMC:MovieClip = MovieClip( MovieClip(loader.content).getChildAt(0) );