Access totalFrames from an external loaded swf

Categories Actionscript

Use UILoader to load the external swf and on the INIT event we will be able to get the loaded swf total frames. Don’t forget to drag the UILoader component (from the components panel, ctr+F7) into your library, and import fl.containers.*.

ActionScript

  1. import fl.containers.*;
  2.  
  3. var swfLoader:UILoader = new UILoader();
  4. swfLoader.scaleContent = false;
  5.  
  6. swfLoader.addEventListener(Event.INIT, loader_init);
  7.  
  8. function loader_init(evt:Event):void
  9. {
  10.     var mc:MovieClip = swfLoader.content as MovieClip;
  11.     trace(mc.totalFrames)
  12. }
  13.  
  14. var urlReq:URLRequest = new URLRequest("to_be_loaded.swf");
  15.  
  16. swfLoader.load(urlReq);

I recently used this technique to build video like player (play, stop, seek) for swf’s.

Share this
Facebooktwitter

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *