views:

307

answers:

2

I am trying to import a SWF file into a custom loader and then treat the loaded SWF file as a MovieClip object. The code for the functionality can be seen below.

public function loadMyMovie(movie:String)
{

    var now:Date = new Date();

    var rnd:String = "?randomize=" + now.time;

    var request:URLRequest = new URLRequest(movie);

    request.data = getObjectURLVariables(this.loaderInfo.parameters)

    var loading:Loader = new Loader();

    loading.load(request);

    loading.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

    function loadComplete(event:Event):void {

     var movie:MovieClip = addChild(loading.content);

     movie.gotoAndStop(0);

    }

}

When I do this I get the following error.

"Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type flash.display:MovieClip."

A: 

The answer is that the SWF file I was attempting to import was AS2, so it was being imported as a AVM1Movie object. Need to speak with the developer who produced the SWF.

Philip Bennison
A: 

You make can try this.
var movie:DisplayObject = event.target.content as DisplayObject;
AVM1Movie is not a DisplayObjectContainer.

bhups
I need to be able to control how the imported SWF is played, so I am going to have to get the developer of the SWF to amend his code or to rebuild it in AS3.
Philip Bennison