Be a Supporter!
patchido
patchido
  • Member since: Apr. 20, 2006
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
handling arrays Aug. 25th, 2011 @ 06:07 PM Reply

why wont the data inside an array stay?? i want to populate the variable inside the function delimiter so i can use the array outside

ActionScript Code:

var fechaArray:Array =new Array();
var tec1Array:Array=new Array();
var tec2Array:Array=new Array();
var depArray:Array=new Array();
var extArray:Array=new Array();

var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("scripts/Avisos.php");
varSend.method = URLRequestMethod.POST;
variables.sendRequest="parse";
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.TEXT;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
varLoader.load(varSend);


function completeHandler(event:Event):void{
    splitByDelimiter(event.target.data);
}

function splitByDelimiter(externalString:String){
    var myArray:Array = externalString.split("(||)"); 
    var i:uint = 0;
    for (var element:String in myArray) {
        
        // Break down the inner string into an array and access elements
        var innerArray:Array = myArray[element].split("|");

        fechaArray.push(innerArray[0]);
        tec1Array.push(innerArray[1]);
        tec2Array.push(innerArray[2]);
        depArray.push(innerArray[3]);
        extArray.push(innerArray[4]);
        i++;
    }
    Object(root).prueba2.text += fechaArray;
}
    Object(root).prueba.text += fechaArray;

my traces are boxes in at the end of the script

prueba2 does populate with info but prueba doesnt, beacuse the array is empty

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to handling arrays Aug. 25th, 2011 @ 07:10 PM Reply

At 8/25/11 06:07 PM, patchido wrote: beacuse the array is empty

why is it empty?

23450
23450
  • Member since: May. 28, 2003
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to handling arrays Aug. 25th, 2011 @ 10:39 PM Reply

Object(root).prueba.text += fechaArray; is not inside any method. It might be getting called when the object it resides in gets instantiated, but fechaArray will not be populated with any data until splitByDelimiter is called. Did you mean to put it inside splitByDelimiter just under the code that sets prueba2?


BBS Signature