我使用滑块调整图像的alpha属性(不透明度)。但它没有按预期工作。当alpha设置为1(即滑块上的最大值)时,图像会显示,但只要我滑动到小于1的任何值,图像就会完全消失。即在所有vales btw 0和0.99没有图像......我猜测它是将alpha设置为0表示所有小于1的值。我是as3的新手。这就是我所拥有的
包{
import flash.display.*;
import flash.events.*;
import fl.controls.Slider;
import fl.events.SliderEvent;
public class PicturePanel extends MovieClip {
sliderA.width=125;
sliderA.x=425;
sliderA.y=15;
addChild(sliderA);
sliderA.addEventListener(SliderEvent.THUMB_DRAG, FnNewA);
sliderA.minimum=0;
sliderA.maximum=100;
sliderA.value=100;
pctPicture.txtA.text= "alpha = " + (sliderA.value/100);
function FnNewA(event:SliderEvent):void {
pctPicture.txtA.text=""+event.value/100;
chief.gameBoard.gameNewPctA=event.value/100;
chief.gameBoard.FnEditPicture();
}
public function FnPanelSliderStart():void {
sliderA.value=chief.gameBoard.gameNewPctA*100;
pctPicture.txtA.text=""+sliderA.value;
}
}
package
{
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import fl.motion.MatrixTransformer;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.filters.ConvolutionFilter;
import flash.text.*;
import flash.filters.DropShadowFilter;
public class GameBoard extends MovieClip
{
private var newPctA:Number = 1;
public function FnEditPicture():void
{
arraySprite[chief.gamePanel.numSprite].getChildAt(0).alpha = gameNewPctA;
}
private function FnPanelPictureStartOne():void
{
newPctA = 1;
pctPanel.FnPanelSliderStart();
}
private function FnPanelPictureStartTwo():void
{
newPctA =arraySprite[chief.gamePanel.numSprite].getChildAt(0).alpha;
pctPanel.FnPanelSliderStart();
}
public function set gameNewPctA(value:int):void
{
newPctA = value;
}
//--------------------------------------------------
public function get gameNewPctA():int
{
return newPctA;
}
}
答案 0 :(得分:2)
你的getter和setter函数返回/取整数而不是数字。 Int将始终向下舍入到最接近的整数(在这种情况下为0)。使用数字代替获取小数值。
public function set gameNewPctA(value:Number):void
{
newPctA = value;
}
//--------------------------------------------------
public function get gameNewPctA():Number
{
return newPctA;
}
}