Copy link to clipboard
Copied
I've been trying for 2 days now to find the total number of frames of a dynamically loaded .swf.
Here's an example code:
var loader:Loader = new Loader;
loader.load(new URLRequest("mop.swf")) master_mc.addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, xmlLoadedF);
function xmlLoadedF(event:Event):void
{
trace(loader.content.totalFrames);}
I am truly puzzled.
Any help would be greatly appreciated.
1 Correct answer
i know this is old but i found it via google and thought i would correct the error.
you can reference avm1 swf properties (and methods) by using localconnection to communicate between the avm1 and avm2 swfs, SWF to SWF Communication when both swfs use actionscript 3.0
Copy link to clipboard
Copied
Try this:
trace(event.currentTarget.content.totalFrames);
Copy link to clipboard
Copied
now I get this error:
ReferenceError: Error #1069: Property totalFrames not found on flash.display.AVM1Movie and there is no default value.
at Untitled_fla::MainTimeline/xmlLoadedF()
THe movie I am loading has the animation embeded right in the main timeline.
What could be the problem now?
Copy link to clipboard
Copied
Did this error occur after changing the trace? If so then try emmenting the error by commenting out the trace statement. The error shows it trying to get info from Untitled_fla, is this the name of your fla file? Are you using AS2 or AS3?
Copy link to clipboard
Copied
Hey,
The error occured after changing the trace.
The only code Ihave is the example code posted here as I want to make it work here and then focusonmy application.
Hence, the actual fla filename is untitled.fla
I am using AS3 and to movie I am trying to load is AS2
Copy link to clipboard
Copied
Because your script class was named CatProcess I saved the fla file as CatProcess and added the CatProcess in the fla Class Properties.
Copy link to clipboard
Copied
Because your script class was named CatProcess I saved the fla file as CatProcess and added the CatProcess in the fla Class Properties.
Still can't send the fla? ummm
Copy link to clipboard
Copied
Does it work by renaming the files and adding the class?
Do you want me to send you the .fla?
Copy link to clipboard
Copied
I'm not having much luck with this.
What I want to use this script for is for a player that loads both static images and flash movies dynamically from an xml.
It uses a timer to switch between picture after a couple for seconds. For movies however, it would have to wait for the movie to finish and then switch.
Is there any way to do this without using .totalFrames?
If not, the first question is still really valid.
Thank you.
Copy link to clipboard
Copied
I think this might be complicated by loading an AS2 movie into an AS3 document.
The error message is telling you that there is no totalFrames property and in fact AS2 movies would have a _totalframes property.
So you could try that.
Also I'm not sure if event.currentTarget.content returns a MovieClip or a DisplayObject. If it is a DisplayObject (which is most likely) then it too wouldn't have totalFrames property. So you might need to cast it as a MovieClip. Something like this:
MovieClip(event.currentTarget.content).totalFrames
And or it could be some combination of these two above issues? I don't know really, I'm just grasping at straws. But I don't see any way to know when a clip is done playing other than to compare its currentFrame to totalFrames.
Copy link to clipboard
Copied
It indeed is a display object.
However when I try to cast it as a movie clip using the line you mentioned inside the function it returns the following error.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@f377701 to flash.display.MovieClip.
at Untitled_fla::MainTimeline/xmlLoadedF()
Copy link to clipboard
Copied
Turns out that you can't access the totalFrames (or _totalframes) of an AVM1Movie in AS3. There are no methods — so no stop() or gotoAndPlay(). And there are only a limited set of properties — x, y, alpha, but no totalFrames or currentFrame.
That is really annoying! I can kind of see why there are no methods, but having some properties, but not others is crazy.
Sorry I don't have better news for you there.
Copy link to clipboard
Copied
i know this is old but i found it via google and thought i would correct the error.
you can reference avm1 swf properties (and methods) by using localconnection to communicate between the avm1 and avm2 swfs, SWF to SWF Communication when both swfs use actionscript 3.0

