Flash actionscript 3.0: December 2008

circle collusion in AS2.0

0

Posted by Sankar.G | Posted in | Posted on 4:45 PM

CIRCLE COLLUSION IN AS2.0
ang = 1;
speed = 0.3;
r = 100;
moved();
c2.onPress = function() {
startDrag(this);
};
c2.onRelease = function() {
stopDrag();
};
start_btn.onPress = function() {
c2._x = _xmouse;
c2._y = _ymouse;
};
function moved() {
this.onEnterFrame = function() {
c1._x = 200+(Math.sin(ang)*r);
ang += speed;
xdist = c2._x-c1._x;
ydist = c2._y-c1._y;
dist = Math.sqrt(xdist*xdist+ydist*ydist);
angle = Math.atan2(ydist, xdist);
if (dist<
c1._width) {
c2._x = c1._x+(c1._width*Math.cos(angle));
c2._y = c1._y+(c1._width*Math.sin(angle));
updateAfterEvent();
}
};
}

snow effect

0

Posted by Sankar.G | Posted in | Posted on 3:53 PM

w = Stage.width;
h = Stage.height + 100;
max_snowsize = 10;
snowflakes = 40;

init = function ()
{
for( i = 0; i < snowflakes; i++ ) { t = attachMovie("snow", "snow"+i, i); t._alpha = 50 + Math.random()*50; t._x = -(w*0.5) + Math.random()*(1.5*w); t._y = -(h*0.5) + Math.random()*(1.5*h); t._xscale = t._yscale = 50 + Math.random()*(max_snowsize*10); t.k = Math.random()*1.5 + 1; t.wind = Math.random()*3.5 - 1.5; t.onEnterFrame = mover; } } mover = function () { this._y += this.k; this._x += this.wind; if(this._y > h+10)
{
this._y = -20;
}
if(this._x > w+20)
{
this._x = -(w*0.5) + Math.random()*(1.5*w);
this._y = -20;
}
else if(this._x < -20)
{
this._x = -(w*0.5) + Math.random()*(1.5*w);
this._y = -20;
}
}
init();

attach a movieclip from library using AS3.0

0

Posted by Sankar.G | Posted in | Posted on 6:05 PM

Below code is used to attach a movie Clip using AS 3.0 from a library
var ax:Number=100;
var but:Array=new Array();
function funm() {
for (var i:Number=0; i < 8; i++) {
but[i] = new obj1();
but[i].name = "s"+i;
addChild(but[i]);
but[i].x=ax;
but[i].y=100;
ax=ax+60;
but[i].addEventListener(MouseEvent.ROLL_OVER,fun);
}
}
function fun(e:Event) {
var cc:Number=(e.target.name.substr(1));
getChildByName("s" + cc).addEventListener(MouseEvent.MOUSE_DOWN,fun1);
getChildByName("s" + cc).addEventListener(MouseEvent.MOUSE_UP,fun2);
}
function fun1(e1:Event) {
var ob = e1.target;
ob.startDrag();
}
function fun2(e2:Event) {
var ob1 = e2.target;
ob1.stopDrag();
}
funm();