# AS2/CS3:ProgressBar from \_root to movieclip

**URL:** <https://forum.kirupa.com/t/as2-cs3-progressbar-from--root-to-movieclip/297348>\
**Category:** flash\
**Created:** [September 30, 2009, 5:47pm UTC](https://forum.kirupa.com/t/as2-cs3-progressbar-from--root-to-movieclip/297348 "2009-09-30T17:47:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamminBill](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@JamminBill](https://forum.kirupa.com/u/JamminBill)\
**Post date:** [September 30, 2009, 5:47pm UTC](https://forum.kirupa.com/t/as2-cs3-progressbar-from--root-to-movieclip/297348/1 "2009-09-30T17:47:02Z")

</div>

This is driving me nuts. Below is code for an interactive about where to see fall leaf colors. You can see how it works here:

[http://www.sacbee.com/1232/rich\_media/2179852.html](http://www.sacbee.com/1232/rich_media/2179852.html)

The way I have it now, there is a photo for each popup movieclip and all the photos load from an ftp server and have a progress bar connected to them. The only way I’ve ever found to make that work is to have the progressBar/loader code in the first frame of each movieclip. The loader and the progressBar are both in the movieclip. I’m trying to figure out a way to have that code in the first frame of \_root so I can use the arrays with these things also. It all works just fine except that I can’t get the progressBar.source to work. I have the line of code in question below surrounded by comments and colored red (if I did that right. I’m new here). Again it all works fine except that I CANNOT hit on the right path so that the progressBar can link to the loader component that’s loading the photo. Any thoughts? Comments?

JamminBill

var clipSpeed:Number = .5;

import mx.transitions._;  
import mx.transitions.easing._;

var p0:String = “One.jpg”;  
var p1:String = “Two.jpg”;  
var p2:String = “Three.jpg”;  
var p3:String = “Four.jpg”;  
var p4:String = “Five.jpg”;  
var p5:String = “Six.jpg”;  
var p6:String = “Seven.jpg”;  
var p7:String = “Eight.jpg”;  
var p8:String = “Nine.jpg”;  
var p9:String = “Ten.jpg”;  
var p10:String = “Eleven.jpg”;  
var p11:String = “Twelve.jpg”;  
var p12:String = “Thirteen.jpg”;  
var p13:String = “Fourteen.jpg”;  
var p14:String = “Fifteen.jpg”;  
var p15:String = “Sixteen.jpg”;  
var p16:String = “Seventeen.jpg”;  
var p17:String = “Eighteen.jpg”;  
var p18:String = “Nineteen.jpg”;  
var p19:String = “Twenty.jpg”;  
var p20:String = “Twentyone.jpg”;  
var p21:String = “Twentytwo.jpg”;  
//various arrays  
var aButtons:Array = new Array(btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn10, btn11, btn12, btn13, btn14, btn15, btn16, btn17, btn18, btn19, btn20, btn21);  
var aMapURL:Array = new Array(mapURL0, mapURL1, mapURL2, mapURL3, mapURL4, mapURL5, mapURL6, mapURL7, mapURL8, mapURL9, mapURL10, mapURL11, mapURL12, mapURL13, mapURL14, mapURL15, mapURL16, mapURL17, mapURL18, mapURL19, mapURL20, mapURL21);  
var aClipsToAttach:Array = new Array(“mc0”, “mc1”, “mc2”, “mc3”, “mc4”, “mc5”, “mc6”, “mc7”, “mc8”, “mc9”, “mc10”, “mc11”, “mc12”, “mc13”, “mc14”, “mc15”, “mc16”, “mc17”, “mc18”, “mc19”, “mc20”, “mc21”);  
var aPhotos:Array = new Array(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21);  
var aClipsAttached:Array = new Array(“mcA0”, “mcA1”, “mcA2”, “mcA3”, “mcA4”, “mcA5”, “mcA6”, “mcA7”, “mcA8”, “mcA9”, “mcA10”, “mcA11”, “mcA12”, “mcA13”, “mcA14”, “mcA15”, “mcA16”, “mcA17”, “mcA18”, “mcA19”, “mcA20”, “mcA21”);  
//basic for loop  
var count:Number = aButtons.length;  
var index:Number;  
for (var i:Number = 0; i\<count; i++) {  
if (this.aButtons.length == this.aClipsToAttach.length) {  
index = i;  
aButtons[index].i = index;  
aButtons[index].onRelease = function() {  
for (var j:Number = 0; j\<aClipsToAttach.length; j++) {  
if (this.i == j) {  
openClip(j);  
}  
}  
};  
}  
aButtons\*.onRollOver = function() {  
this.gotoAndStop(“over”);  
};  
aButtons\*.onRollOut = function() {  
this.gotoAndStop(“out”);  
};  
}  
//function that operates movieclips  
function openClip(num) {  
var clipName = aClipsAttached[num];  
var buttonLocation = aButtons[num];  
var mapURL = aMapURL[num];  
var moveClip:MovieClip = attachMovie(aClipsToAttach[num], clipName, this.getNextHighestDepth());  
var xTween:Tween = new Tween(moveClip, “\_x”, none, buttonLocation.\_x, 0, clipSpeed, true);  
var yTween:Tween = new Tween(moveClip, “\_y”, none, buttonLocation.\_y, 0, clipSpeed, true);  
var xscaleTween:Tween = new Tween(moveClip, “\_xscale”, none, 0, 100, clipSpeed, true);  
var yscaleTween:Tween = new Tween(moveClip, “\_yscale”, none, 0, 100, clipSpeed, true);

```
[COLOR=Red]//beginning of code in question
var progressBarListener:Object = new Object();
progressBarListener = function (evt_obj:Object) {
    moveClip.progressBar._visible = false;
};
moveClip.progressBar.addEventListener("complete",progressBarListener);
moveClip.mcLoader.loadMovie(aPhotos[num]);
moveClip.progressBar.mode = "polled";

```

//BELOW IS THE OFFENDING LINE OF CODE  
moveClip.progressBar.source = “\_root.moveClip.mcLoader”;  
//ABOVE IS THE OFFENDING LINE OF CODE  
moveClip.progressBar.conversion = “1”;  
moveClip.progressBar.label = “LOADING %3%%”;  
moveClip.progressBar.direction = “right”;  
moveClip.progressBar.labelPlacement = “bottom”;  
moveClip.progressBar.color = “#2A2828”;  
moveClip.progressBar.themeColor = “#2A2828”;  
//end of code in question[/COLOR]

```
xTween.onMotionFinished = function() {
    moveClip.btnGoogle.onRelease = function() {
        getURL(mapURL, "_blank");
    };
    moveClip.btnClose.onRelease = function() {
        buttonLocation._alpha = 50;
        var xTween:Tween = new Tween(moveClip, "_x", none, 0, buttonLocation._x, clipSpeed, true);
        var yTween:Tween = new Tween(moveClip, "_y", none, 0, buttonLocation._y, clipSpeed, true);
        var xscaleTween:Tween = new Tween(moveClip, "_xscale", none, 100, 0, clipSpeed, true);
        var yscaleTween:Tween = new Tween(moveClip, "_yscale", none, 100, 0, clipSpeed, true);
        xTween.onMotionFinished = function() {
            moveClip.removeMovieClip();
        };
    };
    moveClip.btnForward.onRelease = function() {
        buttonLocation._alpha = 50;
        var xTween:Tween = new Tween(moveClip, "_x", none, 0, buttonLocation._x, clipSpeed, true);
        var yTween:Tween = new Tween(moveClip, "_y", none, 0, buttonLocation._y, clipSpeed, true);
        var xscaleTween:Tween = new Tween(moveClip, "_xscale", none, 100, 0, clipSpeed, true);
        var yscaleTween:Tween = new Tween(moveClip, "_yscale", none, 100, 0, clipSpeed, true);
        xTween.onMotionFinished = function() {
            moveClip.removeMovieClip();
            if (num != 21) {
                openClip(num+1);
            }
            if (num == 21) {
                openClip(num-21);
            } 
        };
    };
    moveClip.btnBack.onRelease = function() {
        buttonLocation._alpha = 50;
        var xTween:Tween = new Tween(moveClip, "_x", none, 0, buttonLocation._x, clipSpeed, true);
        var yTween:Tween = new Tween(moveClip, "_y", none, 0, buttonLocation._y, clipSpeed, true);
        var xscaleTween:Tween = new Tween(moveClip, "_xscale", none, 100, 0, clipSpeed, true);
        var yscaleTween:Tween = new Tween(moveClip, "_yscale", none, 100, 0, clipSpeed, true);
        xTween.onMotionFinished = function() {
            moveClip.removeMovieClip();
            if (num != 0) {
                openClip(num-1);
            }
            if (num == 0) {
                openClip(num+21);
            }
        };
    };
};

```

}
