views:

57

answers:

1

Hello everyone.

As a total beginner in Flash, I am on an assignment where I should create a fake progress bar that should go from 0% - 98%.

Right now I have my line of progress with a total white tween over it that goes from left to right to indicate the fake download. See picture.

alt text

While the tween is running I want to increase the percentage so it matches and stops with 98% - is it possible to do this? And how?

My document is in AS3, but there is no action script yet so it does not matter right now. I mostly do timeline.

Thank you!

+2  A: 

Hi,

Let's assume, your "98%" is a label which has an id "txtPercent" on the stage.

For example, you can write a function which will listen enterFrame event and update your txtPercent label.

Open the actionscript editor on the first frame and write:

import flash.events.*;

//add enterFrame event listener, when timeline frame is passed the listener function is invoked
addEventListener(Event.ENTER_FRAME, updateProgress); 

function updateProgress(event:Event) {  
    //update the label with percent count
    txtPercent.text = (currentFrame / totalFrames * 100).toFixed(0) + "%";
}

Don't forget to put stop(); in the actionscript editor for the last frame.

Sergey Z.
This works - thank you! :-)
meep
You are welcome :)
Sergey Z.