我使用Flash CS4 Professional构建可拖动元素。但是,每当我输入我的代码时,我都会收到错误1131.有人可以告诉我我做错了什么吗?
stop();
class Scrollbar extends Sprite
{
var value:Number;
var padding:Number = 5;
var _textField:TextField;
var max:Number;
var min:Number;
function draggable()
{
min = bar_mc.y;
max = bar_mc.height - Erhu_H3_btn.height;
Erhu_H3_btn.addEventListener(MouseEvent.MOUSE_DOWN, dragHandle);
}
function dragHandle(event:MouseEvent):void
{
Erhu_H3_btn.startDrag(false, new Rectangle(0,min,0,max));
stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
}
function stopDragging(event:MouseEvent):void
{
Erhu_H3_btn.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP, stopDragging);
}
}
答案 0 :(得分:2)
您应该将Scrollbar类的代码放在单独的.as文件中,然后您可以声明这样的实例:
import PackageName.Scrollbar;
stop();
var scrollbar:Scrollbar = new Scrollbar();
滚动条类位于" PackageName \ Scrollbar.as":
package PackageName{
import flash.display.Sprite;
public class Scrollbar extends Sprite{
var value:Number;
//...
}
}