Welcome, Guest
  • Author Topic: Need some help getting my data from MySQL and putting in arrays  (Read 3876 times)

    CStrauss

    • Server what's that
    • *
    • Posts: 3
      • View Profile
      • Email
    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: [Select]
    // 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.

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    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: [Select]
    mysql_fetch_array($rs,MYSQL_ASSOC);

    See php manual for more details.
    happy flashing
    8)
    Ronald

    CStrauss

    • Server what's that
    • *
    • Posts: 3
      • View Profile
      • Email
    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.

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    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).
    happy flashing
    8)
    Ronald

    CStrauss

    • Server what's that
    • *
    • Posts: 3
      • View Profile
      • Email
    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?

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    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 ;)

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