1

Is there an equivalent in actionscript of php's list()?

1
  • not easy to google, for quite obvious reasons
    – o0'.
    Mar 24, 2011 at 10:38

3 Answers 3

1

There is a similar question regarding list in JS: Javascript equivalent of PHP's list()

There is also a experimental JS implementation of list from PHPJS: https://github.com/kvz/phpjs/blob/master/_experimental/array/list.js

1

You don't have an equivalent to list() in AS3.0 and implementing one is really difficult(near impossible).

The primitive types: Boolean, int, Number, String, and uint cannot be (manually) passed by reference and changed via this reference. This is because Flash stores them as immutable objects internally. So when it passes by value it actually passes by a reference but the data cannot be changed(see link 2).

Example:

    var obj:Object = {xy:21,yx:24};
    var num:Number = 24;
    public function Sample():void{

        trace(obj.xy,obj.yx,obj.hey);
        boom(obj);
        trace(obj.xy,obj.yx,obj.hey);
        heya(obj);
        trace(obj.xy,obj.yx,obj.hey);
        nullify(obj)
        trace(obj.xy,obj.yx,obj.hey);
        trace("Testing number");
        trace(num);
        numer(num);
        trace(num);

    }

    function boom(obj1:Object){
        var i:uint=0;
        obj1.xy=34;
        obj1.yx=34;

    }

    function heya(obj2:Object){

        obj2.hey = "hehe";
    }

    function nullify(obj3:Object){

        obj3=null;
    }

    function numer(xz:Number){
        xz=45;
    }

when function Sample() is run we get the following output:

21 24 undefined
34 34 undefined
34 34 hehe
34 34 hehe
Testing number
24
24

Therefore, we can conclude that we can modify an object's properties(add them or change them) but we cannot change the object itself. Also we cannot change a primitive type variable's value.

Function parameters: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f56.html

Data Types: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9c.html

1

here is an article about 4 ways of making lists in AS3 http://www.richardlord.net/blog/linked-list-performance-test

and one more article http://lab.polygonal.de/?p=206

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.