Well, thank God I have the source code for ProgressBar.as
I tracked it down to this:
if (_indeterminate && _source == null && _mode ==
ProgressBarMode.EVENT && visible)
startPlayingIndeterminate();
else
stopPlayingIndeterminate();
So, if you set ProgressBar.source then animation will never work. The
only way you can get this to work is to set ProgressBar.mode =
"event", but don't attach a source. Attach your own ProgressEvent
listener to your source. When you first hit that event do something
like this:
private function onProgress(e:ProgressEvent):void {
if(progressBar.indeterminate) {
trace("setting indeterminate to false");
progressBar.indeterminate = false;
progressBar.mode = "manual";
}
progressBar.setProgress(e.bytesLoaded, e.bytesTotal);
}
Now, you have to set it back to "manual" mode so you can update the
progress -- pretty screwy...but it works.
On Wed, Jan 27, 2010 at 1:04 PM, Davis Ford
<[email protected]> wrote:
> Hi, I'm looking at the following simple example:
> http://blog.flexexamples.com/2007/10/31/pausing-the-animation-in-an-indeterminate-progressbar-control/
>
> That shows how the animation on the indeterminate property of
> ProgressBar is only animated when the mode is set to "event". It woks
> on the live demo on that page, but I can't seem to get it to work for
> me.
>
> <mx:ProgressBar
> width="100%"
> id="progressBar"
> indeterminate="false"
> indeterminateMoveInterval="50"
> minimum="0"
> maximum="100"
> visible="true"
> mode="event"
> source="{fileRef}"
> labelPlacement="center"/>
>
> The progress bar is meant to show the progress of a file upload.
> {fileRef} is a FileReference I get from having the user browse. This
> all works great. The file is uploaded, and the progress bar shows the
> status updates. Below are the two functions related to this. So,
> when the user clicks the Upload button, I set indeterminate to true,
> and it shows me the indeterminate style, but there is no animation.
> When a ProgressEvent.PROGRESS is fired, I switch off indeterminate and
> see the progress bar show status updates as the file uploads.
>
> My question is why don't I see the indeterminate animation? The mode
> is clearly set to be "event". Any ideas? Thanks in advance -- davis
>
> /**
> * Handler when upload button is clicked
> */
> private function upload():void {
> // set to indeterminate
> progressBar.indeterminate = true;
>
> // add form params to our post
> var params:URLVariables = new URLVariables();
> params.description = descriptionText.text;
> params.applicationId = urlText.text;
> params.indexFile = indexFileText.text;
> urlRequest.data = params;
>
> // add event listeners
> fileRef.addEventListener(Event.COMPLETE, onUploadComplete);
> fileRef.addEventListener(ProgressEvent.PROGRESS, onProgress);
> // disable upload button so they can't upload while in progress
> uploadBtn.enabled = false;
>
> // do upload
> fileRef.upload(urlRequest);
> }
>
> /**
> * Need to trap on this to turn off progress bar indeterminate
> */
> private function onProgress(e:ProgressEvent):void {
> if(progressBar.indeterminate) {
> trace("setting indeterminate to false");
> progressBar.indeterminate = false;
> }
> }
>
--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977