4 Replies Latest reply: Sep 7, 2011 10:31 AM by gotoAndHelp ( please ) RSS

    Creating puzzle pieces help

    florin22xxl@yahoo.com

      hello

      I'm trying to created iregular puzzle pieces from a picture(in flash cs5.5) can anyone sugest some ways of doing this?maybe a usefull link.I know how to make rectangular shapes,but i'm looking in creating iregular pieces.


      tks in advance

      this is how my make puzzle pieces function looks like

      the shapes are rectangular

              private function makePuzzlePieces(bitmapData:BitmapData)
              {
                  puzzleObjects = new Array();
                  for (var x:uint = 0; x < numPiecesHoriz; x++)
                  {
                      for (var y:uint = 0; y< numPiecesVert; y ++)
                      {
                          //create new puzzle piece and sprite
                          var newPuzzlePieceBitmap:Bitmap = new Bitmap(new BitmapData(pieceWidth,pieceHeight));
                          newPuzzlePieceBitmap.bitmapData.copyPixels(bitmapData,new Rectangle(x*pieceWidth,y*pieceHeight,pieceWidth,pieceHeight),new Point(0,0));
                          var newPuzzlePiece:Sprite = new Sprite();
                          newPuzzlePiece.addChild(newPuzzlePieceBitmap);

       

                          //place in bottom sprite;
                          otherPieces.addChild(newPuzzlePiece);
                          //create object to store in array;
                          var newPuzzleObject:Object = new Object();
                          newPuzzleObject.loc = new Point(x,y);// location in puzzle
                          newPuzzleObject.dragOffset = null;//offset from cursor
                          newPuzzleObject.piece = new PuzzlePiece  ;
                          newPuzzlePiece.addEventListener(MouseEvent.MOUSE_DOWN, clickPuzzlePiece);
                          puzzleObjects.push(newPuzzleObject);
                      }
                  }
                  //randomize location of puzzle pieces
                  shufflePieces();
              }