Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

my post clip doesn't grab latest post until refresh or next post

Status
Not open for further replies.

iostream71

Programmer
Mar 13, 2002
229
US
ok, i have a movie that has a posting feature

problem is, when i submit a post, SOMETIMES the clip that handles the posting reads in the text before it has been written to the text file, resulting in the post not being shown when the text is reloaded. it will show if the browser is refreshed, or a new post is submitted afterwards

basically, i'm just loading a text file at the start of the clip and if a post is submitted, i go back and load the text file again

hope that makes sense....any ideas?
 
Are you using the "onCLipEvent(data)" handler to load your text? If the textfield is "refreshed" before new contents have had time to load it will display the old contents again - the best way to stop this happening is to use "onClipEvent(data)", which will execute any following script ONLY when new data has been received.

If you want I can send you a small sample FLA - post your email if your interested.
 
no, i wasn't using any kind of data event. basically, on frame 1 i loaded the text file. then, if a post was made, i went to frame 1 again and reloaded the file.

thing this is, i had a loop set up so that if the file wasn't loaded, it would go back to a certain frame and loop until the
file was loaded. is that not the same thing you're talking about?


iostreamx@hotmail.com
 
No, the onClipEvent(data) handler is dedicated to situations where data is known to be loading into a movieClip's timeline. It's event is triggered when the data import has stopped (i.e. when the whole file is loaded), and is therefore a REALLY easy way of making sure things happen the way they should.

I was going to start explaining it all, but the easiest way would be to send you a FLA and let you see for yourself. It's worth having a look at. Post your email and I'll send one over.
 
ok, i tried the onclipevent and it still doesn't work right. the problem is that it's reading the file BEFORE the php script is writing to the file. the only way it works right is if i put a long pause before i read the file

i don't see how the onclipevent can prevent reading too early. how can i ensure the file has been written to before it gets read?

test it here:
 
Good question. I see what you mean now ... there must be a way of telling if the file exists. I have an idea for a post management TXT file which could solve the problem, but its a bit complicated. Let me know if you're interested.
 
Can't you have some check that the file has been written to, before sending your movie to frame 1, and reading the file again? I don't know the first thing about side scripting, but seems to me that that should be possible. Worst case, can't you just add a so many seconds timer event (with an updating message of some sort!), that would delay the new reading of the file while it's being updated? Regards,

new.gif
 
yeap, i did that already, but it just looks kinda sloppy. i had a 2 second loop, but wanted to get rid of it

i was thinking of some sort of file locking via the php script, maybe?
 
what's your idea rgstewart? lay it on me, i'll try anything at this point lol
 
I just thought about it some more, and it's not likely to work. I keep getting ideas, but the bottom line is there must be some way of PHP being able to tell Flash when the file has been written.
 
thanks for the help anyways. i'll poke around in php and surely something will work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top