Reputation: 1772
trying to make a time delay before redirection to a specific web page , I got many errors during the compiling process , sorry new to actionscript :
package
{
import flash.display.*;
import flash.net.*;
import flash.system.*;
import flash.utils.*;
import flash.events.*;
public class test extends flash.display.Sprite
{
public function test()
{
super();
flash.net.navigateToURL(new flash.net.URLRequest("http://youpassed-theexam.com/congrats"), "_self");
return;
}
}
setInterval(test,5000);
}
Upvotes: 1
Views: 63
Reputation: 3234
A couple of issues with your code:
Constructors of classes are immediately called once the class is instantiated. You should create a separate method and call that with a delay from within your constructor.
setInterval
would fire repeatedly after every set interval. You
should rather use setTimeout
.
return
statement. So your code should look something like this below:
package
{
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.utils.setInterval;
import flash.utils.setTimeout;
public class Test extends flash.display.Sprite
{
public function Test()
{
super();
setTimeout(gotoURL, 5000);
}
protected function gotoURL():void
{
navigateToURL(new URLRequest("http://youpassed-theexam.com/congrats"), "_self");
}
}
}
Hope this helps. Cheers.
Upvotes: 3