我有一个包含一堆组件的组件,如果您单击并拖动这些组件,它们就会亮起。如果您单击并拖动这些相同的组件,它们就会恢复到正常设置。(同样,当它们被单击和未单击时,百分比值被链接以显示在组件的右侧)
现在我正在尝试创建一个“重置”按钮,将百分比设置回零并取消突出显示以前选择的所有部分。但是我在重置按钮底部的函数 (resetGVHD) 中收到“错误 #1009 无法访问空对象引用的属性或方法”。
(另外, - showCaption 是我用来使其突出显示的功能。hideCaption 是用于取消突出显示的功能。)
任何帮助将不胜感激!谢谢!
这是我的代码:
public var holdingPiece:Boolean = false;
public var holdingSelectedPiece:Boolean = false;
[Bindable]
public var numberBodyButtonSelected:Number = 0;
protected function pieMouseDownHandler(event:MouseEvent):void
{
var bodyButton:BodyButton= event.currentTarget as BodyButton;
if( bodyButton.selected ){
holdingSelectedPiece = true;
holdingPiece = false;
bodyButton.hideCaption();
if (bodyButton.includedinBody){
numberBodyButtonSelected -= bodyButton.percentageValue;
}
}else{
holdingSelectedPiece = false;
holdingPiece = true;
bodyButton.showCaption();
if (bodyButton.includedinBody){
numberBodyButtonSelected+= bodyButton.percentageValue;
}
}
stage.addEventListener( MouseEvent.MOUSE_UP, releasePiece );
}
protected function pieRollOver(event:MouseEvent):void
{
var myPie:BodyButton = event.currentTarget as BodyButton;
if( holdingPiece ){
if( !myPie.selected ){
myPie.showCaption();
if (myPie.includedinBody){
numberBodyButtonSelected+= myPie.percentageValue;
}
}
}else if( holdingSelectedPiece ){
if( myPie.selected ) {
myPie.hideCaption();
if (myPie.includedinBody){
numberBodyButtonSelected-= myPie.percentageValue;
}
}
}
}
protected function releasePiece( event:MouseEvent ):void
{
stage.removeEventListener( MouseEvent.MOUSE_UP, releasePiece );
holdingPiece = false;
holdingSelectedPiece = false;
}
public var bodyButton:BodyButton;
protected function resetGVHD( event:MouseEvent ):void{
numberBodyButtonSelected=0;
bodyButton.hideCaption();
}