Hi every one, yes i am finally on AS3 and for good now, so this is my question.
I have created a SelectionSystem class that creates instences of a UIButton class and place them one after an other horizontaly.
My button MC has a hitZone and a titleMc Movieclips.
Every thing is working up to that point, the issues arise with "inheritance" form when i tried to create the VerticalMenu classes that is supposed to extends UIButton
and overright the function setPosition() to place the button in a vertical manner. i am getting this: "1120: Access of undefined property hitZone.", "1120: Access of undefined property titleMC."
now that in the linkage box of my Button i have put VerticalMenu it doesn't find hitZone or titleMc.
I have flipped every witch way i just cant figure it out, some help would be grealy apreciated as i am just stating on my AS3 journey

...
my Classes:
Code:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class UIButton extends MovieClip
{
public var id:uint;
private var visited:Boolean;
private var selected:Boolean;
//public var hitZone:MovieClip;
//public var titleMc:MovieClip;
public function UIButton()
{
//initMouseEvents();
}
public function Init(_systemData:Object, _id:Number)
{
id = _id;
setTitle(_systemData.Title);
setPosition();
//trace(2);
}
//MouseInit
private function initMouseEvents()
{
//var hitZone:MovieClip;
hitZone.addEventListener(MouseEvent.MOUSE_DOWN, handleDown);
hitZone.addEventListener(MouseEvent.MOUSE_UP, handleUp);
hitZone.addEventListener(MouseEvent.MOUSE_OVER, handleOver);
hitZone.addEventListener(MouseEvent.MOUSE_OUT, handleOut);
//hitZone.addEventListener(MouseEvent.CLICK, handleClick);
hitZone.buttonMode = true;
}
private function removeMouseEvents()
{
//var hitZone:MovieClip;
hitZone.removeEventListener(MouseEvent.MOUSE_DOWN, handleDown);
hitZone.removeEventListener(MouseEvent.MOUSE_UP, handleUp);
hitZone.removeEventListener(MouseEvent.MOUSE_OVER, handleOver);
hitZone.removeEventListener(MouseEvent.MOUSE_OUT, handleOut);
//hitZone.removeEventListener(MouseEvent.CLICK, handleClick);
hitZone.buttonMode = false;
}
//set
private function setTitle(_title:String)
{
//var titleMc:MovieClip;
titleMc.titleTxt.text = _title;
}
private function setPosition()
{
this.x = (this.width + 2)*id;
}
//handle
private function handleOver(event:MouseEvent):void
{
MouseRollOver();
}
private function handleOut(event:MouseEvent):void
{
MouseRollOut();
}
private function handleDown(event:MouseEvent)
{
MouseDown();
}
private function handleUp(event:MouseEvent)
{
MouseUp();
}
private function handleClick(event:MouseEvent)
{
//
}
//select
public function setSelected()
{
visited = selected = true;
this.gotoAndPlay("over");
removeMouseEvents();
}
public function setUnselected()
{
selected = false;
initMouseEvents();
MouseRollOut();
}
//goto
private function MouseRollOver()
{
this.gotoAndPlay("over");
}
private function MouseDown()
{
this.gotoAndStop("down");
}
private function MouseUp()
{
this.gotoAndStop("up");
}
private function MouseRollOut()
{
if (visited)
{
this.gotoAndPlay("visited");
}
else
{
this.gotoAndPlay("out");
}
}
}
}
//-------------------------------
package
{
import UIButton;
class VerticalMenu extends UIButton
{
//public var hitZone:MovieClip;
public function VerticalMenu(){}
private function setPosition()
{
//this.x = (this.height + 10)*id;
}
}
}
//---------------------------------
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class SelectionSystem extends MovieClip
{
private var systemData:Array;
private var currentSelection:Number;
private var listItems:Array;
public function SelectionSystem()
{
}
public function Init(_systemData:Array)
{
listItems = new Array();
systemData = _systemData;
Render();
}
private function Render()
{
for (var i:uint=0; i<5; i++)
{
var item:MovieClip = new VerticalMenu;
item.Inito(systemData[i], i);
item.name = "btn" + i;
item.addEventListener(MouseEvent.CLICK, handleClick);
addChild(item);
listItems.push(item);
}
}
private function handleClick(event:MouseEvent)
{
var id:uint = event.currentTarget.id;
setSelection(id);
doAction();
}
public function setSelection(_id:uint)
{
if (currentSelection != _id)
{
if (!isNaN(currentSelection))
{
listItems[currentSelection].setUnselected();
}
currentSelection = _id;
listItems[currentSelection].setSelected();
}
}
private function doAction(){
//trace(systemData[currentSelection].Url);
}
}
}
//---------------------------
var menuData:Array = new Array();
menuData = [
{Title:"Btn 1", Url:"0"},
{Title:"Btn 2", Url:"1"},
{Title:"Btn 3", Url:"2"},
{Title:"Btn 4", Url:"3"},
{Title:"Btn 5", Url:"4"}
];
btnMenu.Init(menuData);
//btnMenu.setSelection(2);
//----------------