Question

I have a website, and basically I want to use flash to automatically redirect the web site to another with as soon as its load. But it keeps rapidfiring, and has even crashed my computer at one point. How can I set this to only only send the user once.

addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);

function fl_EnterFrameHandler(event:Event):void
{
//navigateToURL(new URLRequest("http://www.levittproperties.com/sitebuildercontent/sitebuilderfiles/homepage.swf"), "_self");
trace("Entered frame");
}

The '//' is just incase you try in your flash. I don't want you to crash too. The 'trace' is sufficient to see what I'm talking about.

Was it helpful?

Solution 2

Try to do as Garry Wong said. But if you must use the ENTER_FRAME for some reasons , so use it only once , like this:

addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);

function fl_EnterFrameHandler(event:Event):void
{
    removeEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);
    navigateToURL(new URLRequest("http://www.levittproperties.com/sitebuildercontent/sitebuilderfiles/homepage.swf"), "_self");     
}

OTHER TIPS

All you need to do is kill the event listener if you're already on your target page, consider the following:

import flash.external.ExternalInterface;

addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);

function fl_EnterFrameHandler(event:Event):void
{
    var gotoURL:String = "http://www.levittproperties.com/sitebuildercontent/sitebuilderfiles/homepage.swf";
    var currentURL:String = ExternalInterface.call("window.location.href.toString");
    if(gotoURL != currentURL) {
        navigateToURL(new URLRequest(gotoURL), "_self");
    } else {
        Event.currentTarget.removeEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top