practice

I Needed GRID Practice…

Vodpod videos no longer available.


import com.greensock.TweenLite;
import com.greensock.easing.*;

var ballNum:int=150;
var cols:int=15;
var rows:int=Math.ceil(ballNum/cols);
var ballCount:int=0;

loadBalls();

function loadBalls():void {
for (var py:int = 0; py <rows; py++) {
for (var px:int = 0; px <cols; px++) {
var ball:MovieClip = new Ball();
ball.x=50+(ball.width+4) * px;
ball.y=50+(ball.height+4) * py;
with (ball.graphics) {
beginFill(0x9966ff),drawRect(-10,-10,20,20);
}
ball.buttonMode=true;
ball.alpha=.5;
addChild(ball);

if (ballCount<ballNum) {
ball.buttonMode=true;
ball.addEventListener(MouseEvent.ROLL_OVER, onOver);
ball.addEventListener(MouseEvent.ROLL_OUT, onOut);
} else {
// ball is inactive
ball.alpha=0.2;
}
ballCount++;
}
}
function onOver(evt:Event):void {
var ball:MovieClip=MovieClip(evt.target);
addChild(ball);
TweenLite.to(ball, .5, {scaleX:1.5, scaleY:1.5, ease:Bounce.easeOut});
var ct:ColorTransform = new ColorTransform();
ct.blueMultiplier = 100;
ct.greenOffset = 100;
evt.currentTarget.transform.colorTransform = ct;
}

function onOut(evt:Event):void {
TweenLite.to(evt.target, 1, {scaleX:1, scaleY:1});
evt.currentTarget.transform.colorTransform = new ColorTransform();

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s