Welcome, Guest. Please login or register.
Did you miss your activation email?
02/08/12, 08:01
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  Need some help getting my data from MySQL and putting in arrays
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Need some help getting my data from MySQL and putting in arrays  (Read 3449 times)
CStrauss
Server what's that
*
Posts: 3


View Profile Email
« on: 10/18/08, 17:25 »

Hello, this is my first post here and finding lot of usuful information so far on this site, but before I get distracted with all that other stuff im having an issue trying to pull information from my database into flash.

I was using this code to pull information from an xml file looping through and storing the values in an array so I can use later.
Code:
// Arrays to hold all the picture data
var picturePathList:Array=[];
var thumbPathList:Array=[];
var pictureTitleList:Array=[];
var pictureDescList:Array=[];

function loadTheXML() {
var xmlURLLoader:URLLoader = new URLLoader();
var xmlURLRequest:URLRequest = new URLRequest( urlVar );
xmlURLLoader.load(xmlURLRequest);
xmlURLLoader.addEventListener( Event.COMPLETE , sortTheXML );

function sortTheXML(event:Event):void {
var theXMLData:XML = new XML(  xmlURLLoader.data );
var a:Number = theXMLData.picture_path.length();
totalPics = a;
var b:Number = 0;
// Loop to load the data into array
while (b < a) {
picturePathList.push( theXMLData.picture_path[ b ]);
thumbPathList.push( theXMLData.thumb_path[ b ]);
pictureTitleList.push( theXMLData.picture_title[ b ]);
pictureDescList.push( theXMLData.picture_desc[ b ]);
b = b + 1;
}// end while loop


How can I do the same but with a database I figure the code cant be to different. Im using PHP to get my data and put in a name/value set. Reason I want to know if there is a similar way to write the code for getting my data from database is cause I'm still learning AS3 stuff and the XML code above i have decent understanding and if i can dupilcated it for a database it would keep me from getting to confused. Any Help anyone can provide I will be greatful.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6162


View Profile WWW Email
« Reply #1 on: 10/19/08, 00:58 »

Hi CStrauss, and welcome to the boards.

If you pull the data from a database, you allready get it into an array by reading it in:
Code:
mysql_fetch_array($rs,MYSQL_ASSOC);

See php manual for more details.
Logged

happy flashing
Cool
Ronald
CStrauss
Server what's that
*
Posts: 3


View Profile Email
« Reply #2 on: 10/19/08, 08:24 »

yeah i know that, the php part isnt the problem its the AS3 im trying to figure out. is there special objects for working with in AS3 like XML has an XML object and so on.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6162


View Profile WWW Email
« Reply #3 on: 10/19/08, 09:36 »

If you seriously want to move large chunks of structured data, you should be looking into remoting with AMFPHP and exchange of VOs (valued objects).
Logged

happy flashing
Cool
Ronald
CStrauss
Server what's that
*
Posts: 3


View Profile Email
« Reply #4 on: 10/19/08, 12:53 »

Probably so, but wouldn't you think it be best to learn the AS3 scripting language first with in the flash IDE before moving to outside stuff? You wouldn't build a building from the top down would you?
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6162


View Profile WWW Email
« Reply #5 on: 10/20/08, 03:07 »

This is not the case.
If you want to do something easy, you have to start with an easy project.
Why building somathing at the client side, what you can receive from the server Wink

Sure, you can read numbered fields, but then I would prefer XML for transport - so we are back to the beginning.
Logged

happy flashing
Cool
Ronald
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything