stevethomas
10-03-2009, 04:48 AM
Let's start out by saying I'm a noob with AS3.
Not sure if this has been addressed or not, but I found a way to control the timeline within a movieclip using the slider component. I searched for hours and eventually found this link which pointed me in the right direction:
http://www.gotoandlearnforum.com/viewtopic.php?f=29&t=24015
And if you are wondering why I used the slider component instead of the custom slider from the link above - I like the tickInterval feature on the component. If anyone has code that will automatically do this on a custom slider I'm all for it.
I've tried this with different numbers of frames within the mc and got stumped on the math. As of now it only has 10 frames and seems to work well. Having said that, there is probably a line or two that isn't needed. Here is the code:
import fl.controls.Slider;
import fl.events.SliderEvent;
import flash.events.Event;
amount.text = "1";
mcTest.gotoAndStop(1);
var mcSlider:Slider = new Slider();
var animLength : int = mcTest.totalFrames;
var calcWidth : Number = mcSlider.maximum / animLength;
mcSlider.move(20,150);
mcSlider.liveDragging = true;
mcSlider.setSize(500,0);
mcSlider.minimum = 1;
mcSlider.maximum = 10;
mcSlider.tickInterval = 1;
addChild(mcSlider);
mcSlider.addEventListener(SliderEvent.CHANGE, doSliderChange);
mcTest.addEventListener(Event.ENTER_FRAME, scrubMovie);
function scrubMovie(evt:Event):void
{
var scrubPos : int = mcSlider.value;
var gotoFrame : int = Math.ceil(scrubPos / calcWidth);
mcTest.gotoAndStop(gotoFrame);
}
function doSliderChange(e:SliderEvent):void {
amount.text = e.target.value;
}
I've attached the fla as well.
A question I have is, how would I be able to manipulate the text so that it would show specific years instead of the mcSlider.maximum = 10;?
Also, if you have success using different frame numbers in the mc, post the code please.
Steve
Not sure if this has been addressed or not, but I found a way to control the timeline within a movieclip using the slider component. I searched for hours and eventually found this link which pointed me in the right direction:
http://www.gotoandlearnforum.com/viewtopic.php?f=29&t=24015
And if you are wondering why I used the slider component instead of the custom slider from the link above - I like the tickInterval feature on the component. If anyone has code that will automatically do this on a custom slider I'm all for it.
I've tried this with different numbers of frames within the mc and got stumped on the math. As of now it only has 10 frames and seems to work well. Having said that, there is probably a line or two that isn't needed. Here is the code:
import fl.controls.Slider;
import fl.events.SliderEvent;
import flash.events.Event;
amount.text = "1";
mcTest.gotoAndStop(1);
var mcSlider:Slider = new Slider();
var animLength : int = mcTest.totalFrames;
var calcWidth : Number = mcSlider.maximum / animLength;
mcSlider.move(20,150);
mcSlider.liveDragging = true;
mcSlider.setSize(500,0);
mcSlider.minimum = 1;
mcSlider.maximum = 10;
mcSlider.tickInterval = 1;
addChild(mcSlider);
mcSlider.addEventListener(SliderEvent.CHANGE, doSliderChange);
mcTest.addEventListener(Event.ENTER_FRAME, scrubMovie);
function scrubMovie(evt:Event):void
{
var scrubPos : int = mcSlider.value;
var gotoFrame : int = Math.ceil(scrubPos / calcWidth);
mcTest.gotoAndStop(gotoFrame);
}
function doSliderChange(e:SliderEvent):void {
amount.text = e.target.value;
}
I've attached the fla as well.
A question I have is, how would I be able to manipulate the text so that it would show specific years instead of the mcSlider.maximum = 10;?
Also, if you have success using different frame numbers in the mc, post the code please.
Steve