4 Replies Latest reply on Jul 7, 2007 8:25 AM by sspecter

    AS3: graphic buffer

    sspecter
      Is there any way to create a graphic buffer in ActionScript 3.0?

      I want to create an object, and use it to draw many images simultaneously in screen. But I don't want to clone this object in memory (because i plan to use it intensively, and with bitmaps). Is there ANY way to do that???
        • 1. Re: AS3: graphic buffer
          kglad Adobe Community Professional & MVP
          you can use the graphics property of one shape object to "draw" something. you can do that repeatedly and/or you can draw that (or those) something(s) to a bitmapdata object(s).

          whether that answers your question or not, i have no idea because i'm not sure what you're trying to accomplish.
          • 2. Re: AS3: graphic buffer
            sspecter Level 1
            sadly that don't help.

            I am trying to make a tiled game. The problem is that i have the tile, but I can't figure out a way to draw it many times (simultaneously) on screen without stressing memory (by making a hundreds of clones of the tile object).

            I did got some good answers of how to clone the object, however making that become very slow, as you will have many identical objects in memory. I am currently trying to find a way to draw an object, without having to clone its content.

            Think of a graphic buffer, where you can draw it anywhere you want and how many times you want by just using the buffer itself as a reference.

            AcrionScript 3 frustrate any of my tries to simultaneously reuse the object by forbiding multiple parent containers and prototype manipulation.

            Is there any way in ActionScript 3 to redraw a MovieClip object any times you want, without having to copy the entire object????

            I want to know how the hell I can reuse an animation (simultaneously) without having to identical-copy all of it in memory!!! I believe it is not much to ask! :(

            • 3. Re: AS3: graphic buffer
              Rothrock Level 5
              The answer is there is no way to do it. You are looking for answers that are native to other ways of thinking about and manipulating objects. The way Flash is is the way it is. There is no way to draw something without drawing it. There is no way to copy something without copying it. I don't understand how you would reuse it without copying it. Even with buffers you are copying it again, it is just the system is designed to optimize that process

              Generally speaking, Flash is a memory/cpu hog and if you put a lot of graphics on the screen it will require more memory. By using movieclips/sprites you reduce file size and the requirements. That isn't to say there aren't better/less demanding ways to reuse your content. Certainly the BitmapData class and its related methods will be of great service. (I just learned about lock()/unlock() and if you are doing lots of pixel manipulations that can really speed things up.)

              Perhaps if you shared the actual use, code, effect, you are trying to achieve we could give pointers on how to optimize it? Folks have made lots of tile games, ray casting games, and other graphic intensive things and they work great.
              • 4. AS3: graphic buffer
                sspecter Level 1
                Ok, thanks for your help. You were more helpful than you think ;)

                quote:

                There is no way to draw something without drawing it. There is no way to copy something without copying it.

                Actually, I was thinking something like a texture in a 3d game. Imagine what would happen if, for each single use of a texture, the objects containing the textures itself had to be completely copied?

                Note: duplicating its graphical presentation on screen is not (or should not be) the same as duplicating the object itself.

                quote:

                Perhaps if you shared the actual use, code, effect, you are trying to achieve we could give pointers on how to optimize it?


                Thanks for the help invitation. But the code is already too big and network based to put here.

                But thanks to your post, I noticed I had to change my way of thinking. I figured out few solutions to try.