Search code examples
flashadobeflash-cc

To have a speed bar in Flash


I want this

enter image description here

which I found in a animation about a heart

enter image description here

One manual here but too little details and very basics. ActionScript 3 most probably the latest programming language in Flash, but I cannot find here, for instance the function changeFps.

How can you have such a speed bar for an animation? Any package for this?


Solution

  • With a component Slider named slider on your stage:

    import fl.events.SliderEvent;
    
    var val:Number = 30;
    
    slider.value = val;
    slider.maximum = 100;
    slider.minimum = 20;
    
    myFps.text = val + " fps";
    stage.frameRate = val;
    
    slider.addEventListener(SliderEvent.THUMB_DRAG, changeFps);
    
    function changeFps(e:SliderEvent):void {
        val = e.target.value;
        stage.frameRate = val;
        myFps.text = val + " fps";
    }