Avatar of derrida
derrida

asked on 

problem with the slider component -AS3

Hi
i have a Slider component which scroll a movie which include in it other movies. i built all great and it does scroll but i cannot make it scroll exactly from the start of the container movie to its end (which depends on the amount of inner movies);

seem to be easy: determine the hieght of the container by multiply the inner movie height with the number of inner movies. but hey, it does not work. at least not for me.

i attach the code:

what am i doing wrong?

best regards


ron
import fl.controls.Slider;
import fl.events.SliderEvent;
 
var container:MovieClip = new MovieClip();
var clip:MovieClip;
 
addChild(container);
container.x = 150;
container.y = 55;
 
 
var numofbox:Number = 15;// this will be dynamic from database
 
 
 
for (var i:int = 0; i < numofbox; i ++) {
	clip = new box();
	clip.buttonMode= true;
	clip.name = "clip" + i;
	clip.info_txt.text = clip.name;
	//trace(clip.name);
	clip.y += (clip.height+ 5) * i ;
	container.addChild(clip);
	//trace(clip.height);
	clip.addEventListener(MouseEvent.CLICK , tellname);
}
 
 
function tellname (e:MouseEvent):void {
	trace(e.target.name);
}
 
 
var mymask:Sprite = new Sprite();
mymask.graphics.beginFill(0x000000,1);
mymask.graphics.drawRoundRect(container.x,container.y,container.width,320,30,30);
mymask.graphics.endFill();
addChild(mymask);
 
container.mask = mymask;
 
 
 
Slider.maximum = clip.height * numofbox;
 
Slider.addEventListener(SliderEvent.CHANGE , scrollMovie);
 
 
function scrollMovie (e:SliderEvent):void {
	//trace(e.target.value);
	container.y = - e.target.value;
}

Open in new window

Adobe Flash

Avatar of undefined
Last Comment
derrida

8/22/2022 - Mon