6 Replies Latest reply on Aug 17, 2012 6:44 AM by sinious

    Basic Question about Structure

    beamycruns

      I have some logic in a function that moves movieclips around using x and y coordinates.  How can I incorporate the FPS/events/Frames to slow these moves down?  Thanks.

        • 1. Re: Basic Question about Structure
          Ned Murphy Adobe Community Professional & MVP

          I am not sure what you mean in saying you want to use FPS/events/Frames to slow the movieclips down.  What is the logic/code that is moving them around?

           

          If the movement is based on the frame rate, then you could try lowering the frame rate.  You could also try getting the frame rate out of the movement logic if you want more flexibility in controlling the speed of movement.

          1 person found this helpful
          • 2. Re: Basic Question about Structure
            robdillon Most Valuable Participant

            Look at the EnterFrame event and the Timer object. EnterFrame can be used to call a function once each frame, so the timing corresponds to the frame rate. A Timer object can be used to call a function at a rate that you set.

            1 person found this helpful
            • 3. Re: Basic Question about Structure
              beamycruns Level 1

              Ned/Rob,

               

              My apologies, it was late last night and I was giving up and going to bed.  Not the clearest question ever formed. 

               

              So this is an interactive game that I'll eventually deploy to the iPhone, it'll be somewhat animated, but I don't think it will push any limits.  I'm not really familiar with Flash and most of my programming experience has been with VBA and business stuff, but this first journey into flash games should be pretty basic.

               

              I see what you guys are saying with the Timer or the EnterFrame.  My comfort zone pushes me toward using a timer and to ignore the Flash frame and timeline system for my animations. Are there any inefficiencies or pitfalls with this approach?

               

              Also, just to make sure I'm being efficient, I've started by mapping out my interface, which includes transparent regions, in photoshop, then saved them as PNGs and moved them into Flash.  Flash had me convert the images I wanted to move into MovieClips.  Is there a more appropriate way of doing this?

               

              Thanks for the help guys, I just want to get started on the right foot.  Most of my websearching gets me syntax and howtos, but these broader concepts are a built difficult to get answers for.

              • 4. Re: Basic Question about Structure
                robdillon Most Valuable Participant

                Most new users of Flash start animating using the timeline. You can use it or not, when the .swf file is compiled everything is converted to code in any case. If you are comfortable building a timer as a control for your animation, then use that. You will have more flexibility.

                 

                If you can create your artwork as vector rather than bitmap, you'll save file size for the download. Flash can more efficiently animate vectors than it can bitmaps. If you use bitmap images you may find that using gif or jpeg file types may save you some file size. You can use Photoshop's "Save for Web and Devices" option to get the most compact file size while maintaining image quality.

                1 person found this helpful
                • 5. Re: Basic Question about Structure
                  beamycruns Level 1

                  Awesome, I will rebuild the art for vector.  I don't think file size will be much of problem, but I want efficiency as I'm a bit concerned about the Flash to iOS conversion. 

                   

                  Thanks again for the help.  I think I've got a solid start.

                  • 6. Re: Basic Question about Structure
                    sinious Most Valuable Participant

                    The complexity of the vector greatly matters in saying that a vector is less overhead on a mobile device than a bitmap. Size-wise it is far more efficient but certainly not always in performance cost.

                     

                    In almost all cases (especially text), vectors will kill your processor. I'm presuming you're not getting into any Stage3D or really utilizing the GPU. With the CPU, bitmaps are almost always faster because it's just copying areas of memory, not calculating. The only case to be made is setting a complex vectors cacheAsBitmap to true and then you have a bitmap in memory anyhow.

                     

                    If you've built websites before, try to use the cutting techniques you've learned to break the interface up into the smallest bitmaps possible. For instance if you have an interface that surrounds all edges of the screen with the center transparent, it's more memory efficient to cut the bitmap into pieces while removing the transparent area rather than render a single bitmap with transparency.

                     

                    Mobile devices greatly lack on CPU and you should always think of everything except the latest generation of quad core tablets as basically glorified phones. You're much more used to desktop programming and performance and mobile performance without utilizing Stage3D will certainly suprise you, for the worse.

                     

                    A Timer is better than Event.ENTER_FRAME. You can't guarantee the framerate during a game on mobile devices which goes up and down. Event.ENTER_FRAME is very expensive so use it a little as possible. Timers are much less expensive and logic executes more reliably over uneven frame rates.

                    1 person found this helpful