home *** CD-ROM | disk | FTP | other *** search
- class application.screens.AbstractScreen extends MovieClip
- {
- var log;
- var configObj;
- var systemObj;
- var dataObj;
- var hasFocus;
- var controller;
- var focusBorder;
- var onRollOver;
- var onRollOut;
- var onPress;
- var IvId;
- var IvID;
- var onRelease;
- var onReleaseOutside;
- var tabId;
- var focusManager;
- var offset;
- var rootMC;
- function AbstractScreen()
- {
- super();
- this.log = application.debug.Logging.getInstance();
- this.log.addKey("abstractScreen",65535);
- }
- function setConfigProvider(configObj)
- {
- this.configObj = configObj;
- }
- function setSystemProvider(systemObj)
- {
- this.systemObj = systemObj;
- }
- function setDataObj(dataObj)
- {
- this.dataObj = dataObj;
- }
- function buildButton(mc)
- {
- this.log.showKeyedMessage("abstractScreen","buildButton " + mc);
- mc.enabled = true;
- mc.controller = this;
- mc.gotoAndStop(1);
- mc.focusManager = application.core.FocusManager.getInstance();
- mc.focusBorder = application.ui.FocusBorder.getInstance();
- mc.createEmptyMovieClip("rect",100);
- mc.rect._visible = false;
- mc.tabEnabled = false;
- mc.hasFocus = false;
- mc.onRollOver = function()
- {
- if(this.enabled && !this.hasFocus)
- {
- this.gotoAndStop(2);
- this.controller.onButtonRollOver(this);
- }
- };
- mc.onRollOut = function()
- {
- if(this.enabled && !this.hasFocus)
- {
- this.gotoAndStop(1);
- this.controller.onButtonRollOut(this);
- }
- };
- mc.onPress = function()
- {
- if(this.enabled)
- {
- this.gotoAndStop(3);
- this.controller.onButtonPress(this);
- }
- };
- mc.onRelease = function()
- {
- if(this.enabled)
- {
- application.core.FocusManager.getInstance().switchFocus(this);
- _global.SoundManager.playSound();
- this.gotoAndStop(2);
- this.controller.onButtonRelease(this);
- }
- };
- mc.onReleaseOutside = function()
- {
- if(this.enabled)
- {
- this.gotoAndStop(1);
- this.controller.onButtonReleaseOutside(this);
- }
- };
- mc.onDisable = function()
- {
- this.enabled = false;
- this.gotoAndStop(4);
- if(this.hasFocus)
- {
- this.hasFocus = false;
- this.focusBorder.hide();
- }
- this.controller.onButtonDisable(this);
- };
- mc.onEnable = function()
- {
- this.enabled = true;
- this.gotoAndStop(1);
- this.controller.onButtonEnable(this);
- };
- mc.onSetFocus = function()
- {
- this.onRollOver();
- this.hasFocus = true;
- this.focusBorder.showBorder(this);
- };
- mc.onKillFocus = function()
- {
- this.hasFocus = false;
- this.onRollOut();
- this.focusBorder.hide();
- };
- mc.onSelect = function()
- {
- this.onPress();
- if(this.IvId != undefined)
- {
- clearInterval(this.IvID);
- delete this.IvID;
- }
- this.IvID = setInterval(this,"onDeselect",100);
- };
- mc.onDeselect = function()
- {
- clearInterval(this.IvID);
- delete this.IvID;
- if(this.hasFocus)
- {
- this.onRelease();
- }
- else
- {
- this.onReleaseOutside();
- }
- };
- mc.onUnload = function()
- {
- this.focusManager.unregister(this.tabId,this);
- };
- }
- function buildToggle(mc)
- {
- this.log.showKeyedMessage("abstractScreen","buildToggle " + mc);
- mc.enabled = true;
- mc.controller = this;
- mc.gotoAndStop(1);
- mc.focusManager = application.core.FocusManager.getInstance();
- mc.focusBorder = application.ui.FocusBorder.getInstance();
- mc.createEmptyMovieClip("rect",100);
- mc.rect._visible = false;
- mc.tabEnabled = false;
- mc.offset = 0;
- mc.hasFocus = false;
- mc.onRollOver = function()
- {
- if(this.enabled && !this.hasFocus)
- {
- this.gotoAndStop(2 + this.offset);
- this.controller.onButtonRollOver(this);
- }
- };
- mc.onRollOut = function()
- {
- if(this.enabled && !this.hasFocus)
- {
- this.gotoAndStop(1 + this.offset);
- this.controller.onButtonRollOut(this);
- }
- };
- mc.onPress = function()
- {
- if(this.enabled)
- {
- this.gotoAndStop(3 + this.offset);
- this.controller.onButtonPress(this);
- }
- };
- mc.onRelease = function()
- {
- if(this.enabled)
- {
- application.core.FocusManager.getInstance().switchFocus(this);
- if(this.offset == 0)
- {
- this.offset = 4;
- }
- else
- {
- this.offset = 0;
- }
- this.gotoAndStop(2 + this.offset);
- this.controller.onButtonRelease(this);
- }
- };
- mc.onReleaseOutside = function()
- {
- if(this.enabled)
- {
- this.gotoAndStop(1 + this.offset);
- this.controller.onButtonReleaseOutside(this);
- }
- };
- mc.onDisable = function()
- {
- this.enabled = false;
- this.gotoAndStop(4 + this.offset);
- if(this.hasFocus)
- {
- this.hasFocus = false;
- this.focusBorder.hide();
- }
- this.controller.onButtonDisable(this);
- };
- mc.onEnable = function()
- {
- this.enabled = true;
- this.gotoAndStop(1 + this.offset);
- this.controller.onButtonEnable(this);
- };
- mc.onSetFocus = function()
- {
- this.onRollOver();
- this.hasFocus = true;
- this.focusBorder.showBorder(this);
- };
- mc.onKillFocus = function()
- {
- this.hasFocus = false;
- this.onRollOut();
- this.focusBorder.hide();
- };
- mc.onSelect = function()
- {
- if(this.hasFocus)
- {
- this.onPress();
- if(this.IvId != undefined)
- {
- clearInterval(this.IvID);
- delete this.IvID;
- }
- this.IvID = setInterval(this,"onDeselect",100);
- }
- };
- mc.onDeselect = function()
- {
- clearInterval(this.IvID);
- delete this.IvID;
- if(this.hasFocus)
- {
- this.onRelease();
- }
- else
- {
- this.onReleaseOutside();
- }
- };
- mc.onUnload = function()
- {
- this.focusManager.unregister(this.tabId,this);
- };
- }
- function setLabel(mc, s, autosize)
- {
- this.log.startFoldMessage("abstractScreen","setLabel " + mc);
- this.log.addToFoldMessage("abstractScreen","");
- this.log.addToFoldMessage("abstractScreen","\t\tBtn=" + mc);
- this.log.addToFoldMessage("abstractScreen","\t\tText=" + s);
- this.log.endFoldMessage("abstractScreen");
- var _loc3_ = mc.label;
- _loc3_.autoSize = autosize;
- _loc3_.text = s;
- if(s.length < 1)
- {
- this.log.showKeyedMessage("abstractScreen","\t*** ERROR *** empty Label in Button " + mc);
- }
- }
- function reszizeButtonBackground(mc, width, height)
- {
- mc._height = height;
- mc._width = width;
- }
- function createFocusRec(mc, w, h, x, y)
- {
- var _loc2_ = mc.rect;
- _loc2_.clear();
- _loc2_.lineStyle(2,this.configObj.tabBorderColor,100);
- _loc2_.moveTo(0,0);
- _loc2_.lineTo(w,0);
- _loc2_.lineTo(w,h);
- _loc2_.lineTo(0,h);
- _loc2_.lineTo(0,0);
- _loc2_._x = x;
- _loc2_._y = y;
- }
- function setContainer(rootMC)
- {
- this.rootMC = rootMC;
- }
- }
-