0 Replies Latest reply on May 21, 2010 2:06 AM by FocalPointJK

    Wrong frame rendered with draw() - AIR vs FP9


      I am working in CS3 to develop a game which will run in standalone  format. Up until now, I have been avoiding converting this to an AIR  project to keep things simpler. However, I need the ability to save to  disk so I've been attempting to make the program run under AIR.

      The problem I'm having is that the draw() function of the BitmapData  class seems to behave differently in Flash9 and AIR. I'm using it to  draw several bitmaps and MovieClip symbols to the screen to create the  game world. However, the MovieClip symbols don't draw properly when run  the the AIR environment.


      I've created a short example that illustrates the problem:


      ------- Code --------

      var screenBMP:BitmapData = new BitmapData(200, 600);    //Create bitmapData object
      var screen:Bitmap = new Bitmap(screenBMP);        //Create bitmap object and link to bitmapData
      addChild(screen);                              //Add bitmap to stage for display


      var mem:TestBlock = new TestBlock();                    //Create instance of block


      var transMatrix:Matrix = new Matrix();          //Create matrix to move block around
      transMatrix.translate(0, 0);


      var n:uint = 1;           //Counter for position
      var m:int = 2;                      //Counter for frame to display


      function clickButton(evtObj:MouseEvent):void{         //Draw another block on button click
          if (m == 2){                                        //Alternate between frames 1 and 2
              m = 1;
              m = 2;
          mem.gotoAndStop(m);         //Goto selected frame of block
          transMatrix.translate(10, 0);                  //Shift slightly to right so new block is visible
          screenBMP.draw(mem, transMatrix);               //Draw the block to the bitmapData (and thus to the screen)
      CButton.addEventListener(MouseEvent.CLICK, clickButton);



      TestBlock is a MovieClip created on the stage and exported for  ActionScript with two frames, one a blue square and the other red.  Running this in Flash9 draws alternating blue and red blocks (the  correct result), but in AIR it produces only red blocks.

      Has anyone run into something similar to this or know of a solution?