A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Instantiate a Class picked from a Class Array

Threaded View

  1. #1
    Member
    Join Date
    Jul 2009
    Location
    Florianópolis
    Posts
    81

    Instantiate a Class picked from a Class Array

    I would like to change this:

    Code:
    obj = new _objectClass();
    into something like this:

    Code:
    var objClass:Class = _objectClassArray[range(0, _objectClassArray.length)] as Class;
    obj = new objClass();
    
    trace (_objectClassArray[range(0, _objectClassArray.length)]) // returns [class MyClip] or [class MyClip2] and so on..
    Actually this last piece of code throws the following error:

    TypeError: Error #1007: Instantiation attempted on a non-constructor.


    Full explanation:

    This code goes inside an ObjectPool from HYPE Framework of Joshua Davis.

    I´ve created a "MultipleObjectPool" and changed some little details , that is: the constructor, instead of receiving a Class as a parameter, receives then a Class Array, so each time it should create an object (via the request() function) of a Class that is picked randomically from the Class Array.

    Is that possible ?

    Thanks in advance!
    Last edited by ziriguidum; 03-05-2010 at 06:11 PM. Reason: add stuff, clarify

Tags for this Thread

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