Why is this line working outside a function:
this.pBar.removeMovieClip();
and when I put it in a function, it suddenly doesn't work anymore.
Code is listed below.
//**********************************************************
//Functgion to write the images to the stage with preloader
//**********************************************************
function WriteImages(strLocation:String, bteNumber:Number) {
//Call the function to write the images to the stage
//******************************
//SET-UP
//******************************
var xPBar:Number = 0;
var yPBar:Number = 45;
var xMovie:Number = 0;
var yMovie:Number = 0;
var xCount:Number = 4;
var minScale:Number = 12;
var maxScale:Number = 25;
//***************************************
//Init for loop to loop trough all images
for (i=0; i<=bteNumber; i++) {
//Attach the preloader movie.
var pBar = this.attachMovie("ProgressBar", "ProgressBar"+i,
this.getNextHighestDepth());
//Position the preloader movie (centered)
if ((i%4) == 0) {
if (i>=4) {
yMovie = yMovie+100;
yPBar = yPBar+100;
}
}
pBar._x = (143*(i%4))+60;
pBar._y = yPBar;
//Set the progressbar to 0
with (pBar.bar_mc) {
_xscale = 0;
}
//Create listner object for preloader
var mclListener:Object = {pBar:pBar};
//Actions to do when loading starts
mclListener.onLoadStart = function(target_mc:MovieClip) {
this.pBar.bar_mc._xscale = 0;
};
//Actions to do while loading is in progress
mclListener.onLoadProgress = function(target_mc:MovieClip,
bytesLoaded:Number, bytesTotal:Number) {
this.pBar.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
};
//Actions to do when loading is complete
mclListener.onLoadComplete = function(target_mc:MovieClip) {
this.pBar.removeMovieClip();
};
//Actions to do when load is initiated (first frame)
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._xscale = 12;
target_mc._yscale = 12;
};
//Create a container for the image to load into
var movImage:MovieClip = this.createEmptyMovieClip("image_mc"+i,
this.getNextHighestDepth());
movImage.createEmptyMovieClip("holder", 1);
//Create a object for the movieclip loader & add the listners to it (defined
above)
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
//Load the actual image
image_mcl.loadClip("
http://www.url.be/inside/images"+strLocation+"/image"+i+".
jpg", movImage.holder);
//Position the image
movImage._x = 143*(i%4);
movImage._y = yMovie;
//Assign code to the images
movImage.onRollOver = function() {
this.swapDepths(100);
this.holder._xscale = 25;
this.holder._yscale = 25;
};
movImage.onRollOut = function() {
this.holder._xscale = 12;
this.holder._yscale = 12;
};
movImage.onRelease = function() {
//
};
}
}