# Fmx error

**URL:** <https://forum.kirupa.com/t/fmx-error/34745>\
**Category:** Uncategorized\
**Created:** [November 6, 2003, 12:01am UTC](https://forum.kirupa.com/t/fmx-error/34745 "2003-11-06T00:01:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aquaman](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@aquaman](https://forum.kirupa.com/u/aquaman)\
**Post date:** [November 6, 2003, 12:01am UTC](https://forum.kirupa.com/t/fmx-error/34745/1 "2003-11-06T00:01:20Z")

</div>

can someone please tell me what i´m making wrong:

```auto
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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2003, 6:33am UTC](https://forum.kirupa.com/t/fmx-error/34745/2 "2003-11-06T06:33:35Z")

</div>

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. 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2003, 9:34am UTC](https://forum.kirupa.com/t/fmx-error/34745/3 "2003-11-06T09:34:47Z")

</div>

```auto
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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2003, 10:15am UTC](https://forum.kirupa.com/t/fmx-error/34745/4 "2003-11-06T10:15:45Z")

</div>

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?

```auto
_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. 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 7, 2003, 7:36am UTC](https://forum.kirupa.com/t/fmx-error/34745/5 "2003-11-07T07:36:50Z")

</div>

hi  
dosen´t work, i really don´t understand why is this, do you know a other preload proto whit alpha maybe

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 7, 2003, 7:54am UTC](https://forum.kirupa.com/t/fmx-error/34745/6 "2003-11-07T07:54:36Z")

</div>

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?
