flex 拖曳疑问 实在是没辙了

fudg1211 2009-08-29 07:15:01
//先看代码
package component
{
import flash.events.MouseEvent;

public class Drag_move
{
public var obj:Object;
public var check:Boolean;
//import flash.display.Stage;
public function Drag_move(obj:Object,stage:Object)
{
this.obj=obj;
this.obj.addEventListener(MouseEvent.MOUSE_DOWN,this.move_start);
stage.addEventListener(MouseEvent.MOUSE_MOVE,this.move);//疑问1 为什么不能直接写stage
stage.addEventListener(MouseEvent.MOUSE_UP,this.move_stop);//疑问2 怎么写进第二个参数 比如stage
}
public function move_start(evt:MouseEvent):void{
this.check=true;
}
public function move(evt:MouseEvent):void{
if(this.check){
this.obj.x=evt.localX;
this.obj.y=evt.localY;
}
}
public function move_stop(evt:MouseEvent):void{
this.check=false;
}

}
}

小弟实在是没分 先谢谢各位大哥了
...全文
126 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fudg1211 2009-09-01
  • 打赏
  • 举报
回复
我只是想在包里面直接使用stage 而不用通过传参数传递stage
gundamff 2009-09-01
  • 打赏
  • 举报
回复
protected function get stage():Object{
return XXXXXXXXXXXXXXX;
}

然后在你的包里随便写stage.XXXX
gundamff 2009-08-31
  • 打赏
  • 举报
回复
1.你想怎么写?
2.你想在move_stop方法里传stage?
fudg1211 2009-08-30
  • 打赏
  • 举报
回复
这里好冷啊 这么久了也不见下沉
fudg1211 2009-08-29
  • 打赏
  • 举报
回复
最主要是看这段
public function Drag_move(obj:Object,stage:Object)
{
this.obj=obj;
this.obj.addEventListener(MouseEvent.MOUSE_DOWN,this.move_start);
stage.addEventListener(MouseEvent.MOUSE_MOVE,this.move);//疑问1 为什么不能直接写stage
stage.addEventListener(MouseEvent.MOUSE_UP,this.move_stop);//疑问2 怎么写进第二个参数 比如stage
}

stage.addEventListener//stage 必须传递进来才能有用 如果实在没发 有什么可以代替吗 只要不传参数就ok了

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧