• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 596
  • Last Modified:

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
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

0
wraithlord
Asked:
wraithlord
1 Solution
 
biyikCommented:
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...
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now