12 Replies Latest reply on Nov 26, 2013 1:20 AM by mariusmta

    Draw method stop at first frame

    mariusmta

      I need to make an animated flower movie using tile of one bitmap. I use the code below but write only the first frame then stop, how can I draw more frames?

       

       

      createEmptyMovieClip("triangle",2);
      triangle.beginFill(0x000000,100);
      triangle.moveTo(width_map/2,height_map/2);
      triangle.lineTo(width_map/2+(height_map*Math.tan(angle)/2),0);
      triangle.lineTo(width_map/2,0);
      triangle.endFill();
      triangle._visible = false;
      
      attachMovie(elm_link,"elm",1);
      
      elm.setMask(triangle);
      
      sl_bmp = new flash.display.BitmapData(height_map*Math.tan(angle), height_map/2, true, 0x00000000);
      angl = 0;
      for (i=1; i<=slices; i++) {
           createEmptyMovieClip('elm'+i,10+i);
           this['elm'+i].createEmptyMovieClip('elm',0);
           this['elm'+i].elm.attachBitmap(sl_bmp,0,"always",true);
           this['elm'+i].elm._x = -height_map*Math.tan(angle)/2;
           this['elm'+i].elm._y = 2-(height_map/2);
           this['elm'+i]._x = width_map/2;
           this['elm'+i]._y = height_map/2;
           if (angl>0) {
                this['elm'+i]._rotation = angl;
           }
           angl += 360/slices;
      }
      function onEnterFrame() {
           elm._rotation += rotspeed;
           elm._x += transpeed;
           elm._y += transpeed;
           var tmp_bmp = new flash.display.BitmapData(height_map*Math.tan(angle)/2, height_map/2, true, 0x00000000);
           tmp_bmp.draw(elm,new flash.geom.Matrix(1, 0, 0, 1, -(width_map/2), 0),null,"normal",null,true);
      
           sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(-1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);
           sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);
      
      }
      
        • 1. Re: Draw method stop at first frame
          kglad Adobe Community Professional & MVP

          there are, at least, two critical undefined variables (elm_link and slices) in that code.

          • 2. Re: Draw method stop at first frame
            mariusmta Level 1

            Was defined before:

            elm_link="image" the movie linkage with bitmap

            slices=6

            • 3. Re: Draw method stop at first frame
              kglad Adobe Community Professional & MVP

              i have no idea what that's supposed to do but, if you have everything defined correctly, you're repeatedly drawing elm with the same matrix so other than elm rotating and moving, nothing else is going to change.

               

              maybe you want the following but, like i mentioned, i don't know what you're trying to accomplish.

               

               

              function onEnterFrame() {
                   elm._rotation += rotspeed;
                   elm._x += transpeed;
                   elm._y += transpeed;
                   var tmp_bmp = new flash.display.BitmapData(height_map*Math.tan(angle)/2, height_map/2, true, 0x00000000);
                   tmp_bmp.draw(elm,elem.transform.matrix,null,"normal",null,true);
              
                   sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(-1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);
                   sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);
              
              }
              
              1 person found this helpful
              • 4. Re: Draw method stop at first frame
                mariusmta Level 1

                I want to make a kaleidoscope with transparent slices from an image in library. You say "you're repeatedly drawing elm with the same matrix so other than elm rotating and moving, nothing else is going to change." I don't understand why because the first movie 'elm' is changed at each frame.

                • 5. Re: Draw method stop at first frame
                  kglad Adobe Community Professional & MVP

                  because the draw method draws the untransformed object. you need to use the draw method's matrix parameter to change elm's position/rotation/scale/shear.  try the code i suggested to see if it does what you want.

                   

                  (but i think you'll need to clear that bitmap periodically.)

                   

                  here's an as2 kaleidoscope effect: http://www.quasimondo.com/archives/000579.php

                  1 person found this helpful
                  • 6. Re: Draw method stop at first frame
                    mariusmta Level 1

                    Cannot understand how can I use your line

                    tmp_bmp.draw(elm,elem.transform.matrix,null,"normal",null,true);

                     

                    What mean 'elem'?

                     

                    Code from quasimondo.com have one problem, cannot use transparent image becouse the next frame draw on old frame even if I use true, 0x00000000 transparent parameter on BitmapData definition.

                    • 7. Re: Draw method stop at first frame
                      kglad Adobe Community Professional & MVP

                      that's a typo and should be elm

                      • 8. Re: Draw method stop at first frame
                        mariusmta Level 1

                        I tried with your code and draw nothing, please give me an example how work your ideea in my case.

                        You say "draws the untransformed object", is masked and transformed, my Ideea is to modify the masked movie position than draw a new frame with the same matrix because is more easy.

                        • 9. Re: Draw method stop at first frame
                          kglad Adobe Community Professional & MVP

                          i'm not sure anything will work with your code to do what you want.  but this, at least, will appear to draw the transformed elm:

                           

                          function onEnterFrame() {

                               elm._rotation += rotspeed;

                               elm._x += transpeed;

                               elm._y += transpeed;

                               var tmp_bmp = new flash.display.BitmapData(height_map*Math.tan(angle)/2, height_map/2, true, 0x00000000);

                               tmp_bmp.draw(elm,elm.transform.matrix,null,"normal",null,true);

                           

                               sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(-1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);

                               sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);

                           

                          }

                          1 person found this helpful
                          • 10. Re: Draw method stop at first frame
                            mariusmta Level 1

                            I tried before this code and draw nothing

                            • 11. Re: Draw method stop at first frame
                              kglad Adobe Community Professional & MVP

                              then, like i first mentioned, you probably don't have eveything defined correctly.

                               

                              and, like i mentioned previously, you should junk that code and use someone else's working code.  if you don't see how to adapt quasimondo's code, use google to search for what you want.

                              1 person found this helpful
                              • 12. Re: Draw method stop at first frame
                                mariusmta Level 1

                                Your line code working, was not visible in the area Working with transparency too.

                                 

                                 
                                function onEnterFrame() {
                                     elm._rotation += rotspeed;
                                     elm._x += transx;
                                     elm._y += transy;
                                     var tmp_bmp = new flash.display.BitmapData(height_map*Math.tan(angle), height_map, true, 0x00000000);
                                     tmp_bmp.draw(elm,elm.transform.matrix,null,"normal",null,true);
                                
                                     sl_bmp = new flash.display.BitmapData(height_map*Math.tan(angle)*2, height_map, true, 0x00000000);
                                     sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(-1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);
                                     sl_bmp.draw(tmp_bmp,new flash.geom.Matrix(1, 0, 0, 1, tmp_bmp.width, 0),null,"normal",null,true);
                                
                                     angl = 0;
                                     for (i=1; i<=slices; i++) {
                                          createEmptyMovieClip('elm'+i,10+i);
                                          this['elm'+i].createEmptyMovieClip('elm',0);
                                          this['elm'+i].elm.attachBitmap(sl_bmp,0,"always",true);
                                          this['elm'+i].elm._x = height_map*Math.tan(angle);
                                          this['elm'+i].elm._y = height_map;
                                          this['elm'+i]._x = width_map/2;
                                          this['elm'+i]._y = height_map/2;
                                          if (angl>0) {
                                               this['elm'+i]._rotation = angl;
                                          }
                                          angl += 360/slices;
                                     }
                                }

                                 

                                Now I have another little problem, the tiles don't meet exactly in the center.