PDA

View Full Version : shoutbox: here i am again



fishtank
February 2nd, 2003, 01:12 PM
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:

lostinbeta
February 2nd, 2003, 02:00 PM
Sounds like a cache problem. Try this to prevent that....

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

fishtank
February 2nd, 2003, 02:10 PM
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: ;)


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

lostinbeta
February 2nd, 2003, 02:13 PM
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.

fishtank
February 2nd, 2003, 02:18 PM
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:

lostinbeta
February 2nd, 2003, 02:19 PM
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.

fishtank
February 2nd, 2003, 02:24 PM
aha... i see

lostinbeta
February 2nd, 2003, 02:33 PM
:) 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

h88
February 2nd, 2003, 03:42 PM
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");

fishtank
February 2nd, 2003, 04:01 PM
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...

lostinbeta
February 2nd, 2003, 06:25 PM
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.

fishtank
February 3rd, 2003, 04:10 AM
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...

lostinbeta
February 3rd, 2003, 04:13 AM
Congrats!

fishtank
February 3rd, 2003, 01:54 PM
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?.

Jubba
February 3rd, 2003, 01:57 PM
could you post the FLA so I could take a look at how it is set up?

fishtank
February 3rd, 2003, 02:02 PM
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.... ;)

Jubba
February 3rd, 2003, 02:41 PM
Didn't you get the open source files from me in the first place? Why would I copy your design? lol :P I'll take a look at it. I'll let you know what i find.

Jubba
February 3rd, 2003, 02:49 PM
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

fishtank
February 3rd, 2003, 03:42 PM
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...

fishtank
February 3rd, 2003, 04:08 PM
it doesnt work

:(

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

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

Jubba
February 3rd, 2003, 05:21 PM
AHHH DAMMIT!! I had the entire response typed out and then, like a moron I closed the window. Oh well here we go again. It works on my machine. I am going to attach the files.

http://www.livetoskateboard.com/test/FTsb/shoutbox0r.swf

Flash File:



//------- Frame 1
loadVariablesNum("viewtext.php", 0, "GET");
gotoAndPlay(3);

//------- Frame 2
dataLoader = new LoadVars();
stop();


//------- Frame 3
loadVariablesNum("viewtext.php", 0, "GET");
stop();

//------- "Kick It!" Button
on (release) {
_root.dataLoader.nName = _root.nName;
_root.dataLoader.nEmail = _root.nEmail;
_root.dataLoader.nMess = _root.nMess;
_root.dataLoader.send("shout.php", _root.dataLoader, "POST");
gotoAndPlay(3);
}





Shout.php:


<?
//-----------------------------
//FileName: shout.php
//-----------------------------
$nName = $_POST['nName'];
$nEmail = $_POST['nEmail'];
$nMess = $_POST['nMess'];

$nName = ereg_replace("&", "and", $nName);
$nEmail = ereg_replace("&", "and", $nEmail);
$nMess = ereg_replace("&", "and", $nMess);

$nName = stripslashes($nName);
$nEmail = stripslashes($nEmail);
$nMess = stripslashes($nMess);

$filename = "shout.txt";
$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose($fp);

$Input = "$nName<br>$nMess<br><u>Website: $nEmail</u><br><br>";

$New = "$Input$OldData";

$fp = fopen( $filename,"w");
fwrite($fp, $New);
fclose($fp);

echo "<script language=\"JavaScript\">\n";
echo "self.close()";
echo "</script>";

?>


viewtext.php:


<?
//---------------------------------
//FileName: viewtext.php
//----------------------------------
$filename = "shout.txt";
$fp = fopen($filename,"r");
$savedtext = fread($fp, 80000);
fclose($fp);

print "text=$savedtext";

?>


Now if this doesn't work then try to use the unique Identifier like LostInBeta ( :flower: ) originally suggested and it should work just fine.

Cheers,
Jubs :crazy:

fishtank
February 3rd, 2003, 06:04 PM
hm, the prob is, that when i sign it, a new browser window opens. iexplorer asks me if i allow this site to close the window. i changed your php script to prevent that new window... thanks man , but any idea how to solve that without opening a new window?

Jubba
February 3rd, 2003, 06:13 PM
Nope. I can't change it. I can't make the script work without the window opening...

Jubba
February 3rd, 2003, 06:51 PM
Don't know if this will work or not. I'm not at my computer anymore. Try changing the code on the "kick it" button. Change where it says "POST" to "GET" I doubt this will work tho. You could try to post on www.tutorialforums.com and ask hem. They have some really smart people over there...

Sorry man...

fishtank
February 4th, 2003, 01:37 PM
another problem: when i load a movie which loads vars from a php-script into a mc, why doesnt that work? i mean, ive tried it, and the variables arent loaded.