First of all, hello all, this is my 1st post here, so I’d like to take the opportunity to greet you all.
Now,
I got this class desat.menus.HorizontalMenu
I want to make an instance of this class in a fla-file, but I get the following runtime error:
TypeError: Error #1010: A term is undefined and has no properties.
at desat.menus::HorizontalMenu$iinit()
at fcms_fla::MainTimeline/fcms_fla::frame1()
The forum search nor google gave me a solution for this.
This is my code
FLA-file
import desat.menus.HorizontalMenu;
var arr:Array = new Array();
arr.push("home");
arr.push("news");
var $root:MovieClip = this;
var menu:HorizontalMenu = new HorizontalMenu($root, arr, 10, 10 ,120);
HorizontalMenu.as (inside /desat/menus/ )
//******************************************************************************************
// HorizontalMenu class for FCMS.
//
// @author: Gerrit Bertier
// @contact: gerrit@tensixtytwo.com
// http://desaturated.be
//
// @properties: parentMovie (MovieClip) = the parent movie for the menu item
// menuText (Array) = the array containing the text for the items
// xpos (Number) = the x-position for the 1st menu item
// ypos (Number) = the y-position for the 1st menu item
// itemWidth (Number) = the width of a menu item (default: 120)
//
//******************************************************************************************
package desat.menus {
// Imports
import flash.display.MovieClip;
import flash.text.TextFormat;
import flash.text.TextField;
//
public class HorizontalMenu {
// Properties
var _parentMovie:MovieClip;
var _menuText:Array = new Array();
var _xpos:Number = 0;
var _ypos:Number = 0;
var _itemWidth:Number = 120;
//
// Getters & setters
public function get parentMovie():MovieClip {
return this._parentMovie;
}
public function set parentMovie(newValue:MovieClip):void {
this._parentMovie = newValue;
}
public function get MenuText():Array {
return this._menuText;
}
public function set MenuText(newValue:Array):void {
this._menuText = newValue;
}
public function get xpos():Number {
return this._xpos;
}
public function set xpos(newValue:Number):void {
this._xpos = newValue;
}
public function get ypos():Number {
return this._ypos;
}
public function set ypos(newValue:Number):void {
this._ypos = newValue;
}
public function get itemWidth():Number {
return this._itemWidth;
}
public function set itemWidth(newValue:Number):void {
this._itemWidth = newValue;
}
// Methods
function HorizontalMenu(parentMovie:MovieClip, menuText:Array, xpos:Number, ypos:Number, itemWidth:Number = 120):void {
_parentMovie = parentMovie;
_menuText = menuText;
_xpos = xpos;
_ypos = ypos;
_itemWidth = itemWidth;
// Text formats for the menu items
var tfmt_normal:TextFormat = new TextFormat();
tfmt_normal.align = "center";
tfmt_normal.color = 0x333333;
tfmt_normal.font = "Trebuchet MS";
tfmt_normal.size = 11;
var tfmt_hover:TextFormat = new TextFormat();
tfmt_hover.align = "center";
tfmt_hover.color = 0x666666;
tfmt_hover.font = "Trebuchet MS";
tfmt_hover.size = 11;
// Creating a movie clip and the textfield withing that movieclip for each menu item
for (var i = 0; i < _menuText.length; i++) {
var my_mc:MovieClip = new MovieClip();
my_mc.name = "menuitem"+i+"_mc";
var menu_txt:TextField = new TextField();
menu_txt.name = "menuitem_txt";
my_mc.addChild(menu_txt);
_parentMovie.addChild(my_mc);
my_mc.menuitem_txt.mouseEnabled = false;
my_mc.menuitem_txt.setTextFormat(tfmt_normal);
my_mc.menuitem_txt.text = _menuText*;
}
}
}
}
Any experiences or help with this would be greatly appreciated, as I’m really stuck here.
Edit: I narrowed down the problem and found it is somewhere inside the for-block.