0 Replies Latest reply on Jul 5, 2007 9:03 PM by sspecter

    AS3: cloning MovieClips versus Memory

    sspecter
      Hi. I am currently trying to make a game in Actionscript 3, but I am having a problem I couldn't avoid, no matter how I've tried.

      I am trying to make an isomeric tiled game, the content would be dynamically loaded remotely, allowing the game load tiles from web. I am trying that by creating tiles in SWF and loading it (throught Loader class) from the main SWF. Then I am trying to use the loaded content to be drawed where it is needed.

      However, I am having a problem. It is being caused by 2 barriers:

      - ActionScript 3 do not allow single objects being a child of multiple containers (showing simultaneously 2 images from the same object instance in 2 MovieClips, for example)
      - ActionScript 3 do not allow prototype manipulation (so I could use the object as a model to others)

      For that reasons, I am now in a dead end. The resultant problems are:
      - the only native feature to duplicate movies is the class constructor. But it only copy a class, not an object
      - the only ways to copy an object is by copying all its content (including its graphics and animations). Meaning we will have many identical objects in memory.
      - Actionscript give no way to display a single object as many objects
      - Loading images from a class constructor will load the image each time the instance is created.

      The only painfully tries i was successful was:
      - making the tile in the library and exporting to actioncript as a class
      - duplicating the object, in memory, to a clone.
      - Reloading the same tile each time I need it
      - drawing the tile in the Tile class constructor

      However:

      - I want the tiles to be externally loaded
      -I don't have the luxury to allow identical tiles in memory (I plan creating massive amount of multilayered tiles, counting tile transitions objects, walls, etc... think about 3,000 objects at a time)

      The problem explained, I have some questions:

      1) Is there a way to duplicating an object's image in display, without having to duplicate it in memory? (note i am asking about object, not class)
      4) Is there any way around to allow multiple containers having the same child?
      2) Is there any work around Actionscript 3 to change/edit prototypes?
      3) Is there a way to define an object (including its graphics and animation) as a class (generate a class using an object as a model), in execution-time?
      5) Is there any way to create a reference-like object "pointing" to another object?

      I think ActionScript 3.0 is fantastic. I always needed error check in Flash's compilation. But it shouldn't be that difficult to make a graphic buffer in a animation-focused application.

      then....again...I can be missing some thing...

      Thanks for any help.