Edit.. Title should read "AS3 - add OnEnterFrame event to get currentFrame
I have been given a small job, to load a sequence of animated .swfs in a loop.
I need to compare the current loaded clip's currentFrame to its totalFrames in order to know when it has completed playing, and to load in the next.
// ... snip ...//
public class Main extends MovieClip
{
private var _xmlFile:String = "movieList.xml";
private var _containerMovie:MovieClip;
private var _baseUrl:String;
private var _flashFolder:String;
private var _movieXMLListData:XMLList;
private var _currentMovie:Number = 0;
// ... snip ...//
private function loadMovie(_currentMovie:Number):void
{
var movieClip:String = _movieXMLListData[_currentMovie].@file;
var clickThrough:String = _movieXMLListData[_currentMovie].@clickThrough;
var loader:Loader = new Loader();
var placeHolder:MovieClip = new MovieClip();
placeHolder.name = "placeHolder";
placeHolder.addChild(loader);
_containerMovie.addChild(placeHolder);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCompleteEvent);
loader.load(new URLRequest(_baseUrl + _flashFolder + movieClip));
}
private function onLoadCompleteEvent(loadEvent:Event):void
{
trace("load succeeded");
_containerMovie.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame (event:Event):void
{
trace("tick");
trace("frame " + _containerMovie.placeHolder.currentFrame); // error on this line
}
// ... snip ...//
}
I get an error message (in FlashDevelop) - line 107 is the last line of code above, in bold.
[Fault] exception, information=TypeError: Error #1010: A term is undefined and has no properties.
Fault, onEnterFrame() at Main.as:107
This is some sort of scoping issue, surely, as I can trace _containerMovie.currentFrame (which is always 0).
How then do I address these properties of a swf loaded into a Loader?
Also, in AS1 & 2, when loading a swf into a movieclip, the movieclip's onEnterFrame, etc etc were deleted - which is why I created the placeHolder clip to hold the loader. Is this still the case?
__________________________
Hmbeh.