Hey all… I’m trying to make a tab system and I’m having a problem with clicking on one tab, and then having that tab call a function that resets the appearance of any other tabs that are “on” to “off” Here is basically what I have here:
It all works, but I don’t know how to have All instances of the Tabclass respond to the RESET_BUTTON event. I can’t seem to figure out how to address the displayList or???
Thanks in Advance!
C
Tabclass.as
package com.mysite.testing {
import com.mysite.testing.DisplayContent;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.text.TextFormatAlign;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.events.*;
public class TabClass extends Sprite{
private var _totalTabs:Number;
public function TabClass(pos:Number, totalTabs:Number):void {
_totalTabs = totalTabs;
var dataLoader:Sprite = new Sprite();
dataLoader.name = "dl"+pos;
if(pos==0){
dataLoader.graphics.lineStyle(1, 0xcccccc, 1, true);
dataLoader.graphics.beginFill(0xcccccc, 1);
}
else{
dataLoader.graphics.lineStyle(1, 0xa9a9a9, 1, true);
dataLoader.graphics.beginFill(0xa5a5a5, 1);
}
dataLoader.graphics.drawRect(0, 0, 114, 23);
dataLoader.graphics.endFill();
dataLoader.addEventListener(MouseEvent.CLICK, clickMe);
dataLoader.addEventListener(ResetButtonEvent.RESET_BUTTON, buttonReset);
var boxName:TextField = new TextField();
boxName.text = "Testing";
boxName.width = 110;
boxName.height = 25;
boxName.mouseEnabled = false;
boxName.wordWrap = true;
var boxNameFormat:TextFormat = new TextFormat("Trebuchet MS", 11, 0xffffff, true, null, null, null, null, TextFormatAlign.CENTER);
boxName.setTextFormat(boxNameFormat);
dataLoader.mouseEnabled = true;
dataLoader.buttonMode = true;
trace("TabClass working");
var displayContent:DisplayContent = new DisplayContent(10);
dataLoader.addChild(boxName);
addChild(dataLoader);
}
private function clickMe(evt:MouseEvent):void{
evt.target.dispatchEvent(new ResetButtonEvent());
evt.target.graphics.clear();
evt.target.graphics.lineStyle(2, 0xCCCCCC, 1, true);
evt.target.graphics.beginFill(0xCCCCCC, 1);
evt.target.graphics.drawRect(0, 0, 114, 23);
evt.target.graphics.endFill();
}
private function buttonReset(evt:ResetButtonEvent):void{
trace("halp");
}
}
}
ResetButtonEvent.as
package com.mysite.testing{
import flash.events.*;
public class ResetButtonEvent extends Event{
public static const RESET_BUTTON = "resetButton";
public function ResetButtonEvent():void{
super(RESET_BUTTON);
}
}
}