-
About controlling external movies
I'm calling an external movie, just like this:
code: var externalMovie:MovieClip;
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest("external.swf"));
myLoader.contentLoaderInfo.addEventListener(flash. events.Event.COMPLETE, finishedLoading);
function finishedLoading (e:Event):void{
externalMovie = MovieClip(myLoader.content);
stage.addChild(myLoader);
}
the external movie loads fine, but when I try to control it from outside its opening function, like:
code: function playIt()
{
externalMovie.play();
}
playIt();
I get an ugly error (1009).
I know it is because the externalMovie variable is available only under the finishedLoading function scope. But what if I want to control my external movie from anywhere else in my movie? How can I "globalize" my variable to be available by any other function?
PLEASE HELP!!!
-
Senior Member
In my Flashscript class package there is a class CustomDispatcher, which is basically an Eventdispatcher class. Once the movie is loaded, an event is dispatched.
PHP Code:
package biz.Flashscript.events { // // Eventdispatcher // import flash.events.EventDispatcher; import flash.events.Event; import flash.events.TimerEvent; import flash.utils.Timer; public class CustomDispatcher extends EventDispatcher { public static var ACTION:String = "action"; public function CustomDispatcher() { } public function doAction (delay:Number,repeat:Number):void { var myTimer:Timer = new Timer (delay,repeat); myTimer.addEventListener (TimerEvent.TIMER, propAction); myTimer.start (); function propAction (e:TimerEvent):void { dispatchEvent (new Event(CustomDispatcher.ACTION)); } } } }
An example of how it is implemented is shown here.
http://flashscript.biz/flashas3/biz/index.html
Click on CustomDispatcher.
- The right of the People to create Flash movies shall not be infringed. -
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
|