PDA

View Full Version : Simple LoadVars question of PHP



TheMagicMan
September 6th, 2007, 02:01 PM
I'm trying to extract the data(strings) out of PHP onto a dynamictextbox in Flash.

I don't know the correct syntax and also the understanding of using loadVars/


Can someone help me on this?


Thanks.

Digitalosophy
September 6th, 2007, 03:38 PM
http://www.flash-db.com/Tutorials/loading/

TheMagicMan
September 7th, 2007, 05:53 AM
Thank you for that link, but I'm still not able to output what I want.

This is the code I got from one of the tutorial Kirupa has.

Flash AS:
onClipEvent (load) {
loadVariables("http://localhost/test.php", this, "GET");
}

PHP:
<?php
$x = "abc";
print $x;
print "myVar=$x";
?>

I tried putting this in the movieclip of a dynamic text field. I put the code in there.
Nothing appears.

Is there something I'm missing?

Thank you.

Digitalosophy
September 7th, 2007, 09:45 AM
Yes load variables would just load the php script in the background. If you want to actually spawn that page you would use send(), although it doesn't look like you are passing any information over to the php.

TheMagicMan
September 7th, 2007, 11:11 AM
Do I need to pass the information to PHP?
I thought it was just retrieving the information from PHP to Flash?
I'm really confused.

Is the send() in the loadVars class?

Digitalosophy
September 7th, 2007, 12:21 PM
I'm sorry I thought you we're passing info to php.



myData = new LoadVars();
myData.onLoad = function(){
var myValue = this.myVar;
trace(myValue);
}


Should do the trick. Sorry for the confusion.

TheMagicMan
September 7th, 2007, 02:46 PM
Thanks.

I tried putting that into my movieclip-displaytext, but it still doesnt work.
I still have the onClipEvent code in there as well.

What should I do?

Sorry to keep asking.

TheMagicMan
September 10th, 2007, 10:35 PM
Am I suppose to have a mySQL database in between this to actually show the data in Flash?

Please help.

Thanks.

Digitalosophy
September 11th, 2007, 09:58 AM
^ no not unless you are trying to grab data from a database.

Could you host your php page on a web server other then your local pc? If so just post the url to do it and we can figure out what the problem in Flash is.

TheMagicMan
September 11th, 2007, 03:04 PM
http://projectbasic.net/abc.php

Thats the one I used. Is there something wrong on that?

Digitalosophy
September 11th, 2007, 03:49 PM
myData = new LoadVars();
myData.load("http://projectbasic.net/abc.php");
myData.onLoad = function() {
_root.displayText.text = this.abcmyVar;
}

TheMagicMan
September 11th, 2007, 10:40 PM
Thank you so much. :D

Digitalosophy
September 12th, 2007, 09:52 AM
No problem.