Estoy creando una especie de juego de autos en flash el cual tiene:
un movieclip con una pista que avanza y se repite una y otra vez (llamado: pista)
tres botones q aceleran dicho moviclip (llamados: vel1, vel2, vel3)
y un boton stop (stopMC)
todo esto funciona con el siguiente codigo:
Código :
//MovieClip.prototype.customFPSID = null
//MovieClip.prototype.gotoAndPlayFPS = function(frame,fpsVal) {
// this.gotoAndStop(frame)
// this.playFPS(fpsVal)
//}
//MovieClip.prototype.playFPS = function(fpsVal) {
// this.stop()
// if(this.customFPSID) clearInterval(this.customFPSID)
// this.customFPSID = setInterval(customTimeout,1000/fpsVal,this)
//}
//var customTimeout = function(e:*) {
//
// if(e.currentFrame >= e.totalFrames)
// e.gotoAndStop(1)
// else
// e.gotoAndStop(e.currentFrame + 1)
//}
//
//
//
//pista.playFPS(5)
vel1.addEventListener(MouseEvent.CLICK,function(e:*) {
pista.fps = uint(30)
})
vel2.addEventListener(MouseEvent.CLICK,function(e:*) {
pista.fps = uint(60)
})
vel3.addEventListener(MouseEvent.CLICK,function(e:*) {
pista.fps = uint(90)
})
stopMC.addEventListener(MouseEvent.CLICK,function(e:*) {
pista.stop()
})
y con un archico .as
Código :
package {
import flash.display.MovieClip
import flash.events.Event
import flash.utils.Timer
import flash.events.TimerEvent
public class MovieClipVS extends MovieClip {
private var __fps:uint = 0
private var __fpsTimer:Timer = new Timer(1000/12,0)
public function MovieClipVS( ... args ) {
if(args[0]) __fps = args[0]
this.addEventListener(Event.ADDED_TO_STAGE,init)
__fpsTimer.addEventListener(TimerEvent.TIMER,advanceFrame)
super.stop()
}
public override function gotoAndPlay( frame:Object,scene:String = null):void {
this.gotoAndStop(frame,scene)
this.play()
}
public override function play():void {
if(__fps == 0) {
__fpsTimer.stop()
super.play();
return;
}
__fpsTimer.start()
}
public override function stop():void {
__fpsTimer.stop()
super.stop();
}
private function init(e:Event) {
if(__fps == 0) return
__fpsTimer.delay = 1000/__fps
}
public function set fps(p_fps) {
__fps = p_fps
if(__fps == 0) {
this.play()
return;
}
__fpsTimer.delay = 1000/__fps
this.play()
}
public function get fps() {
return __fps;
}
public function advanceFrame(e:TimerEvent) {
if(this.currentFrame == this.totalFrames)
this.gotoAndStop(1)
else
this.gotoAndStop(this.currentFrame + 1)
}
}
}
ahora quiero que el boton stop detenga lentamente la pelicula... no en seco!!
quizas se podra con alguna formula que reste los fps?? no necesariamente con un
Código :
pista.stop()
he estado probando con
Código :
pista.fps = uint.MIN_VALUEpero baja la velocidad a 30 fps y no se como poder establecer ese min value en 0
o que valla frenando progresivamente independiente de la velocidad q lleve
eso
espero podamos armar esto entre todos
