Ok I solve one issue then counter a new one… This might be the wrong place to post this but hey maybe someone knows…
Im trying to have PHP send flash variables…
<?
print “working=1”;
?>
A very simpel script… But here is the deal…
It’s an external SWF that makes this call, and that external SWF makes the call from a button within a movieclip (animated button), but PHP should send the variable to a different movieclip in the same external SWF. That movie clip is looping checking for response from the PHP script and then redirecting that to the main stage to change frame.
Im assuming the PHP script should be like this.
<?
print “_root.test1.test2.working=1”;
?>
test1: the movieclip the external SWF is in.
test2: the movieclip where the PHP response check is done.
I’m assuming I do not need to set the variable just use it.
(1) methodology: hard coding a static target (ie. _root.whatever.whatever.target) in an external file is a waste of time, if things change, you add another holder level or use the script again, you’re doubling the amount of time it takes to change/update things and/or doubling the number of external files you need to call, better to simply echo a simple variable ( echo ‘&working=’.$PHPprocessedVariable; ) that way you can call it mutiple times and it doesn’t matter what level the info is sent too.
(2) PHP (that I know of) can’t send a variable to a different movie clip, infact it’s impossible. What PHP does, is reply to flash and flash determines who requested (ie what MC at what level) the info. if you want two SWF or MC to share the same info, call the PHP from their common parent and set a variable to be WATCHED.
When the file is finally loaded the watcher will tell which MC to do what. this saves processing power and avoids having to loop an MC that might not have to be run at all .
(3) As for a button calling PHP this works, but I recommend that the button call a function on your parent timeline that both MC’s branch off from. This function would execute all the sendAndLoad info, creating the common variables that you’ll need farther down the line…
I know PHP replies to whoever sent the request, but from what I read you can specify otherwise…
Im only dealing with one SWF file with the PHP, it’s just an external one. The main SWF file has nothing to do with these calls. So when PHP replies it replies to the same SWF file that requested PHP.
All I want it to do is request from one movie clip, process the reply in another.
Both movie clip in the same SWF file…
Might have explained myself incorrectly before, or the answer will be the same aswell…
external SWF are basically MC that aren’t exported at runtime, so it doesn’t matter if they’re external of imbedded MCs. look into WATCHERS (very handy built-in function) and use a function in the <relative> root of your external SWF to call the PHP script.
Flash sees external SWF as external from the main swf… But how does PHP see it, I would assume it treats the calling SWF as a single SWF and not an external or main. Is that correct??
think of an external swf like a TV channel. The TV is the main SWF you run <say from in your index.html> and each channel is loaded as per the users requests, PHP sees it just the same way as any viewer, it’s the TV showing the content and deciding when to switch channels (say based on a preset recording time or the push of a button on the remote control). Everything is contained within the same box, there’s no second TV just mutiple channels. So you’re right PHP responds to the MAIN timeline (or TV to keep the analogy) regardless of which TV channel asked for the info.
When I pass my information from flash to PHP from an external SWF, PHP returns it to the main SWF??
If that is the case, then I could assing a global variable, which I then could pick up inn my external SWF. Basicly let the main SWF handle listening for the reply??
my PHP reply is: print “&_root.loaded=1”;
is that send to my main SWF, or the external one that made the call?
I have checked the PHP script that works fine, so all I need to do is make flash pick up the reply and im set…
Wooow I was messing around, and now it’s working… Changed the way I listen for PHP reply from my external SWF and altered the reply to print “loaded=1”;
if you have mutiple variables always include the ‘&’ to seperate them. it’s good practice, even with only one variable to include it so print or echo ‘&variableName=’.$PHPvariable