Shoutbox: here i am again

well, after hours of work, i realized how it could work (i had the problem of not updating the messages, caused by loading them directly from the text-doc and not from the php-script). I now know how to load the variables from a php-script, but the flash-movie still shows the old messages.

whooo, im wild. :crazy: :q: :bounce:

Sounds like a cache problem. Try this to prevent that…

http://www.kirupa.com/developer/actionscript/tricks/cache.asp

so if i want to load variables from a phpscript called view.php, it would have to look like this?


myIdentifier=Math.round(Math.random()*10000);
loadVariablesNum("view.php"+myIdentifier,1,"GET");

btw, thanks for that quick answer :love: :wink:

[edit] that doesnt work, the script sends “_level0.text”, what is displayed in the shoutbox.

No, you are a tad off, you left off the query string identifier…

myIdentifier=Math.round(Math.random()*10000);
loadVariablesNum("view.php?uniq="+myIdentifier,1,"GET");

I added ?uniq= at the end of view.php like it shows in the tutorial.

i do not understand that. dont know why i should add

“?unique=”

ive got no variable called unique in my phpscript. im sorry for my beeing so dumb… :chinaman:

It is a query string variable. You don’t need it in your PHP script.

It basically just confuses your browser into thinking that the file loading is a completely different file than before because it chooses a random number to tack onto the end of that query string.

This makes your browser cache that file and next time it loads it thinks it is a different file and will not load the cached version, but instead will show the new version.

aha… i see

:slight_smile: I hope that was the problem. Because if not, I have no clue what else to try.

There are also other ways of preventing cache of files.

Macromedia say:

http://www.macromedia.com/support/flash/ts/documents/prevent_caching.htm

Lost:

I actually have to disagree about the way used in the trick, when your using Math.Random and Math.Round, there is a 1% possiblity or even more to get the same number again. However, as time always goes forward, i recommend going with this way:

myIdentifier=new Date().getTime()
myLoadVars = new LoadVars();
myLoadVars.variablewhatever = “something goes here”;
myLoadVars.send(“view.php?random=”+myIdentifier, this,“GET”);

heres the code of my view.php:



<?php
$filename = "shoutupdate.txt";
$fp = fopen($filename,"r");
$savedtext = fread($fp, 80000); 
fclose($fp);

print "text=$savedtext";
?>


in the flashmovie in the first frame i load the variables, a textbox with the variable text displays what the people wrote…

*Originally posted by h88 *
**Lost:

I actually have to disagree about the way used in the trick, when your using Math.Random and Math.Round, there is a 1% possiblity or even more to get the same number again. **

True for a shoutbox. It wouldn’t be good to get the same number, but for just a standard site I don’t think that would be a problem. Given people would usually clean their temp files before the chance of getting the same number if you ask me.

thanks h88, it works now, but i now use 2 similar scripts, so the movie cant save the variables when they are loaded from a different script then before…

heres the shoutbox, its not ready yet:

http://195.230.176.35/flashexp/shoutbox/gb/shoutbox0r.swf

thanks guys…

Congrats!

the only problem is that i “reload” the swf. now i do not know, if i load the swf with LoadMovie, is that possible?

its something like that:

when the user presses “post”, the swf sends the variables to the php-script. then theres a “GetURL”, which points to the swf itself. could that cause problems?.

could you post the FLA so I could take a look at how it is set up?

shure…
but it’s built quite complicated because of my cache problem…
i tried to solve it by loading the variables from 2 different scripts…

btw, you should actually allow the file extension .rar for attachments… the rar would take 24 kb, the zip takes 38 kb…

and one more thing…

do NOT copy my design… :wink:

Didn’t you get the open source files from me in the first place? Why would I copy your design? lol :stuck_out_tongue: I’ll take a look at it. I’ll let you know what i find.

Don’t do the getURL to reload the SWF. That is not necessary. You only need to load the varaibles. Reloading the SWF is the same as pointing it to the first frame. And try using LoadVars instead of loadVariableNum…If you need my file again its here:

http://www.kirupaforum.com/showthread.php?s=&threadid=12463&highlight=PHP

well, i used your php-files, modiefied them…
and anyone can copy my design :beam:

the problem is, when i do not reload the movie, the php script sends the old text, and not the one with the text the user just added…

it doesnt work

:frowning:

i now post the whole shoutbox (swf + phpfiles + data file)

plz help me, im almost dead… i cant solve this cache problem…