View Full Version : Making a movie clip not loop
Exile
03-16-2008, 04:46 PM
How would I make a Movie Clip only play once, not looping?
Say a user clicks a button and the movie clip plays then stops.
Also, is it possible to only play x amount of frames?
the binary
03-16-2008, 05:24 PM
here is a quick 'n dirty sample..
//-- define clip to play
var targetMc: MovieClip;
//-- desired target-frame
var targetFrame: Number = 10;
//-- flag wether was played or not
var played: Boolean = false;
//-- little helper
var checker: MovieClip = _root.createEmptyMovieClip('check_mc', _root.getNextHighestDepth());
// start playing and checking for 'target-frame'
myButton.onRelease = function()
{
if (played)
{
trace('allready played')
return;
}
trace('playing '+ targetMc + ' to: '+ targetFrame);
checker.onEnterFrame = doCheck;
played = true;
}
// check if 'target-frame' has reached
// if true, stop playing and checking
function doCheck ()
{
if (yourMc._currentframe >= targetFrame)
{
targetMc.stop()
checker.onEnterFrame;
}
}
hope that shed some light..
cheers
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.