Skip to main content
Participating Frequently
October 22, 2009
Question

How to find totalFrames of Captivate 4 .swf in Flash CS4

  • October 22, 2009
  • 1 reply
  • 871 views

I have a series of Captivate4 AS3 .swf files that I am loading into an interface created in Flash CS4.  The files are loading and playing correctly, but I need to find a way to detect when an imported .swf gets to the end of it's timeline so that I can load the next one.

Here's my code:

var myLoader:Loader = new Loader();
var movieURL:String = "resources/testTestTest.swf";
var req:URLRequest = new URLRequest(movieURL);
var currentMovie;

var endShow:Boolean = false;

myLoader.addEventListener(Event.COMPLETE, loadComplete);

function loadComplete(evt:Event)
{
    currentMovie = myLoader.content;
    currentMovie.rdcmndPause = 0; //fails to pause imported .swf
    trace(currentMovie.cpInfoCurrentDate); //fails to trace out
}
addChild(myLoader);
myLoader.load(req);

Please, help!!

This topic has been closed for replies.

1 reply

Participating Frequently
October 23, 2009

I forgot to add "contentLoaderInfo" to the myLoader eventListener.  Here's my working code:

Captivate- output to AS3, make sure Flash player is same as destination

AS3 code from flash UI:

//initial variables

var myLoader:Loader = new Loader();
var movieURL:String = "fileName.swf";
var req:URLRequest = new URLRequest(movieURL);
var currentMovie:*; //data type movie; use wildcard- data type unavailable at compile time

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

function loadComplete(evt:Event):void
{
    currentMovie = MovieClip(myLoader.content);//data type imported .swf
    trace("frame count = " + currentMovie.rdinfoFrameCount); //rdinfoFrameCount is a Captivate var
    //trace("current frame = " + currentMovie.rdinfocurrFrame); //rdinfoFrameCount is a Captivate var
}

addChild(myLoader);
myLoader.load(req);

//set up timer to check to see if current frame == total frames

var endTimer:Timer = new Timer(1000);//runs every sec.
endTimer.addEventListener(TimerEvent.TIMER, onTimer);
endTimer.start();

function onTimer(evt:TimerEvent):void

{
    //trace("current frame = " + currentMovie.rdinfocurrFrame);
    if((currentMovie.rdinfocurrFrame + 10) >= currentMovie.rdinfoFrameCount) //had to add 10 to current frame

{

     //write your function here

    endTimer.stop();
    }
}