aquaman
November 6, 2003, 12:01am
1
can someone please tell me what i´m making wrong:
for (i=1; i<=8; i++) {
attachMovie("mc", "m"+i, i);
_root["m"+i]._x = 10;
_root["m"+i]._y = 10+yPos;
yPos += 70;
_root["m"+i]._width = 50;
_root["m"+i]._height = 50;
_root["m"+i].preload("images/m"+i+".jpg", 40, 50, 50);
//loadimages
_root["m"+i].onPress = function() {
loadMovie(this._name+".jpg", _root.content_mc);
};
}
//i´m using this to attach an mc 8 timesto preload some images to it, but the press event dosen´t work. have I wroted a mistake, I can´t figure it out (preload is a proto) and he works fine, the error only occurs when i click each image, he says he dosen´t find the image
thanks
system
November 6, 2003, 6:33am
2
You’re surely assigning the [font=courier new]onPress[/font] event handler before the image has been loaded.
Post the code for the preload method.
system
November 6, 2003, 9:34am
3
MovieClip.prototype.preload = function(image, barWidth, imgWidth, imgHeight) {
// Set variables
var barWidth = barWidth == undefined ? 100 : barWidth;
var imgWidth = imgWidth == undefined ? 0 : imgWidth;
var imgHeight = imgHeight == undefined ? 0 : imgHeight;
// Create mc's
this.createEmptyMovieClip("PH_mc", 0);
this.createEmptyMovieClip("updater_mc", 1);
this.createEmptyMovieClip("bar_mc", 2);
this.createEmptyMovieClip("text_mc", 3);
// Scale bar
this.bar_mc._xscale = 1;
// Make preloader bar
with (this.bar_mc) {
beginFill(0xFF0000, 100);
lineTo(barWidth, 0);
lineTo(barWidth, 1);
lineTo(0, 1);
lineTo(0, 0);
}
// Text format
this.format = new TextFormat("Arial", 10, 0xFFFFFF, false, false, false, null, null, "center");
// Make preloader text
with (this.text_mc) {
createTextField("preload_txt", 0, 0, 0, barWidth, 0);
with (preload_txt) {
setNewTextFormat(this.format);
border = true;
borderColor = 0xFFFFFF;
text = " ";
selectable = false;
}
}
// Set bar mc and text mc dimensions position
this.text_Height = this.text_mc.preload_txt.textHeight+2;
this.text_mc.preload_txt._height = this.text_Height;
this.bar_mc._height = this.text_Height;
// Set bar mc and text mc positions
if (imgWidth != 0) {
this.bar_mc._x = this.text_mc._x=imgWidth/2-barWidth/2;
}
if (imgHeight != 0) {
this.text_mc._y = imgHeight/2-this.text_mc._height/2;
this.bar_mc._y = imgHeight/2-this.bar_mc._height/2+1;
}
// Load image
this.PH_mc.loadMovie(image);
// Get updater running
this.updater_mc.onEnterFrame = function() {
this.Loaded = this._parent.PH_mc.getBytesLoaded();
this.Total = this._parent.PH_mc.getBytesTotal();
this.Percent = Math.ceil((this.Loaded/this.Total)*100);
if (this.Loaded != this.Total || this.Total<=0) {
this.Percent = this.Total == 0 ? 0 : this.Percent;
this._parent.text_mc.preload_txt.text = this.Percent+"%";
this._parent.bar_mc._xscale = this.Percent;
trace(this.Percent+" %");
} else {
this._parent.text_mc.preload_txt.text = this.Percent+"%";
this._parent.bar_mc._xscale = this.Percent;
delete this.onEnterFrame;
this._parent.bar_mc.removeMovieClip();
this._parent.text_mc.removeMovieClip();
this.removeMovieClip();
}
};
};
///////////////////thanks for helping
system
November 6, 2003, 10:15am
4
Ok… that’s weird. :-\
The code seems to be fine, it shouldn’t mess up the event the handler. Have you tried a [font=courier new]trace()[/font] to check if the event handler is being called?
_root["m"+i].onPress = function() {
trace(this._name);
loadMovie(this._name+".jpg", _root.content_mc);
};
PS. I edited your post. Next time, please use the ActionScript tag [AS][ /AS] to show your code.
system
November 7, 2003, 7:36am
5
hi
dosen´t work, i really don´t understand why is this, do you know a other preload proto whit alpha maybe
system
November 7, 2003, 7:54am
6
Why don’t you attach your FLA? It would make things easier for me.
And by alpha … do you mean to fade in the image?