Reputation: 724
I am new to ActionScripot and Flash and I am stuck with the following problem:
On the stage I have a movieclip (Container, originally 200px width) and inside it with a progressbar movieclip (originally 700px width), scaled with Free Transform Tool to fit the parent container. The width of the container changes run-time while resizing the scene.
In ActionScript I have a function which should set the progress bar width according to a calculated percentage value:
private function updateProgress(event:TimerEvent):void
{
var barWidth:int = _container.width;
var progress:Number = _stream.time / _stream.duration * barWidth;
_progressBar.width = progress;
}
My problem is that the progressBar even at full time (100%) is only at 1/4 of the parent container. I assume that it comes from the symbols original size.
Can I correct this programatically, or I must redesign it with the "designer"?
I hope I made clear my problem, as I said, I'm new in Flash.
Thanks in advance.
Upvotes: 0
Views: 647
Reputation: 2316
If I understand correctly, your _progressBar has its scaleX set by the designer. What you could do is store the initial scaleX and change your function to:
...
var barScaleX = _progressBar.scaleX;
...
private function updateProgress(event:TimerEvent):void
{
var progress:Number = _stream.time / _stream.duration;
_progressBar.scaleX = barScaleX * progress;
}
This should set the width of the progressbar by a percentage of it's original scale.
Upvotes: 3
Reputation: 19812
Try to divide the barWidth with the amount of the times scaled or write the original width = 700px
Upvotes: 0