dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: how to make array in function1=array in function2

  1. #1
    Senior Member
    Join Date
    May 2016
    Posts
    106

    how to make array in function1=array in function2

    hello

    i need items[i] = MyArray[i] in this code

    PHP Code:
    function kofa () {
        var 
    loadV = new LoadVars();                        
       var 
    MyArray = new Array();
       
    loadV.load("student.txt");  
        
    loadV.onData = function(s) {
            
    s.split('&');              
            for(
    i=0p.lengthi++) {            
                
    MyArray[i]=p[i];                                                                                                      
            }                
        }
     }
    function 
    SetItemsGen(list, dditems_exist){    
        
    Value = (dditems_exist)?-1:Number(parameters.InitialValue);
        
    items = list;
        var 
    sc:String parameters.SepChar;
        if (
    "semicolon" == sc)
            
    sc ";";    
        
    items items.split(sc);
       
    //.....................................
       //  here i need  items[i] = MyArray[i] 
       //....................................


  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,773
    In order for a variable to be visible to other stuff outside of the function it needs to be defined outside of it.
    Code:
    var MyArray:Array = new Array();
    function kofa () { 
        var loadV = new LoadVars();
        loadV.load("student.txt");
        loadV.onData = function(s) {
            trace(s); 
            p = s.split('&');               
            for(i=0; i < p.length; i++) {             
                MyArray[i]=p[i];                                                                                                       
            }                 
        } 
     } 
    function SetItemsGen(list, dditems_exist){     
        Value = (dditems_exist)?-1:Number(parameters.InitialValue); 
        items = list; 
        var sc:String = parameters.SepChar; 
        if ("semicolon" == sc) 
            sc = ";";     
        items = items.split(sc); 
       //..................................... 
       //  here i need  items[i] = MyArray[i]  
       //.................................... 
    }
    See how I moved MyArray out.
    .

  3. #3
    Senior Member
    Join Date
    May 2016
    Posts
    106
    thanks swak but not working
    is there a new idea

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