# MovieClip.onPress only executes createEmptyMovieClip once?!

**URL:** <https://forum.kirupa.com/t/movieclip-onpress-only-executes-createemptymovieclip-once/245064>\
**Category:** flash\
**Created:** [November 26, 2007, 2:12am UTC](https://forum.kirupa.com/t/movieclip-onpress-only-executes-createemptymovieclip-once/245064 "2007-11-26T02:12:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slade86](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@slade86](https://forum.kirupa.com/u/slade86)\
**Post date:** [November 26, 2007, 2:12am UTC](https://forum.kirupa.com/t/movieclip-onpress-only-executes-createemptymovieclip-once/245064/1 "2007-11-26T02:12:22Z")

</div>

Now, this is really strange… Is there a difference between onPress behaviour of a Button Symbol and a MovieClip?

I wrote this function, which was becoming to be the host of a loop, which would dynamically add items to my submenu, but, a very strange thing happened. menubutton1 is a movieclip, if i leave it this way, my object “submenu1” will be removed, when i invoke the creation of a second emptyMovieClip (the trace before the second “createEmptyMovieClip” would give me the coordinate and the trace after the “createEmptyMovieClip” returns “undefined” ) --\> but if i make menubutton1 a button, it works perfectly fine, now my problem is that menubutton1-n are created dynamically in actionscript and therefor are MovieClips and MovieClips only (except if there may be a trick, to create an alpha=0 Button on the fly, which i could lay over my actual MovieClip Button - But I doubt that)

well here’s the code:

function loadentries(num, submenu\_height, submenu\_scrollstep)  
{

```
eval("menubutton" + num).onRelease = function() 
{
	
	newmenubutton_name = "menubutton" + num;
	submenu = "submenu" + num;
	
        eval(newmenubutton_name)._x = menubutton_x;
	eval(newmenubutton_name)._y = menubutton_y;
	
	createEmptyMovieClip(submenu,this.getNextHighestDe pth());
	eval(submenu)._x = eval(newmenubutton_name)._x;
	eval(submenu)._y = eval(newmenubutton_name)._y;
	
	count = 1;
	// arrow up
	newsubmenuitem = "submenuitem" + count;
	eval(submenu).attachMovie("DropDown_SubMenuBG",new submenuitem,this.getNextHighestDepth());
	eval(submenu)[newsubmenuitem]._width = eval(newmenubutton_name)[newmenubutton_name]._width-10;
	eval(submenu)[newsubmenuitem]._height = submenu_height;
	eval(submenu)[newsubmenuitem]._x = 5;
	eval(submenu)[newsubmenuitem]._y += 7;
	
	eval(submenu)[newsubmenuitem].createEmptyMovieClip("labelholder", this.getNextHighestDepth());
	eval(submenu)[newsubmenuitem].labelholder.createTextField("arrowup", this.getNextHighestDepth(), 0, -2.5, 20, submenu_height);
	myformat = new TextFormat();
	myformat.size = "8";
	myformat.font = "Arial";
	eval(submenu)[newsubmenuitem].labelholder.arrowup.text = "back up again";
	eval(submenu)[newsubmenuitem].labelholder.arrowup.setTextFormat(myformat);
	count++;
	

	trace(submenu1._y);
	submenu = "submenu2";
	createEmptyMovieClip(submenu,this.getNextHighestDe pth());
	trace(submenu1._y);

	
	switch(num)
	{
	case 1:
	trace("entry1");
	trace(submenu_height);
	
	break;
	case 2:
	trace("entry2");
	trace(submenu_height);
	break;
	}

}

```

}

if you want to test this code:  
create at least one menu button (MovieClip), called menubutton1.  
create a button, called tracer, to test if submenu1 is still there

then add this to the bottom of the code

loadentries(1, 50, 5);

tracer.onPress = function()  
{  
trace(submenu1.\_y);  
}
