25 lines source code

In the last post, I put up my entry to one of the 25 lines of actionscript competitions. In case you missed it, here it is again.
[kml_flashembed
fversion=”8.0.0″ movie=”flash-content/25lines/25lines.swf” targetclass=”flashmovie” publishmethod=”static” width=”400″ height=”400″]

Get Adobe Flash player

[/kml_flashembed]
And here is the AS3 that makes it – for a stage size of 400 x 400, and a frame rate of about 50.

stage.quality = StageQuality.LOW;
var stageSin = 0.1;
var bmd:BitmapData = new BitmapData(400, 400, true, 0x000000);
var bm:Bitmap = new Bitmap(bmd);
addChild(bm);

for(var i=1;i<=360;i++){
     var circle:Shape = new Shape( );
     circle.graphics.beginFill( ((0xFFFFFF*i)/360) , 1 );
     circle.graphics.drawCircle( 0 ,  0 , i/(i/2) );
     var holder:MovieClip = new(MovieClip);
     holder.x = holder. y = 200;
     addChild(holder);
     holder.addChild(circle)
     circle.y=-10;
     holder.myNum= i;
     holder.addEventListener(Event.ENTER_FRAME, spinCircle);
}
function spinCircle(e:Event):void{
     e.currentTarget.rotation+=((mouseY-200)/100)*(Math.PI*(e.currentTarget.myNum/2))/150;
     e.currentTarget.alpha = Math.abs(1-(mouseX/200));
     e.currentTarget.scaleX = e.currentTarget.scaleY = ((Math.PI*(e.currentTarget.myNum/2))+(Math.sin(stageSin)*350))/15;
}

addEventListener(Event.ENTER_FRAME, drawAndSin);

function drawAndSin(e:Event):void{
     bmd.draw(this);
     bmd.applyFilter(bmd, bmd.rect, new Point(0,0), new BlurFilter(2, 2, 1));
     stageSin+=0.02;
}

In just 25 lines of Actionscript 3…

Right, I’m new to this, so go easy with me.
The idea of this blog, is to share some of the code I write and ideas I have. So much of my learning process with Flash has been through blogs and messageboards, I thought I’d best give something back.
I’m still getting to grip with WordPress, so I’m not sure how well this work, but hopefully you should see a flash movie here –
[kml_flashembed
fversion=”8.0.0″ movie=”flash-content/25lines/25lines.swf” targetclass=”flashmovie” publishmethod=”static” width=”400″ height=”400″]

Get Adobe Flash player

[/kml_flashembed]
Cool! You can affect the transparency of the circles and their spin direction by moving your mouse around.
Well, that was my entry into the awesome 25 lines competition, a great idea run by Keith Peters. The idea was to create something cool using just 25 lines of Actionscript 3, and that’s what I made. Needless to say, the Flash community submitted some staggering pieces, but I’m still quite proud of my entry as it was one of my first AS3 projects. In my next post, I’ll post the source code.