define('DISALLOW_FILE_EDIT', true);{"id":362,"date":"2009-12-07T14:10:16","date_gmt":"2009-12-07T19:10:16","guid":{"rendered":"http:\/\/www.unfocus.com\/?p=362"},"modified":"2009-12-07T14:11:06","modified_gmt":"2009-12-07T19:11:06","slug":"stop-all-child-movieclips-in-flash-with-actionscript-3-0","status":"publish","type":"post","link":"http:\/\/www.unfocus.com\/2009\/12\/07\/stop-all-child-movieclips-in-flash-with-actionscript-3-0\/","title":{"rendered":"Stop All Child MovieClips in Flash with Actionscript 3.0"},"content":{"rendered":"

While trying to come up with a way to get two different movies loaded at the same time, to play at different frame rates, I came up with a method to recursively stop all child movies of an as3 MovieClip. I didn’t end up using it, but I thought it might be useful for someone, so here it is:<\/p>\n

[cc lang=’actionscript3′]
\nimport flash.display.DisplayObjectContainer;
\nimport flash.display.MovieClip;<\/p>\n

function stopAll(content:DisplayObjectContainer):void
\n{
\n\tif (content is MovieClip)
\n\t\t(content as MovieClip).stop();<\/p>\n

\tif (content.numChildren)
\n\t{
\n\t\tvar child:DisplayObjectContainer;
\n\t\tfor (var i:int, n:int = content.numChildren; i < n; ++i)\n\t\t{\n\t\t\tif (content.getChildAt(i) is DisplayObjectContainer)\n\t\t\t{\n\t\t\t\tchild = content.getChildAt(i) as DisplayObjectContainer;\n\t\t\t\t\n\t\t\t\tif (child.numChildren)\n\t\t\t\t\tstopAll(child);\n\t\t\t\telse if (child is MovieClip)\n\t\t\t\t\t(child as MovieClip).stop();\n\t\t\t}\n\t\t}\n\t}\n}\n[\/cc]\n\nThe plan was to use that to stop playing movies, every other frame, and restart them on the alternative frames, but there is apparently no way to tell if a MovieClip is currently playing or not, to know which ones to restart.\n\nI did end up hacking Tweener to add support for a Timer based update method. That way I can adjust the stage FPS to match the older timeline content (at 12fps) and have my Tweener based interactions work at a silky smooth 60 FPS.\n\nI'll post more on that later.\n<\/p>\n","protected":false},"excerpt":{"rendered":"

While trying to come up with a way to get two different movies loaded at the same time, to play at different frame rates, I came up with a method to recursively stop all child movies of an as3 MovieClip. I didn’t end up using it, but I thought it might be useful for someone, … Continue reading “Stop All Child MovieClips in Flash with Actionscript 3.0”<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[48,49,47],"_links":{"self":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts\/362"}],"collection":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/comments?post=362"}],"version-history":[{"count":11,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts\/362\/revisions"}],"predecessor-version":[{"id":552,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts\/362\/revisions\/552"}],"wp:attachment":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/media?parent=362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/categories?post=362"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/tags?post=362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}