Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-12-2008, 02:10 PM   #1
entropy
Registered User
 
Join Date: Apr 2008
Posts: 40
Default How to refresh a webpage using AS3?

In my flash application i have a button which should reload the webpage in which the flash application resides. However i don't know the code yet to be able to refresh the webpage when the button is pressed.
Does anyone know if this is possible? If so how?
entropy is offline   Reply With Quote
Old 08-12-2008, 10:04 PM   #2
GFX Complex
if(^_^){WelcomeToMyWorld}
 
GFX Complex's Avatar
 
Join Date: Jan 2008
Location: St.Louis
Posts: 137
Send a message via ICQ to GFX Complex Send a message via AIM to GFX Complex Send a message via MSN to GFX Complex Send a message via Yahoo to GFX Complex Send a message via Skype™ to GFX Complex
Default

why do you need to refresh the page.

That is the one thing I love the most about flash, you only need to load data not the page. This idea of having flash reload the page sounds kinda counter productive.
__________________
AS3 Apex Adobe user group | Twitter | Facebook
GFX Complex is offline   Reply With Quote
Old 08-12-2008, 11:42 PM   #3
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

I agree with GFX kinda...

but IF you need it, I guess you can use navigateToUrl to do it:

navigateToUrl(new URLRequest("the url"), "_self" );

It's just getting the URL you want to reload. You can easily get the URL of the swf object from the SWF's LoaderInfo instance. But usually the swf in some html page.

You could also use php to do it too.
__________________
www.lordofduct.com - come read my blog!

If you want to know how to program, take a math class, take a lot of math classes!
lordofduct is offline   Reply With Quote
Old 08-13-2008, 02:21 PM   #4
entropy
Registered User
 
Join Date: Apr 2008
Posts: 40
Default

I wanted to reload the webpage to have the .swf reload from its initial state. Sort of like a hard reload for the .swf instead of going to frame 1 to reload the .swf.

If it's possible to reload the swf without reloading the webpage, then that would even be better. I wasn't sure it existed, but if it does, does anyone happen to know how to fully reload an swf without reloading the webpage?
entropy is offline   Reply With Quote
Old 08-13-2008, 02:47 PM   #5
GFX Complex
if(^_^){WelcomeToMyWorld}
 
GFX Complex's Avatar
 
Join Date: Jan 2008
Location: St.Louis
Posts: 137
Send a message via ICQ to GFX Complex Send a message via AIM to GFX Complex Send a message via MSN to GFX Complex Send a message via Yahoo to GFX Complex Send a message via Skype™ to GFX Complex
Default

Quote:
Originally Posted by entropy View Post
I wanted to reload the webpage to have the .swf reload from its initial state. Sort of like a hard reload for the .swf instead of going to frame 1 to reload the .swf.

If it's possible to reload the swf without reloading the webpage, then that would even be better. I wasn't sure it existed, but if it does, does anyone happen to know how to fully reload an swf without reloading the webpage?
Why not just use Action Script to tell the swf to go back in the initial state?

I still don't understand why you are trying to go about reloading the whole swf file just to refresh the initial state?

I think you will end up doing more then you should just to get the same results that you can get by using action script.

But then again if you can give me one reason why you can't use action script to do this. I will personally find the solution to your question.
__________________
AS3 Apex Adobe user group | Twitter | Facebook
GFX Complex is offline   Reply With Quote
Old 08-13-2008, 03:17 PM   #6
entropy
Registered User
 
Join Date: Apr 2008
Posts: 40
Default

Quote:
Originally Posted by GFX Complex View Post
Why not just use Action Script to tell the swf to go back in the initial state?

I still don't understand why you are trying to go about reloading the whole swf file just to refresh the initial state?

I think you will end up doing more then you should just to get the same results that you can get by using action script.

But then again if you can give me one reason why you can't use action script to do this. I will personally find the solution to your question.
The reason is throughout my code i think i've been sloppy. So instead of nulling all objects out of memory, at the end some objects will still be in memory. So if i let the app go to frame 1 and reload the app that way, it will run slower the second time, because old objects are still in memory.
I know that is my fault, but when coding this project i was somewhat inexperienced.
A reset of the app's state would avoid the memory leak problems created through my sloppy coding.
The same is the case for certain variables and timers. It's too late into the project to properly recode everything so that every object will be nulled after use and every variable will be reset and every timer will be reset.
So the hard full reset of the application state is kind of my last tool to avoid a major rewrite for which there is no time.

However if you say it's possible to use only AS3 to go to the initial state of the app without reloading the page or the swf, then that would be the best solution. However i have no idea how to reset an swf to it's initial state without reloading the page, that was kind of the difficulty.
Is there something like a reset function in AS, which resets an swf to its initial state without reloading the page? (A full hard reset, which clears memory and resets variables and timers)

Last edited by entropy; 08-13-2008 at 03:27 PM.
entropy is offline   Reply With Quote
Old 08-13-2008, 03:20 PM   #7
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

There is so much you can delete/initialize when you try to go back to the initial state... For example, if you code is dependent to the timer, it might never work again because you cannot reset the timer back to 0... (At least that's what it used to be in AS2...)

Yes, you probably will be able to get away with such trap if you plan well from the beginning, but sometimes there is something that you simply cannot reset...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 08-13-2008, 07:20 PM   #8
entropy
Registered User
 
Join Date: Apr 2008
Posts: 40
Default

Quote:
Originally Posted by CyanBlue View Post
There is so much you can delete/initialize when you try to go back to the initial state... For example, if you code is dependent to the timer, it might never work again because you cannot reset the timer back to 0... (At least that's what it used to be in AS2...)

Yes, you probably will be able to get away with such trap if you plan well from the beginning, but sometimes there is something that you simply cannot reset...
Are you saying it's impossible to reset an swf to its initial state using AS3?
entropy is offline   Reply With Quote
Old 08-13-2008, 08:34 PM   #9
themortalgod
Member
 
Join Date: Mar 2008
Posts: 60
Default

just use javscript to change your objects src to an empty string then back to your swf, for example

Code:
<scripy>

function resetSWF(){
document.getElementById("myMovie").src = "";
document.getElementById("myMovie").src = "mysite.swf";
};

</script>
then in the flash just use a navigateToUrl as mentioned above targeting javascript:resetSWF();

(not you will have to edit the JS function according to whatever way you are embedding your flash, I just used a quick dirty example of the most mundane way for embedding a flash object

kinda a very dirty way of doing it, but as mentioned above, this is not something you should ever be doing in flash :S
themortalgod is offline   Reply With Quote
Old 08-13-2008, 08:39 PM   #10
stompwampa
Senior Member
 
Join Date: Aug 2006
Posts: 794
Default

The easiest way I see to do it is to have one swf file be a master Loader swf, which loads the swf you want to reset.

When it's time to reset...just tell the Loader swf to reload the same swf file.
__________________
-Stomp

===================================
Peter: "Look, my alphabet soup has a message in it! It says 'ooooooo'!"
Brian: "Peter, those are Cheerios."
stompwampa is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Publishing in AS3 breaks AS2 script ATNO ActionScript 3.0 7 08-11-2008 03:24 PM
loading multiple as2 in as3 problems? player bug? Project1.exe ActionScript 3.0 5 07-28-2008 01:05 PM
Getting a demo from AS2 to AS3 flashcooper ActionScript 3.0 4 06-13-2008 07:13 PM
very odd issue with as2 swf in as3 wrapper, looking for information nuge32 ActionScript 3.0 0 06-09-2008 11:52 PM
Converting to AS3. How would I do this in AS3 bubba ActionScript 3.0 7 10-08-2007 04:26 PM


All times are GMT. The time now is 01:27 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.