# Help with createEmptyMovieClip \[Flash MX 2004 - AS\]

**URL:** <https://forum.kirupa.com/t/help-with-createemptymovieclip-flash-mx-2004-as/184738>\
**Category:** flash\
**Created:** [April 7, 2006, 11:02am UTC](https://forum.kirupa.com/t/help-with-createemptymovieclip-flash-mx-2004-as/184738 "2006-04-07T11:02:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GormDraig](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@GormDraig](https://forum.kirupa.com/u/GormDraig)\
**Post date:** [April 7, 2006, 11:02am UTC](https://forum.kirupa.com/t/help-with-createemptymovieclip-flash-mx-2004-as/184738/1 "2006-04-07T11:02:24Z")

</div>

[SIZE=1]Hey there this is my first post/thread on the message board. As you can see I did read the ‘Please read before posting’ thread beforehand ;P[/SIZE]

[SIZE=1]My problem is that I can’t understand how to use:[/SIZE]

[SIZE=1]‘**createEmptyMovieClip()**’[/SIZE]

[SIZE=1]No matter what source I research it from and I would appreciate if anyone had a clearer description/definition for the code.[/SIZE]  
[SIZE=1]I am needing help on this for creating a character that runs left and right for a game I am making.[/SIZE]  
[SIZE=1]So far I have made the character run left and right using the arrow keys [Which, may I add, I am proud of achieving] but the problem lies within what happens when I press left or right. If I press left or right the character goes in that direction and shows the mc of the character running in that direction and moves along with but although I have managed to do this, the static mc of the character can still be seen behind the new mc of the character running in the direction. I dont want that happening.[/SIZE]

[SIZE=1]Any help would be appreciated greatly, if you need to see the code I have created so far to make the character move and stuff then just ask and I shall post it up.[/SIZE]

[SIZE=1] **P.S.** Anyone know which books are best for ActionScript reference and/or tutorials/examples [I already have the Colin Moock book for ActionScript reference][/SIZE]

[SIZE=1]Thanx[/SIZE]

---

<div class="post-metadata">

**Author:** ![pointer](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@pointer](https://forum.kirupa.com/u/pointer)\
**Post date:** [April 7, 2006, 11:16am UTC](https://forum.kirupa.com/t/help-with-createemptymovieclip-flash-mx-2004-as/184738/2 "2006-04-07T11:16:03Z")

</div>

```auto

var container:MovieClip = this.createEmptyMovieClip("container", 1);

```

```auto
 this.createEmtpyMovieClip ("name_RefMC", 1);

```

where 1 is the depth.

---

<div class="post-metadata">

**Author:** ![GormDraig](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@GormDraig](https://forum.kirupa.com/u/GormDraig)\
**Post date:** [April 7, 2006, 12:29pm UTC](https://forum.kirupa.com/t/help-with-createemptymovieclip-flash-mx-2004-as/184738/3 "2006-04-07T12:29:38Z")

</div>

[SIZE=1]I know the basic structure of that code [Plus what you’ve said Pointer is exactly what everything else says really, but thanx all the same] I’m looking to HIDE the original mc but still show the new mc on top. Again if you need the code to see what I am on about using it for then just ask.[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]In fact here is the code I have so far:[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]

```auto
 [/SIZE]
[SIZE=1]onClipEvent(keyDown) {[/SIZE]
[SIZE=1] if(Key.isDown(Key.RIGHT)) {[/SIZE]
[SIZE=1] this.attachMovie("gerry_right", "gerryright", 5);[/SIZE]
[SIZE=1] this._x = this._x +10;[/SIZE]
[SIZE=1] }[/SIZE]
[SIZE=1]}[/SIZE]
[SIZE=1]onClipEvent(keyUp) {[/SIZE]
[SIZE=1] if(Key.getCode) {[/SIZE]
[SIZE=1] removeMovieClip(gerryright);[/SIZE]
[SIZE=1] }[/SIZE]
[SIZE=1]}[/SIZE]
[SIZE=1]

```

[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]Where ‘gerry\_right’ is the mc of the character that runs right and ‘this’ is the mc already on the stage [Which is the static character].[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]Im looking to make the static character go invisible or disappear while the key **RIGHT** is pressed down and then reappear once it is released.[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]And would I use **createEmptyMovieClip()** during any of that code to make it work the way im trying to explain it?[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]Sorry if my first post was confusing.[/SIZE]

---

<div class="post-metadata">

**Author:** ![pointer](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@pointer](https://forum.kirupa.com/u/pointer)\
**Post date:** [April 7, 2006, 12:52pm UTC](https://forum.kirupa.com/t/help-with-createemptymovieclip-flash-mx-2004-as/184738/4 "2006-04-07T12:52:59Z")

</div>

i am not into onClipEvent(-etc-)  
Never put code on the mc’s  
But give this a try.

in keyframe1:

```auto

onClipEvent (load) {
this.attachMovie("gerry_right", "gerryright", 5);
gerry_right._x = 10;
gerry_right._visible = false;
}

onClipEvent (keyDown) {
    if (Key.getCode() == Key.RIGHT) {
        _root.gerry_right._visible = true;

    } else if (Key.getCode() == Key.UP) {
         _root.gerry_right._visible = false;
    }
}

```

---

<div class="post-metadata">

**Author:** ![GormDraig](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@GormDraig](https://forum.kirupa.com/u/GormDraig)\
**Post date:** [April 7, 2006, 2:19pm UTC](https://forum.kirupa.com/t/help-with-createemptymovieclip-flash-mx-2004-as/184738/5 "2006-04-07T14:19:22Z")

</div>

[SIZE=1]The code looks good, but it doesn’t work unless its on a mc because its a \*\*‘clipEvent’ \*\*so the load thing makes both mc’s happen at once from loading. I tried putting it onto the mc too and same thing happened.[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]Or did you mean the first keyframe WITHIN the ‘gerry\_right’ mc?[/SIZE]
