热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

我怎么能在ActionScript3中说“最后一个”-HowcouldIsay“thelast”inActionScript3

IamlearningActionScript3,andIhavethiscode:我正在学习ActionScript3,我有这个代码:}else{}else{

I am learning ActionScript 3, and I have this code:

我正在学习ActionScript 3,我有这个代码:

} else {

} else {

                ourVod.x = stage.stageWidth / 2;
                ourVod.y = stage.stageHeight / 2;

I am making an object (A) stay inside another object (B) that is not the stage. Object A follows the mouse until it is outside the Object B, and right now it comes back to the centre. I would like to to change the valour "stage.stageWidth / 2" for something like "the last x and y value the mouse was", so the object stays in the same point as it was when the mouse left Object B.

我正在制作一个物体(A)留在另一个不是舞台的物体(B)内。对象A跟随鼠标,直到它在对象B之外,现在它返回到中心。我想将“stage.stageWidth / 2”更改为“鼠标所在的最后x和y值”,因此该对象与鼠标离开对象B时保持相同的点。

Thanks a lot!!

非常感谢!!

1 个解决方案

#1


1  

I ignore your code, but something like that works (we imagine that your object B appears in the conditional test):

我忽略了你的代码,但是这样的东西有效(我们想象你的对象B出现在条件测试中):

var oldX:Number;
var oldY:Number;

function enterFrameHandler(e:Event):void {
    if (mouseX > 100 && mouseX <400 && mouseY <350 && mouseY > 50) {
        oldX = A.x = mouseX;
        oldY = A.y = mouseY;
    } else {
        A.x = oldX;
        A.y = oldY;
    }
}

this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

Note: the coordinates of the object A are not necessarily at the limit of the object B. They are the last coordinates of the object A was when the mouse left object B.

注意:对象A的坐标不一定是对象B的极限。它们是对象A的最后一个坐标,当鼠标离开对象B.


推荐阅读
author-avatar
能豆子314
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有