求as3.0高手,这段as2代码如何改为as3??
dragger.onRelease=function(){stopDrag();deletethis.onEnterFrame;};btnup.onPress=funct...
dragger.onRelease = function() {
stopDrag();
delete this.onEnterFrame;
};
btnup.onPress = function() {
this.onEnterFrame = function() {
//技巧
dragger.y = Math.max(top, dragger.y-moveSpeed);
updateContentPos();
}; 展开
stopDrag();
delete this.onEnterFrame;
};
btnup.onPress = function() {
this.onEnterFrame = function() {
//技巧
dragger.y = Math.max(top, dragger.y-moveSpeed);
updateContentPos();
}; 展开
1个回答
展开全部
dragger.addEventListener(MouseEvent.CLICK,on_click);
btnup.addEventListener(MouseEvent.CLICK,on_press);
function on_press(e:MouseEvent)
{
addEventListener(Event.ENTER_FRAME,on_enterFrame);
}
function on_click(e:MouseEvent)
{
stopDrag();
removeEventListener(Event.ENTER_FRAME,on_enterFrame);
}
function on_enterFrame(e:Event)
{
dragger.y = Math.max(top, dragger.y-moveSpeed);
updateContentPos();
}
btnup.addEventListener(MouseEvent.CLICK,on_press);
function on_press(e:MouseEvent)
{
addEventListener(Event.ENTER_FRAME,on_enterFrame);
}
function on_click(e:MouseEvent)
{
stopDrag();
removeEventListener(Event.ENTER_FRAME,on_enterFrame);
}
function on_enterFrame(e:Event)
{
dragger.y = Math.max(top, dragger.y-moveSpeed);
updateContentPos();
}
追问
dragger.addEventListener(MouseEvent.CLICK,on_click);中的on_click是怎么出来的?
如果是btnup.onRelease = function() {
delete this.onEnterFrame;
}btndown.onPress = function(){
this.onEnterFrame = function() {
dragger.y = Math.min(bottom, dragger.y+moveSpeed);
updateContentPos();
};
}
btndown.onRelease = function() {
delete this.onEnterFrame;
};是一样的道理吗
追答
on_click 是自定义的函数啊。
它的函数体
function on_click(e:MouseEvent)
{
stopDrag();
removeEventListener(Event.ENTER_FRAME,on_enterFrame);
}
另外on_enterFrame也是,名称没有什么特别意义。
btndown.onPress = function(){……}
btndown.onRelease = function() {……}
一个按钮注册两种鼠标点击事件,会冲突的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询