I’m a Flex developer who had to do some coding in Flash, so my understanding of how putting an action on a time line is somewhat limited.
I’m trying to attach this action on the first frame of the movie that I’m planning play. When I play the movie for the first time, the code executes as expected. However, when I restart or rewind to the first frame of the movie, the code no longer executes. I’m not sure why this is happening, as it seemed added actionscript code to a frame seems pretty straight forward.
import flash.utils.Timer;
import flash.net.URLLoader;
import flash.net.URLRequest;
var urlLoader:URLLoader;
var timer:Timer;
startAdPlay();
function startAdPlay():void
{
if( urlLoader == null ) {
urlLoader = new URLLoader();
}
urlLoader.load( new URLRequest( "http://localhost:20081/startadplay/15" ) );
timer = new Timer( (15 * 1000) );
timer.addEventListener(TimerEvent.TIMER, stopAdPlay );
timer.start();
}
function stopAdPlay(event:TimerEvent):void
{
urlLoader.load( new URLRequest( "http://localhost:20081/stopadplay" ) );
timer.stop();
stop();
}
I suppose you don’t call
startAdPlay()while restarting the movie in app