Reputation:
i am using a slider to adjust alpha property (opacity) of an image. however it is not working as expected. when alpha is set to 1 (i.e maximum on the slider) then the image shows, but as soon as i slide to any value less than one then the image dissapears completely. i.e at all vales btw 0 and 0.99 there is no image...i a guessing that it is setting alpha at 0 for for all values less than 1. i am a newbie with as3. this is what i have
package {
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;
}
}
Upvotes: 0
Views: 431
Reputation: 165
You have your getter and setter functions returning/taking Integers instead of Numbers. Int will always round down to the nearest whole number (0 in this case). Use Number instead to get the decimal value.
public function set gameNewPctA(value:Number):void
{
newPctA = value;
}
//--------------------------------------------------
public function get gameNewPctA():Number
{
return newPctA;
}
}
Upvotes: 2