A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: About controlling external movies

  1. #1
    Junior Member
    Join Date
    Nov 2001
    Posts
    1

    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!!!

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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.TIMERpropAction);
                
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center