Flash 如何设置MovieClip位置而不弄乱tween?

Flash 如何设置MovieClip位置而不弄乱tween?,flash,actionscript-3,box2d,Flash,Actionscript 3,Box2d,我正在开发一款带有移动平台的AS3和Box2D游戏。平台在Flash中设置动画,在actionscript中,我可以在当前位置读取并调整物理实体以匹配 但是,总有一个延迟,动画比物理动画提前一帧。我想通过读取剪辑的当前位置来修复这个问题,存储它以备以后使用,然后将剪辑放回最后一帧的位置 但当我这样做时,它系统性地拒绝让步 我编写了一个简单的测试,用一个移动的盒子来测试这个想法,我得到了同样的问题(“movingBox”是一个符号,它使其中的一个“盒子”符号具有动画效果): 不是打印出移动框的位置

我正在开发一款带有移动平台的AS3和Box2D游戏。平台在Flash中设置动画,在actionscript中,我可以在当前位置读取并调整物理实体以匹配

但是,总有一个延迟,动画比物理动画提前一帧。我想通过读取剪辑的当前位置来修复这个问题,存储它以备以后使用,然后将剪辑放回最后一帧的位置

但当我这样做时,它系统性地拒绝让步

我编写了一个简单的测试,用一个移动的盒子来测试这个想法,我得到了同样的问题(“movingBox”是一个符号,它使其中的一个“盒子”符号具有动画效果):

不是打印出移动框的位置,而是框保持静止,跟踪调用输出:

frame: 1 , x: 0
frame: 2 , x: 0
frame: 3 , x: 0
frame: 4 , x: 0
frame: 5 , x: 0
...
有什么想法吗?谢谢

更新:只是为了澄清,如果我删除
框。x=0行时,框会正确移动,跟踪调用会输出x的递增值

更新:我举了一些例子:

upd:

package{    
import flash.display.*;
import flash.events.*;    
public class Main extends Sprite {

    public function Main():void {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        // entry point            
        m_movingBox = new MovingBoxClass();
        this.addChild(m_movingBox);
        m_movingBox.stop();
        addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }

    private function onEnterFrame(i_event:Event) : void    {
        var str: String = m_movingBox.getChildAt(0).x + ' - ';
        m_movingBox.gotoAndStop(m_movingBox.currentFrame + 1 < m_movingBox.totalFrames ? m_movingBox.currentFrame + 1 : 0);
        str += m_movingBox.getChildAt(0).x;
        trace(str);
    }        

    [Embed(source="../lib.swf", symbol="movingBox")]
    private var MovingBoxClass:Class;        
    private var m_movingBox : MovieClip;
    }    
 }
包{
导入flash.display.*;
导入flash.events.*;
公共类Main扩展了Sprite{
公共函数Main():void{
if(stage)init();
else addEventListener(Event.ADDED_TO_STAGE,init);
}
私有函数init(e:Event=null):void{
removeEventListener(Event.ADDED_TO_STAGE,init);
//入口点
m_movingBox=新的MovingBoxClass();
这个.addChild(m_movingBox);
m_movingBox.stop();
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
私有函数onEnterFrame(i_事件:事件):void{
var str:String=m_movingBox.getChildAt(0.x+'-';
m_movingBox.gotoAndStop(m_movingBox.currentFrame+1

现在,您可以管理此动画并在每帧调整其他坐标

是的,
m_movingBox
不会自行移动,只有
box
移动,在
m_movingBox
@drpepper的影响下-那么
m_movingBox
仍然站在那里搬运
box
并管理它的动画?我可以看看吗?还有一个愚蠢的问题:你确定你在追踪正确的孩子吗?例如,您是否尝试将其更改为
alpha
?顺便说一句,你的问题可能是因为一些青少年使用计时器而不是回车_frame@www0z0k我举了上面的例子。我没有使用任何自定义tweening代码或任何东西,这只是flash编辑器中的“运动tween”。@drpepper-test.swf显示一个静止的矩形。下载了文件。。。我用的是flash cs4,你能制作一个兼容的.fla吗?@www0z0k没问题,我只是用cs4版本替换了lib.fla。我将其导出到lib.swf(如您所见,它仍在移动)。当我将它导入到我的程序(test.swf)中时,我阻止它随着
box.x=0
行移动。它不动是正常的。但是,我不能理解的是,为什么我不能在我的追踪呼叫中读取它的tween位置。它不应该已经被它的动画所移动了吗?
package{    
import flash.display.*;
import flash.events.*;    
public class Main extends Sprite {

    public function Main():void {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        // entry point            
        m_movingBox = new MovingBoxClass();
        this.addChild(m_movingBox);
        m_movingBox.stop();
        addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }

    private function onEnterFrame(i_event:Event) : void    {
        var str: String = m_movingBox.getChildAt(0).x + ' - ';
        m_movingBox.gotoAndStop(m_movingBox.currentFrame + 1 < m_movingBox.totalFrames ? m_movingBox.currentFrame + 1 : 0);
        str += m_movingBox.getChildAt(0).x;
        trace(str);
    }        

    [Embed(source="../lib.swf", symbol="movingBox")]
    private var MovingBoxClass:Class;        
    private var m_movingBox : MovieClip;
    }    
 }