Skip to main content
Participating Frequently
November 16, 2009
Answered

totalFrames of dynamically loaded swf

  • November 16, 2009
  • 1 reply
  • 8877 views

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.

This topic has been closed for replies.
Correct answer kglad

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.


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

1 reply

socalfish-fDJTBM
Inspiring
November 16, 2009

Try this:

trace(event.currentTarget.content.totalFrames);

Participating Frequently
November 16, 2009

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?

socalfish-fDJTBM
Inspiring
November 16, 2009

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?