# What's wrong with this code?

**URL:** https://forum.kirupa.com/t/whats-wrong-with-this-code/194525
**Category:** flash
**Created:** [July 24, 2006, 12:45pm UTC](https://forum.kirupa.com/t/whats-wrong-with-this-code/194525 "2006-07-24T12:45:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![romainechester](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@romainechester](https://forum.kirupa.com/u/romainechester)
#### Post date: [July 24, 2006, 12:45pm UTC](https://forum.kirupa.com/t/whats-wrong-with-this-code/194525/1 "2006-07-24T12:45:01Z")

</div>

I’m attaching a movie clip to \_root and giving that mc an onRelease code.  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#808080]_// I’ve made a box mc that’s well… a box. Linked to AS of course._[/COLOR]  
[COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“box”[/COLOR], [COLOR=#ff0000]“inst”[/COLOR], [COLOR=#000080]0[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#808080]_// This works…_[/COLOR]  
[COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]inst[/COLOR].[COLOR=#0000ff]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

Now… I try to attach an mc, this time from an external image file.  
1st code — doesn’t work  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#0000ff][COLOR=Gray]_// I attach an empty movie clip that’s in the library_[/COLOR]  
\_root[/COLOR].[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“empty”[/COLOR], [COLOR=#ff0000]“inst”[/COLOR], [COLOR=#000080]0[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000ff]loadMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“img/c1.png”[/COLOR], [COLOR=#ff0000]“inst”[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]inst[/COLOR].[COLOR=#0000ff]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

2nd code — still doesn’t work  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“inst”[/COLOR], [COLOR=#000080]0[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000ff]loadMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“img/c1.png”[/COLOR], [COLOR=#ff0000]“inst”[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]inst[/COLOR].[COLOR=#0000ff]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

What am I doing wrong here? Is there something that I need to additionally do?
