Question : Add mask to dynamicly image scroller Acionscript 3

Sorry in advance, I am a newbie to AS3!

I am looking to make a scrolling image box in Actionscript 3. It is very simple! Just an image area with a scroll bar under it. I have the scrolling image and it works good but I cant get the mask to work only as an image area.

I have posted my code below

Thank you
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
import fl.controls.Slider;
import fl.events.SliderEvent;
import fl.controls.Label;
import fl.containers.UILoader;
 
//Mask
// AS3
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill(0xFF0000);
mc.graphics.drawRect(120, 0, 200, 500);
mc.graphics.endFill();
mc.x = 0;
mc.y = 0;
addChild(mc); 
 
mask = mc; 
 
//scroller
var aSlider:Slider = new Slider();
aSlider.width = 200;
aSlider.snapInterval = 1;
aSlider.tickInterval = 10;
aSlider.maximum = 100;
aSlider.value = 1;
aSlider.move(120, 330);
 
var aLoader:UILoader = new UILoader();
var myImage:image = new image();
aLoader.addChild(myImage)
aLoader.scaleContent = false;
addChild(aLoader);
addChild(aSlider);
 
aSlider.addEventListener(SliderEvent.THUMB_DRAG, changeHandler);
 
function changeHandler(event:SliderEvent):void {
          aLoader.x = event.value * 5;
}
Open in New Window Select All

Answer : Add mask to dynamicly image scroller Acionscript 3

Hi!

mask = mc;  is not correct.

After adding your mask and scroller to the stage use:

aSlider.mask = mc;

by the way I suggest you to rename mc to sliderMask or smth. like that to have a understandable code...

Random Solutions  
 
programming4us programming4us