views:

799

answers:

2

Hi I'm loading an external swf into a MovieClip, and I want it to stop until I choose to play. Currently it plays upon loading immediately.

var mc:MovieClip;

var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, eventLoaded); 
var request:URLRequest;
request = new URLRequest("external.swf");
swfLoader.load (request);

function        eventLoaded(e:Event): void
{
   mc = e.target.content as MovieClip;
// does not stop the clip
   mc.Stop ();
}

So I tried adding a Event.ENTER_FRAME to the movieclip and stop it there, that will stop but it will play the first frame. Is there a way to get it to stay stopped when loaded until I choose Play?

+1  A: 

I wrote this simple TestCase and it works fine... the loaded swf is quite simple, just a tween on the main timeline.

package {
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLRequest;

    public class Test extends Sprite
    {
        private var loader:Loader = new Loader;

        public function Test()
        {
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaded );
            loader.load( new URLRequest( 'testFile.swf' ) );    
        }

        public function handleLoaded( event:Event ):void
        {
            addChild( loader.content );
            var mc:MovieClip = loader.content as MovieClip ;
            mc.stop();
        }
    }
}
Jochen Hilgers
A: 

Hmm, I'm on another computer, and I can't seem to add to the previous reply.

The first frame of testfile.swf is executed. That is causing problem for me. If you have code there, you would see it.

Robin