Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要将flash网站的主面板从左向右移动_Flash_Actionscript 2 - Fatal编程技术网

需要将flash网站的主面板从左向右移动

需要将flash网站的主面板从左向右移动,flash,actionscript-2,Flash,Actionscript 2,该面板位于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

该面板位于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);
        }
    }
};  

感谢您的帮助

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

  • 更改初始菜单位置(稍后将存储在
    originX
    中)
  • destX
    变量值更改为所需值(在屏幕右侧)。它可以是直接值,而不是计算值
  • UPD: 在评论中查看了你的消息来源之后,一切都变得清晰了。 要执行计划,您应执行以下步骤:

  • 更改初始菜单位置
  • 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);
    }
    

    相信我,阿斯皮罗,如果我知道怎么做,我就不会在这里问了。我试图在给定的位置进行一些更改,面板飞到了中间。这是消息来源。请看一下,看看出了什么问题。更新了我的答案。看看吧,天哪!非常感谢你,阿斯皮罗先生。你是个超级英雄!