Prova questo:
L'eventListen è messo sulla funzione principale, la funzione alla fine... Dovrebbe funzionare.Codice PHP:package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.Event;
import flash.events.TimerEvent;
public class Main extends MovieClip {
private var clips_array:Array;
private const SPRING:Number=.1;
private var timer:Timer;
public function Main() {
init();
initTimer();
entra_btn.addEventListener(MouseEvent.CLICK, link_01);
}
private function init():void {
stage.frameRate=31;
bg_mc.x=0;
bg_mc.y=0;
bg_mc.width=stage.stageWidth;
bg_mc.height=stage.stageHeight;
clips_array=new Array(mc_clip_0,mc_clip_1,mc_clip_2,mc_clip_3,mc_clip_4,mc_clip_5);
}
private function initTimer():void {
timer=new Timer(400,0);
timer.addEventListener(TimerEvent.TIMER,go);
timer.start();
}
private function go(evt:TimerEvent):void {
var n:Number=Math.floor(Math.random()*clips_array.length);
var clip:MovieClip=new clips_array[n]; ;
clip.x=Math.random()*stage.stageWidth;
clip.y=-clip.height;
clip.center=clip.x;
clip.vel_x=2+Math.random()*10;
clip.vel_y=clip.vel_x;
clip.angle=0;
addChild(clip);
clip.addEventListener(Event.ENTER_FRAME,goDown);
}
private function goDown(evt:Event):void {
var acc_x:Number=(evt.target.center-evt.target.x)*SPRING;
evt.target.vel_x+=acc_x;
evt.target.x+=evt.target.vel_x;
evt.target.y+=15-evt.target.vel_y;
evt.target.rotation++;
var sine:Number=Math.sin(evt.target.angle);
evt.target.scaleX=sine;
evt.target.angle+=.1;
if (evt.target.y>=stage.stageHeight+100) {
evt.target.removeEventListener(Event.ENTER_FRAME,goDown);
var m:MovieClip=evt.target as MovieClip;
removeChild(m);
}
}
}
function link_01(event:Event):void {
navigateToURL(new URLRequest("home.html"),"_self");
}
}
CIAO

Rispondi quotando