需要将 Flash 网站的主面板从左移到右

Need to move the main panel of a flash website from left to right

该面板采用 ActionScript 2.0。它位于屏幕的左侧,也可以从左向右滑动。我要它在右边,从右向左滑动

代码如下:

//
// INITIAL SETTINGS
//
spacer = 20;
destX = -bg_mc._width+spacer;
originX = this._x;
import mx.transitions.Tween;
import mx.transitions.easing.*;
//
// OPENING TRANSITION
//
// You can use custom easing types such as: Back, Bounce, Elastic, Regular, Strong, None
var tweenMenu:Tween = new Tween(this, "_x", Strong.easeOut, destX, destX, 15, false);
openMenu = function () {
    trace('openMenu')
    tweenMenu.continueTo(0);
};
// Detect mouse position
onMouseMove = function () {
    if (this.hitTest(_root._xmouse+1, _root._ymouse, true)) {
        activated = true;
        if (this._x != 0) {
            tweenMenu.continueTo(0);
        }
    } else {
        if (this._x != destX && activated) {
            tweenMenu.continueTo(destX);
        }
    }
};  

感谢任何帮助!

根据您展示的代码,您需要做的是:

  1. 更改您的初始菜单位置(稍后将存储在 originX);
  2. 将您的 destX 变量值更改为所需值(在屏幕右侧)。它可以是直接值,而不是计算值。

更新: 在评论中查看您的消息来源后,一切都变得清晰了。 要按照您的计划进行,您应该执行以下步骤:

  1. 更改初始菜单位置
  2. nav_mc 中的代码更改为

    //
    // INITIAL SETTINGS
    //
    spacer = 20;
    destX = Stage.width-spacer; //closed menu coord depends on your stage size.
    originX = Stage.width-bg_mc._width; //closed menu too.
    
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    //
    // OPENING TRANSITION
    //
    // You can use custom easing types such as: Back, Bounce, Elastic, Regular, Strong, None
    var tweenMenu:Tween = new Tween(this, "_x", Strong.easeOut, destX, destX, 15, false);
    openMenu = function () {
        trace('openMenu')
        tweenMenu.continueTo(originX); //there was mistake. your menu always goes to 0, and originX was
        //never used in code
    };
    // Detect mouse position
    onMouseMove = function () {
        if (this.hitTest(_root._xmouse+1, _root._ymouse, true)) {
            activated = true;
            if (this._x != originX) { //same here
                tweenMenu.continueTo(originX); //same here
            }
        } else {
            if (this._x != destX && activated) {
                tweenMenu.continueTo(destX);
            }
        }
    };
    

因为您的项目似乎对舞台尺寸的变化有反应,您还需要在 alignObjects = function () {...} 中添加这些行,以便在可能的变化后提供正确的菜单定位:

nav_mc.destX = Stage.width-nav_mc.spacer;
nav_mc.originX = Stage.width-nav_mc.bg_mc._width;

if (nav_mc._x==nav_mc.destX) {
    nav_mc.tweenMenu.continueTo(nav_mc.originX);
}else{
    nav_mc.tweenMenu.continueTo(nav_mc.destX);
}