|
|
Spedito - 07/05/2003 : 06:20:24
|
/*==========UN ACTIONSCRIPT A SETTIMANA======= ---------- servizio di ML gratuito offerto da www.z2000.it/mailinglist ---------
Settimana n°3: 28/02/2003
Memorizzare un percorso. Questa settimana vediamo semplicemente come memorizzare un percorso, per poi riprodurlo. Una base che può tornare utili per molti giochi.
Sullo Stage: Una palla (MC) che istanzieremo "ball" Un pulsante (Button) che istannzieremo "memory"
//========= ball memory by chicco flash =======================
var ballISO=SharedObject.getLocal("ballISO","/"); ballISO.x=new Array();ballISO.y=new Array(); function memo(x,y){this.ballISO.x.push(x);this.ballISO.y.push(y);} _root.createEmptyMovieClip("point",1); function signe(x,y){ with(_root.point){ lineStyle(2,0x00ccff,100); if(!fi){ moveTo(_root.ball._x,_root.ball._y); fi=1;} lineTo(x,y); } } function clear(){ _root.point.clear();fi=0; } ball.onPress=function(){_root.clear(); this.onMouseMove =function(){ this._x=_root._xmouse; this._y=_root._ymouse;_root.memo(this._x,this._y); } } ball.onRelease=ball.onReleaseOutside=function(){delete this.onMouseMove;_root.memory.enabled=true;} memory.onPress=function(){this.enabled=false; this.onEnterFrame=function(){ if( ballISO.x.length>0){
_root.ball._x=ballISO.x.shift();_root.ball._y=ballISO.y.shift();_root.signe( _root.ball._x,_root.ball._y); }else{ this.onEnterFrame=undefined;} } } ball.swapDepths(16000);
//========================================================== end
Il risultato e il FLA sorgente scaricabile: http://www.z2000.it/flash/tutorial/flashmx/t2.asp
Chicco Flash
|
|
|
|
|
|
|