delay before getURL? 2004-02-19 - By andrew
Back Hi All: I'm still trying to work out how to create a 1-sec delay before executing a getURL call that's part of an onEnterFrame function. This is a navbar with buttons that re-shuffle when clicked, and then call a getURL (modified from Andreas Weber's code).
I've tried putting the getURL in a function, and then using setInterval to put a 1-second delay before the function executes, but that's creating a problem where the getURL is called repeatedly, and the request doesn't have time to execute. I think it's related to the browser not receiving a timely answer from the server, so the page is not unloaded from the browser and the request executes again.
I've tried to prevent the getURL call from executing more than once, but that hasn't worked. I'm hoping someone may have encountered this problem before, or if not, maybe someone could give me an example of how to call the getURL function only once (I'm hoping that might solve the issue).
I had tried creating a var "wasItClicked" outside the "positionButtons()" function, and then setting it to false after the function executed, and wrapping the "goThere()" function in a conditional, but that didn't work...maybe I'm doing it wrong, or maybe the problem is unrelated to the getURL call executing repeatedly, but at this point I've run out of ideas! Thanks for any insights. If it's helpful to post the actual .fla file I'm happy to do it.
my complete code is as follows:
_global.mainTimeline = this; //testing static state var secure; _global.subTab = subTab; _global.navPath = navPath; _global.targetURL = ""; _global.mcpressed = "false"; _global.inRoll = function(theClip, theFrame) { theClip.gotoAndPlay(theFrame); }; _global.outRoll = function(theClip, theFrame) { theClip.gotoAndPlay(theFrame); };
//space between buttons pad = 15; //left corner position of buttons x = 10; y = 15; //flag for first positioning of buttons init = true; //bring buttons to initial position and attach onRelease handlers; positionButtons(init); function positionButtons(init) { var widthBefore = 0; for (i=0, len=buttons.length; i<len; i++) { buttons[i].newY = y; buttons[i].newX = x+(i*pad)+widthBefore; if (!init) { // do the tweening buttons[0].onEnterFrame = function() { buttons[1].gotoAndStop(1); for (i=0, len=buttons.length; i<len; i++) { buttons[i]._y = (buttons[i].newY+buttons[i]._y)/2; buttons[i]._x = (buttons[i].newX+buttons[i]._x)/2; } }; } else { // position them without tweening buttons[i]._y = buttons[i].newY; buttons[i]._x = buttons[i].newX; buttons[0].gotoAndStop(5); buttons[0].useHandCursor = false; } widthBefore += buttons[i]._width; if (init) { buttons[i].onRelease = function() { sortButtons(this); }; } } init = false; }
function sortButtons(clickedButton, theUrl) { for (i=0, len=buttons.length; i<len; i++) { //find index of the clicked button if (buttons[i] == clickedButton) { buttons[i].gotoAndStop(5); break; } } //remove button from array buttons.splice(i, 1); //add it at the first position buttons.unshift(clickedButton);
positionButtons(); setInterval(goThere(), 1000);
} function goThere() { if (secure) { getURL("https://"+navPath+"/"+targetURL, "_self"); } else { getURL("http://"+navPath+"/"+targetURL, "_self"); } }
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
|
|