-
Load MySQL query into swf
Greetings all,
Hoping someone can help with my probem.
I have data being loaded into MySQL database from my swf and I am attempting to read back specific data which will be used to determine if a button object will be active or not, basically forcing users to complete an item before they can do another.
Anyway, my code is below:
PHP is providing the following results from my query via print:
"userid","M01","M02","M03","M04","M05" "1234","1","0","0","0","0"
the items above are from each field in the table where i look for a specific user and the value of each field. The field M01 reflects a value of 1 in the sample above.
What I am trying to do is read this back into my parent swf to check the value of M01 and if it equals 1 then a button will be active so the user can do the next assignment. If it !=1 then button remains disabled.
I have attempted to load the M01 value into a text field just to see if it is working, but no luck so far as shown below:
My basic loader is:
Code:
Code:
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener (Event.COMPLETE, dataOnLoad);
function onDataLoad (evt:Event)
{
_idTxt.text = evt.target.data['M01'];
}
Any guidance / assistance will be greatly appreciated.
Thanks in advance!
-
Senior Member
You could change the string in the php file to an array like this:
PHP Code:
<?php
$output = '"userid","M01","M02","M03","M04","M05","1234","1","0","0","0","0"'; $words = explode(',', $output); echo $words[0]."<br/>";//"userid" echo $words[1]."<br/>";//"M01" echo $words[2];
?>
and then pass an array to flash.
I forgot to mention that the php-array is not an array in flash. Using amfphp is one possibility. Alternatively you can just create an xml file in php by iterating the array and then passing xml to flash.
Last edited by cancerinform; 12-13-2012 at 10:04 PM.
- The right of the People to create Flash movies shall not be infringed. -
-
If possible, you should definitely use AMFPHP. You could / should also map classes and work with typed objects on each side ( link: http://www.silexlabs.org/amfphp/docu...typed-objects/ )... or you can of course go down the XML road and then parse the received XML structure each time on the client-side.
-
Thanks for the info
Thank you both for your input.
I will post my results here.
Cheers!
-
Senior Member
If you don't want to use amfphp here are some scripts:
http://www.flashscript.biz/php/strin...ngtoarray.html
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|