Topic: loadVars problem (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21495" title="Pages that link to Topic: loadVars problem (Page 1 of 1)" rel="nofollow" >Topic: loadVars problem <span class="small">(Page 1 of 1)</span>\

 
norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 04-22-2004 08:04

I can display stuff from my database by creating a new loadVars object and then using load(), but when I try to send some variables to my PHP script like this:

code:
on (release) {
theData=new loadVars();
theData.message="hello there";
theData.sendAndLoad("http://127.0.0.1/flash/create.php",this,"POST");

}



nothing shows up in the data base. I know my PHP code is right because if i hardcode a value to replace $_POST['message'] it populates the database.

I can pass variables into the script with getURL() or send() or even loadVariablesNum(), but these involve a browser window and I'm tring to do this without a browser.

Anyone see where I'm messing up in my loadVars() code? Please.......

Cameron
Bipolar (III) Inmate

From: Brisbane
Insane since: Jan 2003

posted posted 04-29-2004 01:16

AFAIK, you need to run this from a browser running on the server for it to work correctly. Running this from the flash environment preview causes all sorts of issues with database stuff, probably because the PHP page thinks the request is comming from an external source and thus won't accept any POST data due to security issues.

When working with Database/PHP stuff and flash I always have the flash file (fla) located on the development server and when I make a change I re-comple the flash swf then refresh the browser window that's displaying the page through the server.

It's a complete pain in the ass to wrok like that thought -- somehting I've been tyring to find better solutions to for a while now. At the moment, the best I've found is a combination of EditPlus and a program called Flush. Flush can compile flash files into swf files from editplus shortcut keys, and editplus (my favourite text editor) can preview HTML/PHP pages through your local server. I usually have my actionscript files referenced to an external source which I also edit in editplus because I find the flash environment too cramped for coding. This makes testing and development much more streamlines (espicaly with a simple compile->preview macro), but it's still a bit of a pain.

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 04-29-2004 02:58

I don't think you can specify "this" (meaning _root) as the target parameter. I think you need to declare a loadVars object to catch the return.

code:
on (release) {
sendData=new loadVars();
catchData = new loadVars();
sendData.message="hello there";
sendData.sendAndLoad("http://127.0.0.1/flash/create.php",catchData,"POST");
}



I don't know how you have structured the variable coming back, but you would extract it as an element in the catchData object's array. Let's say it is also "message". You might define a callback function:

code:
catchData.onLoad = function() {
trace(catchData.message);
}



Lemme know if this works. I think that's your problem, not some thing in the development environment.

Oh - make sure you define the callback before you perform the sendAndLoad() method. Don't want data arriving before Flash knows what to do with it. Though seeing as how this is in response to a mouse click I guess there's not much chance of that happening.


(Edited by Steve on 04-28-2004 19:09)

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 04-29-2004 04:20

Rereading your post, I guess the problem is different from what I thought at first. You aren't trying to get something back are you, just populating a database.

Okay. under loadVars.send() - NOT sendAndLoad() - Moock lists the values for the target argument as "_blank", "_parent", "_self" or "_top" - in other words, references to browser windows the return (if any) from the script should be displayed in. He also notes that in Flash Player 6 if there is no target (or in your case the wrong target) the script may not execute. I don't know if you script sends something back or not, but you might try replacing "this" with "_blank" and see if that helps.

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 04-29-2004 04:51

Cameron:

I'm working right out of a directory on my local apache webserver, the same way I develop PHP applications. It's quite handy to have Apache and MySQL set up on my development box, I've been quite spoiled by working this way for the last couple of years.

Sometimes it presents problems when my development environment doesn't exactly mirror the production set up, but still...........

Steve:

I have used both loadVars.send and getURL() with success, but I don't want to be stuck having to use a browser. So what I'm trying to do is use sendAndLoad to send the variables to the database then echo back a variable to Flash which I will promptly ignore.

I have tried using both the name of my newly created loadVars theData and 'this' to catch the return variable with the same lack of results. I'll give the trace() a try, thanks.

(Edited by norm on 04-28-2004 20:16)

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 04-29-2004 05:52

"I'll give the trace() a try, thanks."

Trace is just a means to verify you got something. A second loadVars object designated as the target was what I was trying to suggest might be needed for sendAndLoad to work properly.

Another thought - have you tried substituting "GET" for "POST"?

I seem to recall reading that there were some problems in some cases using POST with the standalone player. If you're not using a browser, this might be something to investigate.

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 04-29-2004 16:28

LOL..... You mean I can't use Flashes built-in trace() function? I feel a bit foolish now, thanks for setting me straight.

I'll be sure and set an onLoad and then I'll try the GET substitution.

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 05-01-2004 16:15

So......????

Did it work? Let me know so I can tuck in away in the "might need someday" bin.

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 05-03-2004 19:36

Adding the onLoad didn't do the trick and I haven't had time to try GET yet. So many projects, so little time......

I'll try to get this worked out in the next couple of evenings and I'll keep you informed.

thnx,
Norm

/* I wonder....Does Fuzzy Logic tickle? */

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 05-18-2004 03:39

You can make some hidden forms on your php page that is holding your flash movie.

I'm actually not familiar with how flash handles php.. but I know it can interact with javascript. You can set up any kind of form to take your values (hidden forms of course), and use fscommand to run some simple javascript functions, ie:

code:
myButtonName.click();

and then...

fsommand( myButtonName.click() );


Click is a javascript function that simulates a button click. In php, submitting data makes the page refresh, so I imagine you could make frames...

Yes, I'm overcomplicating, but this is totally feasible.

Shine and shine. :: [old cell]



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu