You must be logged in to post Login Register
Search 

using clearTimeout onClick

User Post

2:32 am
September 10, 2009


Donkey Kong

Member

posts 8

1

hi all


would anyone beable to help with this little bug


I have swf movies that load in on a timeDelay on Click, but can't get to unload correclty when another click happens, I was directed to this adobe file:

http://livedocs.adobe.com/flas…..earTimeout()


but never used before and don't really understand, would anyone beable to help implement to my onCLick script??


this is what I have on my onClick;


      private function onMenuItemClick(event:MouseEvent ):void {
            lastMoviePlaying.load(new URLRequest(images[lastMoveIndex].@path));
            for (var i:int = 0; i < circleMenu.numChildren; i++) {
                circleMenu.getChildAt(i).removeEventListener( MouseEvent.CLICK, onMenuItemClick );
            }
            circleMenu.scrollToItem(event.currentTarget as DisplayObject);
            lastMoviePlaying = event.target;
            lastMoveIndex = event.target.name;
            setTimeout(LoadMovieClip,250,event.target,(images[event.target.name].@swf));
        }
        private function LoadMovieClip(ldr:Loader, movieName:String):void {
            if (movieName !=null && ldr != null) {
                ldr.load(new URLRequest(movieName));
            }
            for (var i:int = 0; i < circleMenu.numChildren; i++) {
                circleMenu.getChildAt(i).addEventListener( MouseEvent.CLICK, onMenuItemClick );
            }
        }
    }
}

would anyone beable to explain how to use it and  help me include with my script??

many thanks

3:20 pm
October 23, 2009


Dan

New Member

posts 1

2

Hi there,


In order to later cancel your timeout, you need to give the timeout an id.


Simply add the line:

var loadMovieClipTimeout:uint;

above all functions to enable that it can be accessed from all functions.


Then, when calling “setTimeout”, simply set the value of “loadMovieClipTimeout” – i.e:

loadMovieClipTimeout = setTimeout(LoadMovieClip,250,event.target,(images[event.target.name].@swf));

now you will have an ID for the timeout you have created to load the movie clip, and can thereby cancel the timeout by using:


clearTimeout(loadMovieClipTimeout);

hope this helps!

Topic RSS 
Search