View Full Version : [AS3] help using slider component to scrub timeline
raine3d
09-30-2009, 04:35 PM
I am having a heck of a time trying to figure out how to control the time line with the slider component. Could anyone help me out here? I just want my 16 frame timeline to be controlled with the slider.
THank you
attunedesigns
09-30-2009, 05:03 PM
Its as easy as this!
s.setSize(200,1);
s.maximum=mc.totalFrames;
s.liveDragging=true;
s.addEventListener(Event.CHANGE,updatemc);
function updatemc(e:Event){
mc.gotoAndStop(s.value);
}
raine3d
09-30-2009, 05:32 PM
I get
1120: Access of undefined property s. x7
sorry if im confused and doing something wrong. I had a bunch of errors before when given a similar type of code.
raine3d
09-30-2009, 05:44 PM
attunedesigns
Thank you for your example. I see what I was doing wrong with your code. It workds perfect I really appretiate it!
I do have one problem Im hoping can be solved.
If my MC only contains a small number of frames the slider will be very small. It would be super if the slider will stay the lenth it is now set at 200 frames when the mc is a small amount of frames.
One more...Is there a way to target a MC placed within another swf file ? I am not sure if this is a possibility or not and am just curious
Thanks again
attunedesigns
09-30-2009, 06:13 PM
You can size the slider however big you need. Did you mean 200px when you said 200 frames?
As for accessing MCs in the loaded swf, you can just use the instance name. Here's loading a swf and accessing an MC named 'a' on the stage:
var swf:MovieClip;
var aLoader:UILoader = new UILoader();
aLoader.load(new URLRequest('mcToControl.swf'));
aLoader.addEventListener(Event.COMPLETE,swfLoaded) ;
function swfLoaded(e:Event){
swf=aLoader.content as MovieClip;
s.addEventListener(Event.CHANGE,updatemc);
trace(swf.a.totalFrames);
}
raine3d
09-30-2009, 06:28 PM
wow im not doing so good today....:P
Im sorry that was my bad. When you said did I mean 200 pixels that made me realize what i was doing wrong. For some reason I thought this value was the amount of frames my MC contains. ,... bad error on my part. Thanks for helping me see my mistake!
Thank you also for showing me the example with the swf file.
attunedesigns
09-30-2009, 07:08 PM
Word up
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.