MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference page 80

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

When working with this function, you need to be careful about the memory you use in a
SWF file. For example, when you remove a movie clip from the SWF file, it will not remove
any
setInterval()
by using
clearInterval()
example:
// create an event listener object for our MovieClipLoader instance
var listenerObjectbject = new Object();
listenerObject.onLoadInit = function(target_mc:MovieClip) {
trace("start interval");
/* after the target movie clip loaded, create a callback which executes
about every 1000 ms (1 second) and calls the intervalFunc function. */
target_mc.myInterval = setInterval(intervalFunc, 1000, target_mc);
};
function intervalFunc(target_mc) {
// display a trivial message which displays the instance name and arbitrary
text.
trace(target_mc+" has been loaded for "+getTimer()/1000+" seconds.");
/* when the target movie clip is clicked (and released) you clear the
interval
and remove the movie clip. If you don't clear the interval before deleting
the movie clip, the function still calls itself every second even though
the
movie clip instance is no longer present. */
target_mc.onRelease = function() {
trace("clear interval");
clearInterval(this.myInterval);
// delete the target movie clip
removeMovieClip(this);
};
}
var jpeg_mcl:MovieClipLoader = new MovieClipLoader();
jpeg_mcl.addListener(listenerObject);
jpeg_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
this.createEmptyMovieClip("jpeg_mc", this.getNextHighestDepth()));
If you work with
setInterval()
when you call the function. The
members if you do not use the keyword. This is illustrated in the following example. For a
FLA file with a button called
var me:User = new User("Gary");
this.deleteUser_btn.onRelease = function() {
trace("Goodbye, "+me.username);
clearInterval(me.intervalID);
delete me;
};
80
ActionScript language elements
function running within it. Always remove the
when you have finished using it, as shown in the following
within classes, you need to be sure to use the
setInterval()
deleteUser_btn,
setInterval()
function does not have access to class
add the following ActionScript to Frame 1:
function
keyword
this

Advertisement

Table of Contents
loading

Table of Contents