flash on 2011-5-15
♥2 |
Line 51 |
Modified 2011-05-15 02:35:48 |
MIT License
archived:2017-03-04 19:45:48
ActionScript3 source code
/**
* Copyright bigowl ( http://wonderfl.net/user/bigowl )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jVow
*/
package {
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.events.*;
public class FlashTest extends Sprite {
public var sw:Number = stage.stageWidth;
public var sh:Number = stage.stageHeight;
public var cx:Number = sw / 2;
public var cy:Number = sh / 2;
public var bmd:BitmapData = new BitmapData(sw,sh, true, 0x00000000)
public var img:Bitmap = new Bitmap(bmd);
public var thing:Sprite = new Sprite()
public var line:Sprite = new Sprite();
public var line2:Sprite = new Sprite();
public function FlashTest() {
// write as3 code here..
thing.graphics.beginFill(0x000000,1);
thing.graphics.drawEllipse(cx - 100,cy - 100,200,200);
thing.graphics.endFill();
addChild(thing)
//addChild(line)
addChild(img);
addChild(line2);
img.mask = thing;
stage.addEventListener(Event.ENTER_FRAME, doSomething);
}
public function doSomething(e:Event):void{
var rndx:Number = Math.round(Math.random() * sw);
var rndy:Number = Math.round(Math.random() * sh);
//bmd.setPixel32(rndx, rndy, 0xFFFF0000);
bmd.noise(rndx, 0, 255, 7, true);
line.graphics.clear();
line.graphics.lineStyle(20,0xFF0000,1);
line.graphics.moveTo(sh * .5, sw * .5);
line.graphics.lineTo(mouseX, mouseY);
bmd.draw(line)
line2.graphics.clear();
line2.graphics.beginFill(0x00FF00, .2);
line2.graphics.lineStyle(1,0x0000FF,1)
line2.graphics.moveTo(cx * .5, cy * .5)
line2.graphics.lineTo(mouseX * .5, mouseY * .5);
line2.graphics.lineTo(mouseX, mouseY);
line2.graphics.lineTo(cx,cy);
line2.graphics.lineTo(cx * .5, cy * .5)
line2.graphics.endFill()
line2.graphics.beginFill(0xFF0000, .25);
line2.graphics.moveTo(sw - (cx*.5),sh - (cy*.5))
//line2.graphics.lineTo((cx*.5),(cy*.5)-(cy*.25))
line2.graphics.lineTo(sw - (mouseX * .5), sh - (mouseY * .5));
line2.graphics.lineTo((cx),(cy*.5)-(cy*.125))
line2.graphics.lineTo(cx,cy)
}
}
}