Hey all,
I have created the following code to place several instances of a MovieClip in my library on the stage and give each of them a name and label for use as navigation. What I would like to do is assign each instance a unique instance name and attach a function to it. Most of this code is working, when it is run it creates the instances and assigns them names and when I click on each instance, the trace function returns the unique names I assigned them. However, when I try to attach a function to the instance, Flash does not recognize it by name, and I get the decompiler error “Access of undefined property LinksBtn_mc” Any ideas guys?
Thanks in advance
-Aaron
var navName:Array = ["Home", "About", "Services", "Portfolio", "Contact", "Links"];
var _navBtn:navBtn;
var _navBtnX:Number;
var _navBtnY:Number;
stage.addEventListener(Event.ENTER_FRAME, createNav);
function createNav(EVENT):void
{
_navBtnX = 50;
_navBtnY = 10;
for (var i:Number = 0; i < navName.length; i++) {
_navBtn = new navBtn();
addChild(_navBtn);
_navBtn.x = _navBtnX;
_navBtn.y = _navBtnY;
_navBtnX += _navBtn.width + 2;
_navBtn.navLabel_txt.text = navName*;
_navBtn.name = navName* + "Btn_mc";
_navBtn.addEventListener(MouseEvent.CLICK, checkName);
stage.removeEventListener(Event.ENTER_FRAME, createNav);
}
}
function checkName(event:MouseEvent):void
{
trace (event.target.name);
LinksBtn_mc.addEventListener(MouseEvent.CLICK, runMe);
}
function runMe(event:MouseEvent):void
{
trace ("WTF");
}