Just do it the same way you did it in AS2. In your code you are attaching a
movie and giving it a name of nomeMenu+i. Do the same for your AS3 code -
don't assign the value to a local variable. If you did that in the AS2 code,
you'd end up with the same issue.

Also, instead of removing the submenuitems as you did in AS2, just remove
the items from the display list. That way you don't have to create and
destroy the items everytime. You can create them once, and then add them or
remove them from the display list. It should make the process faster,
especially if you're using getDefinitionByName.

By the way, if you're know the class name in the function that you are using
getDefinitionByName and instantiating the class, why not just instantiate
the class? As in:

import FlashClasses.MenuItem;
...
[in your loop]
var instance:MenuItem = this[nomeMenu+j] = new MenuItem();


On 10 Apr 2007 09:18:43 -0700, herklano <[EMAIL PROTECTED]> wrote:

  i am migrating a project from AS2 to AS3 and had a dynamically built
menu and submenus like:

item1 | item2 | item3
subitem1-1 | subitem1-2 | subitem1-3

and i used the attachmovie to generate it and to get the main
movieclip from the library...

for (var i:Number=0; i < menuRecordSet.length; i++) {
attachMovie('mc_text', nomeMenu+i,
this.getNextHighestDepth(),{_x:mcXleft, _y:mcY});
}

i allready managed to make the items using the getDefinitionByName()
function, like this:

for (var j:Number = 1; j <=5; j++)
{
var classRef:Class = getDefinitionByName("FlashClasses.MenuItem") as
Class;
var instance:Object = new classRef();
addChild(instance)
instance.x = 100 + (j*12);
instance.y = 200;
}

and this works OK to create the submenuitems, but then i have to
remove them when i click on another menuitem and create the new
submenuitems.

then how do i reference to those instances of the class MenuItem if
they are automatically generated?

with attachmovie i had a different reference to each one of the
subitems and used that reference to remove them from stage and insert
them again.




--

Derek Vadneau

Reply via email to