In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2011-5-14

Get Adobe Flash player
by fernando.ramallo 13 May 2011
    Embed
/**
 * Copyright fernando.ramallo ( http://wonderfl.net/user/fernando.ramallo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3FIP
 */

package {
    import flash.geom.Point;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class FlashTest extends Sprite {
        
            
            
        private var sprite:Sprite = new Sprite();
        
        private var points:Array = [];
         
        
         
        private function startDrawing(e:MouseEvent):void
        {
         points = [];
         
         sprite.graphics.clear();
         sprite.graphics.lineStyle(1);
         sprite.graphics.moveTo(stage.mouseX, stage.mouseY);
         
         points.push(new Point(stage.mouseX, stage.mouseY));
                      
         stage.addEventListener(MouseEvent.MOUSE_MOVE, plotPoint);
         stage.addEventListener(MouseEvent.MOUSE_UP, fillShape);
        }
         
        private function plotPoint(e:MouseEvent):void
        {
         sprite.graphics.lineTo(stage.mouseX, stage.mouseY);
         points.push(new Point(stage.mouseX, stage.mouseY));
        }
         
        private function fillShape(e:MouseEvent):void
        {
         stage.removeEventListener(MouseEvent.MOUSE_MOVE, plotPoint);
         stage.removeEventListener(MouseEvent.MOUSE_UP, fillShape);
         
         sprite.graphics.clear();
         sprite.graphics.lineStyle(1);
         sprite.graphics.beginFill(0xFF9900);
         sprite.graphics.moveTo(points[0].x, points[0].y);
        
         for(var i:uint = 1; i < points.length; i++)
         {
          sprite.graphics.lineTo(points[i].x, points[i].y);
         }
         
         sprite.graphics.lineTo(points[0].x, points[0].y);
         sprite.graphics.endFill();
        }            
            
            
        public function FlashTest() {
            // write as3 code here..
            addChild(sprite);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
                
        }
    }
}