home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Canadian Forces: Prepare for Takeoff as a Pilot
/
CF_FS_Air.iso.iso
/
pc
/
data
/
swf
/
flashpaper
/
103.swf
/
scripts
/
MUIComponentSymbol.as
< prev
Wrap
Text File
|
2004-06-30
|
5KB
|
166 lines
function MUIComponentClass()
{
this.init();
}
MUIComponentClass.prototype = new MovieClip();
MUIComponentClass.prototype.init = function()
{
this.enable = true;
this.focused = false;
this.useHandCursor = false;
this._accImpl = new Object();
this._accImpl.stub = true;
this.styleTable = new Array();
if(_global.globalStyleFormat == undefined)
{
_global.globalStyleFormat = new MStyleFormat();
globalStyleFormat.isGlobal = true;
_global._focusControl = new Object();
_global._focusControl.onSetFocus = function(oldFocus, newFocus)
{
oldFocus.myOnKillFocus();
newFocus.myOnSetFocus();
};
Selection.addListener(_global._focusControl);
}
if(this._name != undefined)
{
this._focusrect = false;
this.tabEnabled = true;
this.focusEnabled = true;
this.tabChildren = false;
this.tabFocused = true;
if(this.hostStyle == undefined)
{
globalStyleFormat.addListener(this);
}
else
{
this.styleTable = this.hostStyle;
}
this.deadPreview._visible = false;
this.deadPreview._width = this.deadPreview._height = 1;
this.methodTable = new Object();
this.keyListener = new Object();
this.keyListener.controller = this;
this.keyListener.onKeyDown = function()
{
this.controller.myOnKeyDown();
};
this.keyListener.onKeyUp = function()
{
this.controller.myOnKeyUp();
};
for(var i in this.styleFormat_prm)
{
this.setStyleProperty(i,this.styleFormat_prm[i]);
}
}
};
MUIComponentClass.prototype.setEnabled = function(enabledFlag)
{
this.enable = arguments.length <= 0 ? true : enabledFlag;
this.tabEnabled = this.focusEnabled = enabledFlag;
if(!this.enable && this.focused)
{
Selection.setFocus(undefined);
}
};
MUIComponentClass.prototype.getEnabled = function()
{
return this.enable;
};
MUIComponentClass.prototype.setSize = function(w, h)
{
this.width = w;
this.height = h;
this.focusRect.removeMovieClip();
};
MUIComponentClass.prototype.setChangeHandler = function(chng, obj)
{
this.handlerObj = obj != undefined ? obj : this._parent;
this.changeHandler = chng;
};
MUIComponentClass.prototype.invalidate = function(methodName)
{
this.methodTable[methodName] = true;
this.onEnterFrame = this.cleanUI;
};
MUIComponentClass.prototype.cleanUI = function()
{
if(this.methodTable.setSize)
{
this.setSize(this.width,this.height);
}
else
{
this.cleanUINotSize();
}
this.methodTable = new Object();
delete this.onEnterFrame;
};
MUIComponentClass.prototype.cleanUINotSize = function()
{
for(var funct in this.methodTable)
{
this[funct]();
}
};
MUIComponentClass.prototype.drawRect = function(x, y, w, h)
{
var inner = this.styleTable.focusRectInner.value;
var outer = this.styleTable.focusRectOuter.value;
if(inner == undefined)
{
inner = 16777215;
}
if(outer == undefined)
{
outer = 0;
}
this.createEmptyMovieClip("focusRect",1000);
this.focusRect.controller = this;
this.focusRect.lineStyle(1,outer);
this.focusRect.moveTo(x,y);
this.focusRect.lineTo(x + w,y);
this.focusRect.lineTo(x + w,y + h);
this.focusRect.lineTo(x,y + h);
this.focusRect.lineTo(x,y);
this.focusRect.lineStyle(1,inner);
this.focusRect.moveTo(x + 1,y + 1);
this.focusRect.lineTo(x + w - 1,y + 1);
this.focusRect.lineTo(x + w - 1,y + h - 1);
this.focusRect.lineTo(x + 1,y + h - 1);
this.focusRect.lineTo(x + 1,y + 1);
};
MUIComponentClass.prototype.pressFocus = function()
{
this.tabFocused = false;
this.focusRect.removeMovieClip();
Selection.setFocus(this);
};
MUIComponentClass.prototype.drawFocusRect = function()
{
this.drawRect(-2,-2,this.width + 4,this.height + 4);
};
MUIComponentClass.prototype.myOnSetFocus = function()
{
this.focused = true;
Key.addListener(this.keyListener);
if(this.tabFocused)
{
this.drawFocusRect();
}
};
MUIComponentClass.prototype.myOnKillFocus = function()
{
this.tabFocused = true;
this.focused = false;
this.focusRect.removeMovieClip();
Key.removeListener(this.keyListener);
};
MUIComponentClass.prototype.executeCallBack = function()
{
this.handlerObj[this.changeHandler](this);
};