when pressing on a button that error comes up in the OUTPUT tab
the file is in the link
This is the navigation_actions code where are the codes of the navigation bar (the buttons)
var buttonArray:Array = new Array( );
var currentButton:Object = new Object;
var navContainer:Sprite=new Sprite ;
addChild(navContainer);
var navArray:Array=["من نحن","المحتوى","المراجع","التواصل", "خريطة الموقع"];
for (var i:Number=0; i<5; i++) {
var navItem:NavItem = new NavItem;
navItem.x = navItem.width*i;
navItem.nav_name.text = navArray[i];
buttonArray.push(navItem);
navItem.addListeners();
navContainer.addChild(navItem);
navItem.name = String(i);
navItem.addEventListener(MouseEvent.CLICK, onNavClick);
}
function onNavClick(evt:MouseEvent):void {
currentButton.y = 0;
currentButton.addListeners();
currentButton.addEventListener(MouseEvent.CLICK, onNavClick);
currentButton = evt.target;
currentButton.removeListeners();
currentButton.removeEventListener(MouseEvent.CLICK, onNavClick);
}
initialNavigation();
function initialNavigation():void {
buttonArray[0].y = -10;
currentButton = buttonArray[0];
currentButton.removeListeners();
currentButton.removeEventListener(MouseEvent.CLICK, onNavClick);
}
var navSide:NavSide = new NavSide;
navSide.x = navContainer.width;
navSide.width = stage.stageWidth - navContainer.width;
navSide.alpha = 0.7;
navContainer.addChild(navSide);
navContainer.y = stage.stageHeight-67; }
and this is the navItem actions (the buttons it self)
import com.greensock.TweenLite;
nav_name.autoSize=TextFieldAutoSize.LEFT;
nav_name.selectable=false;
nav_name.x=170-nav_name.width+25;
function onOver(evt:MouseEvent):void {
TweenLite.to(this, 0.4, { y:-10});
}
function onOut(evt:MouseEvent):void {
TweenLite.to(this, 0.4, { y:0});
}
function addListeners():void {
this.addEventListener(MouseEvent.ROLL_OVER, onOver);
this.addEventListener(MouseEvent.ROLL_OUT, onOut);
}
function removeListeners():void {
this.removeEventListener(MouseEvent.ROLL_OVER, onOver);
this.removeEventListener(MouseEvent.ROLL_OUT, onOut);
}
I downloaded your file and from what I can tell you added a listener to your NavItem instance but the actual event comes from its child. That’s why
event.targetis not equal to a NavItem.Either use
event.currentTargetor addnavItem.mouseChildren = false;so NavItem’s children will not grab clicks.Next time please post code.