Thursday 15 September 2011

actionscript 3 - AS#3 organize variables loaded from PhP -


I have a problem in how to organize my variable in PHP through PHP scripts. Array type format so I can loop through them. Below are some code. function full handler (event: event) {// php var after loading symbols // Array: Array = new Array () SymbolsArray.push (evt.target.data.symbol_1) ; // php named variable: symbol_1, symbol_2 trace (evt.target.data); }

The above is allworking, the PHP variable is listed as the symbol 1, symbol_2 etc.

Instead of pushing each variable into different arrays, A loop, with rows of:

  function full handler (event: event) {var symbol: erre = new array () var counter = 1 symbolsArray.push (evt.target.data. Symbol_ + counter); This issue is trace (symbol [0]);     <$ code> $ returnVars ['symbol_1'] = $ virtualReel1 [0]; $ Returnwars ['symbol_2'] = virtual real 1 [1]; $ Returnwars ['symbol_3'] = virtual real 1 [2]; $ Returnwheres ['symbol_4'] = virtual real2 [0]; $ ReturnVars ['symbol_5'] = Virtual Real 2 [1]; // etc $ return string = http_build_query ($ returnVars); Counterpart $ returnString;    

Returned data can be treated as an object (object) You can loop through this:

  Function Full handler (Event: Event) {var symbol Array: array = new array (); For each (var obj: object evt.target.data) {symbolsArray.push (obj); }}   

If you know that all the items are the same type, then you can cast the object. Example: If all numbers:

  symbols (number (obj));   

or strings:

  symbols (strings (OBJ));    

No comments:

Post a Comment