# Mc.OnRelease not working

**URL:** <https://forum.kirupa.com/t/mc-onrelease-not-working/183618>\
**Category:** Uncategorized\
**Created:** [March 28, 2006, 9:31pm UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618 "2006-03-28T21:31:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [March 28, 2006, 9:31pm UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/1 "2006-03-28T21:31:40Z")

</div>

Im having problems when loading a movieClip into an empty container, I can’t access the onRelease event. For example:

```auto
 
t1.onRelease = function() {
 currentPic ='products/pro/mainImage.jpg';
 cMC.loadPic(currentPic);
};
 
MovieClip.prototype.loadPic = function(pic) {
 
 this.loadMovie(pic);

**//not working**
** this.onRelease = function(){
  this.unloadMovie(pic);
 }**
}

```

Any ideas??  
Thanks

Daniel

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [March 28, 2006, 9:37pm UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/2 "2006-03-28T21:37:45Z")

</div>

> [@rollwithit80](#):
>
> Im having problems when loading a movieClip into an empty container, I can’t access the onRelease event. For example:
> 
> ```auto
>  
> t1.onRelease = function() {
> currentPic ='products/pro/mainImage.jpg';
> cMC.loadPic(currentPic);
> };
>  
> MovieClip.prototype.loadPic = function(pic) {
>  
> this.loadMovie(pic);
> 
> **//not working**
> ** this.onRelease = function(){
> this.unloadMovie(pic);
> }**
> }
> 
> ```
> 
> Any ideas??  
> Thanks
> 
> Daniel

so you just can’t get the onRelease to work? because if its in another contrainer you scope is wrong you would need containName.mc.onRelease=function()

---

<div class="post-metadata">

**Author:** ![serkios](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/serkios/32/608_2.png) [@serkios](https://forum.kirupa.com/u/serkios)\
**Post date:** [March 28, 2006, 11:15pm UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/3 "2006-03-28T23:15:57Z")

</div>

You cannot assign onRelease functions to a clip you just loaded. The load command, which is \*\*not \*\*necessarily performed immediatley after the loadMovie() method is invoked, rewrites all methods and properties of the clip receiving the load. So a work around is something like

```
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR] = [COLOR=#000000] **function** [/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]

```

[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#808080]_// do stuff_[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#0000FF]delete[/COLOR] [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

---

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [March 29, 2006, 10:08pm UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/4 "2006-03-29T22:08:34Z")

</div>

Hi, I have attached a sample of what i am trying to acheive. So when you click on the main image it hides it, but the onRelease event still not working.

Thanks;)

---

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [March 30, 2006, 5:55am UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/5 "2006-03-30T05:55:29Z")

</div>

been on it all day, its doing my head in… should be basic huh??  
ahhhh:krazy: :krazy:

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [March 30, 2006, 6:54am UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/6 "2006-03-30T06:54:38Z")

</div>

```auto
t1.onRelease = function() {
	currentPic = 'products/pro/mainImage.jpg';
	cMC.loadPic(currentPic);
};
MovieClip.prototype.loadPic = function(pic) {
	this.loadMovie(pic);
	var clip = this;
	var temp = this._parent.createEmptyMovieClip("temp", 9978);
	temp.onEnterFrame = function() {
		if (clip._width) {
			clip.onRelease = function() {
				this.unloadMovie();
			};
			delete this.onEnterFrame;
		}
	};
};

```

scotty(-:

---

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [March 30, 2006, 8:41am UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/7 "2006-03-30T08:41:34Z")

</div>

thanks a million, i think i was going the wrong way about it. Works smooth…  
You are the king…:king: :king:

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [March 30, 2006, 9:46am UTC](https://forum.kirupa.com/t/mc-onrelease-not-working/183618/8 "2006-03-30T09:46:47Z")

</div>

no problem =)
