I have a component that has a bunch of components that if you click and drag on those components, they light up. And if you click and drag on those same components, they go back to their normal setting. (Also as they are clicked and unclicked, a percentage value is linked to show to the right of the components)
Now I am trying to create a “Reset” button that sets the percentage back to zero and unhighlights all the pieces previously selected. But I am getting a “error #1009 cannot access a property or method of a null object reference”, from my function (resetGVHD) at the bottom for the Reset button.
(Also, – showCaption is the function i use to make it highlight. hideCaption is the function used to unhighlight.)
Any help would be greatly appreciated!
Thanks!
Here is my code:
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();
}
You are looking for something like this:
Now the resetGVHD function will call the hideCaption function on all buttons, that are in the array… but im not sure, that it will work, too much code is missing.