A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: LoadVars Problem

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    18

    LoadVars Problem

    If anyone can help I have been pulling my hair out for hours trying to load some variables I gather from a php output file into variables in the first frame of my movie in CS3.



    My Code for Loading the Variables in AS3 is this

    Code:
    var lv = new LoadVars();
    lv.load("http://localhost/Blink/BlinkItemsArr.php");
    
    lv.onLoad  =  function()  { 
    var packcount:Number = this.packrows;
    var syscount :Number= this.sysrows;
    var acccount:Number = this.accrows;
    
    for(var i:Number=0; i < packcount; i++){
     itemspackagelist[i] =  this.packarr.i.split("|");	
     trace( itemspackagelist[i]);
    }
    
    for(var o:Number=0; o < syscount; o++){
     itemssystemlist[o] =  this.sysarr.o.split("|");	
      trace( itemssystemlist[o]);
    }
    
    for(var p:Number=0; p < acccount; p++){
     itemsaddonslist[p] =  this.accarr.p.split("|");
      trace( itemsaddonslist[p]);
    }}

    The error output I get is this:

    Code:
    1180 Call to possibly Undefined method LoadVars        var lv = new LoadVars();
    I have searched high and low tried other methods I have found although the one listed here seems to be most common but I can't get this to work.

    The goal as you can see is to load the Variables into a set of Multidimensional Arrays that I can later traverse.


    My Php file: outputs this:

    Code:
    &packarr0=1|Soho Package|1|100.00|0.00|1|0|0.00|1|0|spa941small(1).jpg|$100/month - 3-5 users - includes tollfree, mainline, fax line, cell callback, conference calling and more&packarr1=2|StudioLoft Package|1|150.00|0.00|1|0|0.00|1|0|spa941small(2).jpg|$150/month - 6-20 users - includes tollfree, mainline, fax line, cell callback, conference calling and more&sysarr0=3|Main Lines|2|40.00|0.00|1|0|0.00|1|0|spa901small(1).jpg|$40/month - unlimited northamerica - incoming / 2000 outgoing minutes/3 cents per minute additional&sysarr1=4|Extensions|2|15.00|0.00|1|0|0.00|1|0|spa901small(2).jpg|$15/month - shared pool of minutes&sysarr2=5|Fax Lines|2|15.00|0.00|1|0|0.00|1|0|spa901small(3).jpg|$15 - send/recieve upto 200 pages faxes&sysarr3=6|Toll Free Lines|2|10.00|0.00|1|0|0.00|1|0|spa901small(4).jpg|$10/month - 6 cents per minute&sysarr4=7|Extra Lines|2|10.00|0.00|1|0|0.00|1|0|spa901small(5).jpg|$10/month - US or Canada&accarr0=8|Linksys SPA-841 Office Phone|3|15.00|150.00|1|5|25.00|1|1|spa941small.jpg|$150 each or $15/month to purchase (5+phones $125 each)&accarr1=9|Linksys SPA-841 Simple Phone|3|9.00|75.00|1|0|0.00|1|1|spa901small(6).jpg|$75 or $9/month to purchase (5+phones $125 each)&accarr2=10|HT-286 ATA Modem Adapter|3|5.00|50.00|1|5|10.00|1|1|adaptersmall(1).jpg|$50 or $5/month to purchase (5+phones $40 each)&packrows=2&sysrows=5&accrows=3&errormsg=
    I am lost so any help would be greatly appreciated!
    Last edited by PeterPiper22; 08-20-2008 at 12:42 PM.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Throw out that code. It's all AS2.

    LoadVars doesn't exist in AS3. Instead, use a URLLoader with a data format of URLLoaderDataFormat.VARIABLES. Use the livedocs to find out the methods and properties of URLLoader.
    http://livedocs.adobe.com/flash/9.0/...riptLangRefV3/

    The very first example in the docs for URLLoader should get you most of the way there.

  3. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    18
    ok on your advice I read live docs as well retried ideas based upon tutorials I found googling but I am still pulling my hair out.

    I rewrote my php side to put my ooutput into a series of arraqys that I then use the http_build_query function to format them for output in name value pairs for flash to receive. heres sample output:

    Code:
    packarr0=1%7CSoho+Package%7C1%7C100.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa941small%281%29.jpg%7C%24100%2Fmonth+-+3-5+users+-+includes+tollfree%2C+mainline%2C+fax+line%2C+cell+callback%2C+conference+calling+and+morepackarr0=1%7CSoho+Package%7C1%7C100.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa941small%281%29.jpg%7C%24100%2Fmonth+-+3-5+users+-+includes+tollfree%2C+mainline%2C+fax+line%2C+cell+callback%2C+conference+calling+and+more&packarr1=2%7CStudioLoft+Package%7C1%7C150.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa941small%282%29.jpg%7C%24150%2Fmonth+-+6-20+users+-+includes+tollfree%2C+mainline%2C+fax+line%2C+cell+callback%2C+conference+calling+and+moresysarr0=3%7CMain+Lines%7C2%7C40.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%281%29.jpg%7C%2440%2Fmonth+-+unlimited+northamerica+-+incoming+%2F+2000+outgoing+minutes%2F3+cents+per+minute+additionalsysarr0=3%7CMain+Lines%7C2%7C40.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%281%29.jpg%7C%2440%2Fmonth+-+unlimited+northamerica+-+incoming+%2F+2000+outgoing+minutes%2F3+cents+per+minute+additional&sysarr1=4%7CExtensions%7C2%7C15.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%282%29.jpg%7C%2415%2Fmonth+-+shared+pool+of+minutessysarr0=3%7CMain+Lines%7C2%7C40.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%281%29.jpg%7C%2440%2Fmonth+-+unlimited+northamerica+-+incoming+%2F+2000+outgoing+minutes%2F3+cents+per+minute+additional&sysarr1=4%7CExtensions%7C2%7C15.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%282%29.jpg%7C%2415%2Fmonth+-+shared+pool+of+minutes&sysarr2=5%7CFax+Lines%7C2%7C15.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%283%29.jpg%7C%2415+-+send%2Frecieve+upto+200+pages+faxessysarr0=3%7CMain+Lines%7C2%7C40.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%281%29.jpg%7C%2440%2Fmonth+-+unlimited+northamerica+-+incoming+%2F+2000+outgoing+minutes%2F3+cents+per+minute+additional&sysarr1=4%7CExtensions%7C2%7C15.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%282%29.jpg%7C%2415%2Fmonth+-+shared+pool+of+minutes&sysarr2=5%7CFax+Lines%7C2%7C15.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%283%29.jpg%7C%2415+-+send%2Frecieve+upto+200+pages+faxes&sysarr3=6%7CToll+Free+Lines%7C2%7C10.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%284%29.jpg%7C%2410%2Fmonth+-+6+cents+per+minutesysarr0=3%7CMain+Lines%7C2%7C40.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%281%29.jpg%7C%2440%2Fmonth+-+unlimited+northamerica+-+incoming+%2F+2000+outgoing+minutes%2F3+cents+per+minute+additional&sysarr1=4%7CExtensions%7C2%7C15.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%282%29.jpg%7C%2415%2Fmonth+-+shared+pool+of+minutes&sysarr2=5%7CFax+Lines%7C2%7C15.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%283%29.jpg%7C%2415+-+send%2Frecieve+upto+200+pages+faxes&sysarr3=6%7CToll+Free+Lines%7C2%7C10.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%284%29.jpg%7C%2410%2Fmonth+-+6+cents+per+minute&sysarr4=7%7CExtra+Lines%7C2%7C10.00%7C0.00%7C1%7C0%7C0.00%7C1%7C0%7Cspa901small%285%29.jpg%7C%2410%2Fmonth+-+US+or+Canadaaccarr0=8%7CLinksys+SPA-841+Office+Phone%7C3%7C15.00%7C150.00%7C1%7C5%7C25.00%7C1%7C1%7Cspa941small.jpg%7C%24150+each+or+%2415%2Fmonth+to+purchase+%285%2Bphones+%24125+each%29accarr0=8%7CLinksys+SPA-841+Office+Phone%7C3%7C15.00%7C150.00%7C1%7C5%7C25.00%7C1%7C1%7Cspa941small.jpg%7C%24150+each+or+%2415%2Fmonth+to+purchase+%285%2Bphones+%24125+each%29&accarr1=9%7CLinksys+SPA-841+Simple+Phone%7C3%7C9.00%7C75.00%7C1%7C0%7C0.00%7C1%7C1%7Cspa901small%286%29.jpg%7C%2475+or+%249%2Fmonth+to+purchase+%285%2Bphones+%24125+each%29accarr0=8%7CLinksys+SPA-841+Office+Phone%7C3%7C15.00%7C150.00%7C1%7C5%7C25.00%7C1%7C1%7Cspa941small.jpg%7C%24150+each+or+%2415%2Fmonth+to+purchase+%285%2Bphones+%24125+each%29&accarr1=9%7CLinksys+SPA-841+Simple+Phone%7C3%7C9.00%7C75.00%7C1%7C0%7C0.00%7C1%7C1%7Cspa901small%286%29.jpg%7C%2475+or+%249%2Fmonth+to+purchase+%285%2Bphones+%24125+each%29&accarr2=10%7CHT-286+ATA+Modem+Adapter%7C3%7C5.00%7C50.00%7C1%7C5%7C10.00%7C1%7C1%7Cadaptersmall%281%29.jpg%7C%2450+or+%245%2Fmonth+to+purchase+%285%2Bphones+%2440+each%29packrows=2&sysrows=5&accrows=3errormsg=
    now in flash I have this:
    Code:
    var request:URLRequest = new URLRequest("http://localhost/Blink/BlinkItemsArr.php");
    request.method = URLRequestMethod.GET;
    
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, completeHandler);
    loader.load(request);
    
    
    function completeHandler(evt:Event)  { 
    
     var packarr = evt.target.data.packarr0;
     var sysarr = evt.target.data.sysarr0;
     var accarr = evt.target.data.accarr0;
    	
    	trace(packarr);
    	trace(sysarr);
    	trace(accarr);
    }
    (obviously I want more happening in the handler function but I first want to test some data arrives)

    but I get this error:

    Code:
    Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
    	at Error$/throwError()
    	at flash.net::URLVariables/decode()
    	at flash.net::URLVariables$iinit()
    	at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    Thanks for your help it is much appreciated.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You always get the error when you test on your harddrive. You need to test it on the server.
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Junior Member
    Join Date
    Aug 2008
    Posts
    18
    well I made some progress but haven't done the server test yet so I'll have to try that next I guess but there is something I don't understand.

    The code I used flash side is based on tutorial I found when I use the persons tutorial php file it works a charm. Course they are only sending to variables username and email

    Anyway after playing with some formating etc of my php and deciding that maybe one of my variable names was reserved or something I tried again sorta fllowing the tutorial and I made pregress I can seem to stpit out a trace of variables no problem now except the very first variable. I always get variable undefined error for the first variable even if its a plain echo "piclke=picklee" statement. However the other variables all trace fine?

    Also as I say the guys simple php file traces fine so do you think it would still be Harddrive issue?

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    As I said, you get the error even your flash and php code is ok when testing on the harddrive. Test on the server. Create a textfield in flash, so you can check the response from your php script.
    - 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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center