Though I gave you the previous solution, this is more right approach to do what you are trying:
Document Class
PHP Code:
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import classes.*;
public class DocClass extends MovieClip {
public static const TotalTabs:Number = 3;
public static const isLinear:Boolean = false;
public var controller:ClickTabLogic;
private var tabsList:Array;
public function DocClass():void {
tabsList=new Array(tab1,tab2,tab3);
controller = new ClickTabLogic(this);
for (var i=0; i<tabsList.length; i++) {
tabsList[i].addEventListener(MouseEvent.CLICK,tabClicked);
}
}
private function tabClicked(evt:MouseEvent):void {
controller.setTab(evt);
}
}
}
Base Class which attached with the Button Symbols
PHP Code:
package classes{
import flash.display.MovieClip;
public class ActiveButton extends MovieClip {
public function ActiveButton() {
this.gotoAndStop("active");
}
}
}
This Class is listening whenever events are dispatches
PHP Code:
package classes{
import flash.display.MovieClip;
import flash.events.Event;
import flash.text.TextField;
public class ClickTabLogic extends MovieClip {
public var tabs:ClickTabs;
private var target;
public function ClickTabLogic(target):void {
this.target=target;
trace("Waiting here for the custom event");
tabs=new ClickTabs();
tabs.addEventListener(ClickTabEvent.ON_TAB_CLICK,fnShowPopup);
}
private function fnShowPopup(evt:ClickTabEvent):void {
target.txt.text=(evt.target.tabName);
}
public function setTab(evt) {
tabs.clickedListener=(evt);
}
}
}
This Class is despatching event
PHP Code:
package classes{
import flash.display.MovieClip;
import flash.events.Event;
public class ClickTabs extends MovieClip {
private var tabClickedEvent:ClickTabEvent;
public var tabName;
public function ClickTabs() {
}
public function set clickedListener(evt):void {
tabName=evt.target.parent.name;
tabClickedEvent = new ClickTabEvent(ClickTabEvent.ON_TAB_CLICK);
trace("Event is created but dispatch code below does not fires");
dispatchEvent(tabClickedEvent);
}
}
}
This is the constant Class which extends Event Class
PHP Code:
package classes{
import flash.display.MovieClip;
import flash.events.Event;
public class ClickTabEvent extends Event {
public static const ON_TAB_CLICK:String = "onTabClick";
public function ClickTabEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false):void {
super(type, bubbles, cancelable);
}
}
}
There are many approaches on dispatching and listening custom events, but out of all there are two type of methods of doing those. Those are push and pull methods. The previous solution I shown you was a dirty way. This is a push method and is more flexible for oop programming.
Try to go through the code, If you still fail to understand how it works, just let me know, I'll try to explain in detail of both the solutions and there dependencies in programming structure.
Regards