Estoy haciendo una botonera y uso un sprite, cuando aprieto en un botón la caja siempre arranca a moverse desde el mismo lugar. Quisiera que lo haga desde la ultima posición que estuvo la caja. Me ayudan? No se me ocurre como hacerlo. Quizás cuando sepa mas algún día pueda ayudar yo pero no se mucho por ahora.
Aqui pongo el swf para que se entienda.
file:///G:/mover_mc.swf
Aqui esta el codigo:
Código ActionScript :
import flash.events.*; import fl.transitions.Tween; import fl.transitions.easing.*; var caja:Sprite= new Sprite caja.graphics.beginFill(0xfff000); caja.graphics.drawRect(0,0,20,20); caja.graphics.endFill(); caja.x=65 caja.y=30 addChild(caja); stage.frameRate=40 a_btn.addEventListener(MouseEvent.CLICK, aMover); b_btn.addEventListener(MouseEvent.CLICK, bMover); c_btn.addEventListener(MouseEvent.CLICK, cMover); d_btn.addEventListener(MouseEvent.CLICK, dMover); var pos:Number= caja.x ; var a:Number = 15 var b:Number = 65 var c:Number = 115 var d:Number = 165 var efec_c:Tween = new Tween(caja,"x",Regular.easeInOut, pos,c,2, true) var efec_d:Tween = new Tween(caja,"x",Regular.easeInOut, pos,d,2, true) var efec_a:Tween = new Tween(caja,"x",Regular.easeInOut,pos,a,2, true) var efec_b:Tween = new Tween(caja,"x",Regular.easeInOut, pos,b,2, true) function aMover(event:MouseEvent):void { this.efec_a.start(); } function bMover(event:MouseEvent):void { this.efec_b.start(); } function cMover(event:MouseEvent):void { this.efec_c.start(); } function dMover(event:MouseEvent):void { this.efec_d.start(); }