Hey every one. I have been in the transition from AS2 to AS3 and have run into a little snag that I need help with for a project I’m working on. Without too much detail, all I want to do is create a pretty simple navigation.
In AS2 all I would do is something similar to:
var menu_obj:Object = new Object();
menu_obj.drop = new Array();
_root.createEmptyMovieClip("menu_mc", this.getNextHighestDepth());
for(var i:Number = 0; i < menuLen; i++){
menu_obj.drop* = menu_mc.createEmptyMovieClip("option_mc"+i, i);
menu_obj.drop*.link_url = curMenu*.attributes.url;
menu_obj.drop*.onRelease = menu_obj.drop*.onReleaseOutside = function(){
getURL(this.link_url);
};
};
So basically I’m trying to convert that into AS3, so that I create the navigation and am able to assign it attributes to use in an Event Handler. But I’m running into problems. If anyone could please help I would really appreciate it.
I’m not understanding how to create unique objects/sprites using * like I would before to be able to control each navigation element in a for loop.
I came up with something like this, but then got stuck:
var nav_obj:Object = new Object();
for(var i:uint; i < 4; i++){
nav_obj* = new Sprite();
nav_obj*.**property** = i; //I'm unable to figure out how to do this...
nav_obj*.graphics.beginFill();
...
nav_obj*.graphics.endFill();
nav_obj*.addEventListener(MouseEvent.CLICK, onButtonClick);
};
function onButtonClick(event:MouseEvent):void{
trace(event.target**.property**);
};
Thank you, so much, for your help.