define('DISALLOW_FILE_EDIT', true);
That looks like you are trying to pass a instance of MouseEvent to something that expects DisplayObjectContainer (like stopAll). You may have done this:
someBtn.addEventListener(MouseEvent.CLICK, stopAll)
When you need to do this:
someBtn.addEventListener( MouseEvent.CLICK,
function stopHandler( event:MouseEvent ):void {
stopAll( yourMovie );
}
);
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@3c8ef299 to flash.display.DisplayObjectContainer.
can anybody help me out …
]]>I’m afraid that’s outside of the scope of this function.
]]>That is pretty strange. I’d probably have to see the fla to determine why that happens – unless it’s Flash 9 publish target. Flash 9’s MovieClip functionality is way buggy. If you are targeting Flash 9, I’d suggest kicking it up to Flash 10. They fixed enough bugs to make it worth it.
]]>That makes sense, though I can imagine some edge cases where that might fail (what if the currentFrame ticks forward, but a frame based stop event is meant to stop the clip?).
You could probably use a self removing ENTER_FRAME event listener instead of the timeout to make it work for a wider range of framerates.
MovieClip.player and Flash Player 11+ seems like a good way to go. 🙂
]]>Unfortunately, you can’t easily figure out if the MovieClip instance you are stopping is currently playing or not in Flash 10.3 and lower (actually, there is no general way to do it – you have to build a framework). They did add a “playing” property for Flash Player 11 content, so going forward, this will become possible.
]]>The first technique I described in my previous post seems to do the trick. What I do is upon PAUSE being required, I maintain a Dictionary of all the child objects and their current frame.
Then set a Timer with a delay of 500/stage.frameRate. I agree that 500 is a bit abitrary, but its to make sure that the frame will have changed. Of course if you have a very slow running application where there its not running at your desired frame rate, then I guess this logic could be a problem. In my case its ok, as my screens are very basic and its known what hardware I will be running on. So this may not be the *perfect* solution, but its close enough for my needs.
Then when the Timer ticks over, compare each key in the Dictionary and its value and see if the currentFrame of the key has changed, if not, remove it from the dictionary, if so, then stop the item and update the value of the key to its new frame.
I then use the dictionary when it comes to unpausing and gotoAndPlay(value) of each key in the dictionary. Seems to work so far..
]]>Heheh, I just wrote a recursive function to do the same thing. However, I just hit a roadblock when it came to restarting the clips.
How do you know which ones to restart??!! Only method I could think of would be to wait for 1/stage.frameRate milliseconds and see if the currentFrame changes, but that would be pretty useless as depending upon the number of children to pause, the delay could be quite significant.
Only other way would be to extend MovieClip and keep a Boolean state, but this is a lot of authoring work and defeats the purpose of writing this general functionality.
Ideas anyone?? Did you have any breakthroughs?
]]>I need script for Timer and following buttons.
1) Single button for timer ON/OFF/Display timer
2) Reset
That depends on how the clip “mc_mc” is scripted. If it’s just a MovieClip (even with nested playing MovieClips), this script should work. Just call stopAll(root.mc_mc) (assuming it’s an AS3 timeline). If it’s just one playing MovieClip, with nothing nested, the normal stop() method should be sufficient. You may need to cast – this a is difficult concept for some users new to AS3 – (root.mc_mc as MovieClip).stop();
]]>Actionscript 2.0 is a whole different thing. I found this in actionscript.org forums, it might work (untested):
stopMovies(_root);
function stopMovies(mov:MovieClip) {
mov.stop();
for (movs in mov) {
if (typeof mov[movs] == "movieclip") {
mov[movs].stop();
stopMovies(mov[movs]);
}
}
}