gpt4 book ai didi

flex4 - 你如何制作一个自定义的 Flex 4 按钮来定位其他自定义突出显示按钮并取消选择和取消突出显示它们?

转载 作者:行者123 更新时间:2023-12-04 23:58:41 25 4
gpt4 key购买 nike

我有一个包含一堆组件的组件,如果您单击并拖动这些组件,它们就会亮起。如果您单击并拖动这些相同的组件,它们将返回到正常设置。 (此外,当它们被点击和取消点击时,一个百分比值被链接以显示在组件的右侧)

现在我正在尝试创建一个“重置”按钮,将百分比设置回零并取消突出显示之前选择的所有片段。但是我在重置按钮底部的函数 (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();







}

最佳答案

您正在寻找这样的东西:

public var holdingPiece:Boolean = false;
public var holdingSelectedPiece:Boolean = false;
[Bindable]
public var numberBodyButtonSelected:Number = 0;

private var selectedButtons:Array = [];

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){
selectedButtons.push( bodyButton ); // this might go outside the if (bodyButton.includedinBody) condition
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){
selectedButtons.push( bodyButton ); // this might go outside the if (myPie.includedinBody) condition
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;
}

protected function resetGVHD( event:MouseEvent ):void{
numberBodyButtonSelected=0;
for (var i:int = 0; i < selectedButtons.length; i++) {
BodyButton(selectedButtons[i]).hideCaption();
}
selectedButtons = [];
}

现在 resetGVHD 函数将在数组中的所有按钮上调用 hideCaption 函数...但我不确定它是否会起作用,缺少太多代码。

关于flex4 - 你如何制作一个自定义的 Flex 4 按钮来定位其他自定义突出显示按钮并取消选择和取消突出显示它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13481327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com