Game effect
Create a new FLA and add code to the first frame F9.
| The code is as follows |
Copy Code |
|
var arr:array = new Array ();
var time:uint=0;
var angle:number=0;
var Zfun;
[SWF (width=800, HEIGHT=465,BACKGROUNDCOLOR=0XFFFFFF, framerate=24)]
This.addeventlistener (Event.enter_frame,function (Event) {
time++;
angle+=0.1;
if (time>=13) {
var Tf:textfield = addChild (New TextField ()) as TextField;
Zfun = function () {time = 0,tf.htmltext = ' <font size= ' +string (Math.Round () math.random) +15) + ' *35 ' # ' color= (Math.random () *16777215) + ' > ' + string.fromcharcode (int (math.random () *26+65). ToString ()) + ' </font> ', tf.x = Math.random () *-760+780,tf.y = -10,tf.name = (math.random () *-10+5). ToString (), Arr.unshift (TF)}.apply ();
}
for (var i:number = arr.length-1;i>=0;i--) {
Zfun =function () {arr[i].y+=3,arr[i].x+= Math.sin (angle) *int (arr[i].name)}.apply ();
if (arr[i].y>=stage.stageheight) {
Zfun =function () {removechild (arr[i)), Arr.splice (i,1)}.apply ();
Break
}
}
});
Stage.addeventlistener (Keyboardevent.key_down,function (event) {
for (var i:number = arr.length-1;i>=0;i--) {
if (Arr[i].text==string.fromcharcode (Event.keycode)) {
Zfun =function () {removechild (arr[i)), Arr.splice (i,1)}.apply ();
Break
}
}
}); |