Motion trace bouncing movement

Code Actionscript 2.0

this code is only available as Actionscript 3.0

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME,enterFrame); var myBitmapData ; initScreenshot() ; var speedx = Math.random()*10; var speedy = Math.random()*10; function enterFrame(event:Event) { square.x = square.x + speedx; square.y = square.y + speedy; if (square.x > 375) { square.x = 375; speedx = -speedx; } if (square.x < 25) { square.x = 25; speedx = -speedx; } if (square.y > 375) { square.y = 375; speedy = -speedy; } if (square.y < 25) { square.y = 25; speedy = -speedy; } drawScreenshot(); } function initScreenshot() { myBitmapData = new BitmapData(stage.stageWidth, stage.stageHeight); var drawing:MovieClip = new MovieClip(); var bitmap = new Bitmap(myBitmapData); drawing.addChild(bitmap); this.addChild(drawing); } function drawScreenshot() { myBitmapData.draw(stage); }

Description

This script is drawing a trace of the movement "Bouncing movement" by taking a screenshot, and placing it as a bitmap-image onto the drawingboard.

related to: Bouncing movement

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share