PDA

View Full Version : local connection help?



NTD
July 3rd, 2005, 06:16 AM
Hi,

I created a newsreader movie that is populated by a textfile. I also created an admin movie to modify the textfile with a bit of PHP. The theory is to update the textfile for the newsreader movie from the admin, making editing the original newsreader.fla unnecessary.However, I would like to update the information without a browser refresh. I thought I might run into some browser cacheing issues when trying to update the data real time, so my idea was to use the localConnection method to update the newsreader with the content that is being saved to the textfile. I thought this would be a workaround for the browser cacheing the old textfile contents. This works fine locally, but when tested from a browser, the localConnection idea doesn't seem to work. In other admin demo's, after the user saves the info, I just provide a link to the textfile to update the browser cache. When refreshing the browser, the content is updated. I would like to find a way to do this in a real time situation. Here is a link to a small tutorial I tried to write using this method. The source files are available on the second page. Why does this work so well locally but not in a web browser?

http://ntdesigns.net/tutorial/NewsManager.html (http://ntdesigns.net/tutorial/NewsManager.html)

Any suggestions appreciated.
Regards
NTD

Ordinathorreur
July 3rd, 2005, 06:48 AM
Cant you get by the caching by just requesting "yourtextfile.txt?someRandomNumber"

NTD
July 3rd, 2005, 08:29 AM
Hi,

That leaves the problem of having to refresh the browser to see the currently modified text. The idea is to populate the newsreader with the local connection method using the data that is saved to the textfile. The current user will see the update real time. Any users that open the page will load the textfile with the updated data. It seems to be a local connection issue more than a browser cache issue. If you test the .swf files locally, it works as desired. If I test them in a web browser, the local connection doesn't seem to work. I read a couple of posts that said the local connection method was only for two .swf files on a users computer, but I have seen it used to communicate with two .swf files embedded in the same HTML page, so it seems like this idea should work. Is there something I am missing about using this in an online environment?

Thanks for replying
NTD

Ordinathorreur
July 3rd, 2005, 08:57 AM
what i mean is that when you request the data file (whether you are displaying it in flash or elsewhere) appending a dummy variable to the end of the data file request should make it download the text file in it's entirety instead of cheking to see if the user has a local copy in their cache. Maybe I'm not quite understanding the problem properly. If you trying to display a real time news reader in Flash? then maybe the answer lies in using setInterval to refresh the textfile every say, 30 seconds or so, appending the dummy variable to make sure a cached version is not displayed? (p.s. you might want to pose this question in the server side scripting forum instead)

NTD
July 3rd, 2005, 10:53 AM
Hi,

I considered using setInterval to poll for the updated content. I am just curious why this method works locally. If you download the source files, with an internet connection.... you can open both swf files and the information is updated correctly with the local connection method. If I view the demos from the link in the tutorial, they open in a web browser and the info is written to the text file, but not updated in the movie. I tested putting both movies in the same HTML page and the same result occurs..... the info does not update like it does locally. This makes me think I am using the local connection method incorrectly. Is there something that needs to be added for online use? Since it is an unsupported method, there is nothing in the help files about it.

I prob should post to the backend and scripting forum but I dont want to cross post, so for now..... I'll see if I can frustrate myself a bit more.

Thanks for replying
NTD

40Unregistered
July 4th, 2005, 02:55 AM
LocalConnection only allows one movie to listen to any given channel at any one time.
if that is the problem, read guy watson's tip:
local connection tip (http://webdesign.templatemonster.com/web/flash/tutorials/local-connection-tip.1282.html)
i dunno how he do it exactly but u should try the tip

NTD
July 4th, 2005, 04:04 PM
Hi,

I have read and understand the tutorial from Guy.I have considered using this approach for a mini multiplayer game. However,In my project, I am only creating one channel between two movies and I can't even seem to get that to work online and I can't find much information on using the local connection method. Does anyone know if the local connection method is formated differently for online usage rather than local?

I still can't get this to work correctly online. Locally, it works great.
Regards
NTD