Forum Moderators: coopster

Message Too Old, No Replies

Run Script from flash

for flash users out there

         

WhosAWhata

12:11 am on May 28, 2004 (gmt 0)

10+ Year Member


i have a PHP script that i want run every time myFlashFile.swf is run, i don't need it to pass any variables or anything like that, i just need it to run (it updates some files)

i know this is more of an ActionScript question than a PHP question, but this is the closest forum on this site that know of.

the PHP script is at
http://site.com/streams/update.php

How do I do this?

jatar_k

5:57 am on May 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if it has no output why not just include it on the page that has the flash embedded?

Or is it called directly?

haryanto

10:40 am on May 28, 2004 (gmt 0)

10+ Year Member



Or you can use the get var function to run it.
Pretty simple.

WhosAWhata

11:08 pm on May 28, 2004 (gmt 0)

10+ Year Member



its actually going to be called directly (site.com/file.swf)

and downloaded (in .exe form)

how do i use the get var function? i know almost nothing about actionscript...

httpwebwitch

3:20 pm on May 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One nice way is to use LoadVariables() in your Flash actionscript instead of GetURL(). It requests the URL and executes a script, but doesn't actually load it into the browser. This method is good if you are attaching a server action to a Flash button or a frame event.

In Flash:

frame 1:
done=false;

frame 2:
LoadVariables("mysite.com/mypage.php");

frame 3:
if (!done){
gotoAndPlay(_currentframe-1);
}

Then in your PHP script "mypage.php":
1) do all your hidden stuff,
2) echo "done=true"

This example makes your Flash wait in a loop until the server has finished its tasks.
Experiment with that technique, and I'm sure you'll find some way to accomplish your goal.
good luck!

WhosAWhata

4:24 pm on May 29, 2004 (gmt 0)

10+ Year Member



i need it all on the same frame...
would something like this work?

var done = false;
while(!done){
LoadVariables("mysite.com/mypage.php");
}
// the rest of my page

i'm not at a computer with flah at the moment...would this work?

WhosAWhata

4:19 am on May 30, 2004 (gmt 0)

10+ Year Member



this doesn't work...
any ideas?

httpwebwitch

6:02 pm on May 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The Actionscript command that does the work is
LoadVariables();

You'll need to look up the proper syntax, here:
h**p://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary425.html

The other frames in my example are only necessary if you want Flash to loop until the data is loaded (i.e. if subsequent frames need the returned data). If you are not passing any data into Flash, then just use the one command LoadVariables().

That method works when the SWF is embedded on a page, shown with the browser plugin. It just takes some tinkering to get everything connected right.

FYI - the EXE projector does not have all the capabilities that the browser plugin has, especially requesting and loading URLs. You might need to experiment with a Flash wrapper like SWF Studio (from Northcode).