Flash actionscript 3.0: AS2
Showing posts with label AS2. Show all posts
Showing posts with label AS2. Show all posts

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();

Import a .swf file in flash using actionscript

0

Posted by Sankar.G | Posted in | Posted on 12:31 PM

we can import a SWF file in flash using action script
In AS2.0
code: loadMovieNum("example.swf",0);

it is simple is as2.0 example.swf is a file name & 0 is the level of the file

In AS3.0

code: var ldr:Loader=new Loader();
var urlrequest:URLRequest=new URLRequest("example.swf")
ldr.load(urlrequest);
addChild(ldr);

In as3.0 Loader is used to load a file in flash
urlrequest is used to get the link of the file
addChild is used to add that file to the scene