Packageyourminis.api
Classpublic class Chrome
InheritanceChrome Inheritance flash.display.Sprite
Implementsyourminis.api.IChrome

The Chrome class provides a simple interface and customizable, resizable background widget.



Public Properties
 PropertyDefined by
  buttonPoint : Point
Used to set the location of the copy button
Chrome
  chromeAlpha : Number
Used to set the alpha of the widget chrome.
Chrome
  chromeColor : uint
Used to set the primary color of the widget chrome.
Chrome
  chromeGradient : int
Used to create a downward gradient in the widget, the primary color being the chromeColor.
Chrome
  chromeTexture : BitmapData
Used to set the widget chrome to a textured bitmap.
Chrome
  cornerRadius : int
Used to set the roundness of the widgets corners (default is 10, square corners is 0).
Chrome
  draggable : Boolean
Boolean used to allow the widget to be dragged in free floating environments (such as the gallery sandbox).
Chrome
  editEnabled : Boolean
Used to set the visibility of the dropdown button in the widget chrome
Chrome
  enabled : Boolean
Chrome
  height : Number
The height of the widget
Chrome
  resizable : Boolean
Boolean to determine whether or not the widget is resizable (by the user or widget environment--the widget will always be able to be programatically resized).
Chrome
  shadowEnabled : Boolean
Used to set the visibility of the chrome shadow.
Chrome
  visualsEnabled : Boolean
Used to set the visibility of the color picker button in the widget chrome
Chrome
  width : Number
The width of the widget
Chrome
Public Methods
 MethodDefined by
  
Chrome(_widget:Widget, initWidth:int, initHeight:int, initColor:uint, ... bounds)
Chrome
  
redrawChrome():void
Used to redraw the widget chrome.
Chrome
  
setBounds(minWidth:int, minHeight:int, maxWidth:int, maxHeight:int):*
Used to set the resizable boundaries of the widget.
Chrome
  
setSize(newWidth:Number, newHeight:Number, init:Boolean = false):void
Used to set the dimensions of the chrome in pixels.
Chrome
  
setSkin(skin:String):void
Used to set the skin picture of the chrome.
Chrome
  
setTheme(_color:uint, init:Boolean = false):void
Used to set the theme color of the chrome.
Chrome
  
setTitle(txt:String, xoffset:int = 0, yoffset:int = 0):void
Used to set the text of the title bar in the chrome.
Chrome
  
setView(isFullView:Boolean):void
Used to show/hide the chrome background
Chrome
Property detail
buttonPointproperty
buttonPoint:Point  [read-write]

Used to set the location of the copy button

Implementation
    public function get buttonPoint():Point
    public function set buttonPoint(value:Point):void

Example
The following sets the position of the copy button to 5 pixels over and 10 pixels down from the upper left corner of the widget.
  import flash.geom.Point
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.buttonPoint = new Point(5,10);
  }
 

chromeAlphaproperty 
chromeAlpha:Number  [read-write]

Used to set the alpha of the widget chrome. The chrome must be redrawn or resized after setting to have an effect.

Implementation
    public function get chromeAlpha():Number
    public function set chromeAlpha(value:Number):void

Example
The following code sets the widget chrome to completely transparent.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.initWidget(300,250,0x000000); 
   widget.chrome.chromeAlpha = 0;
   widget.chrome.redrawChrome();
  }
 

chromeColorproperty 
chromeColor:uint  [read-write]

Used to set the primary color of the widget chrome. The chrome must be redrawn or resized after setting to have an effect.

Implementation
    public function get chromeColor():uint
    public function set chromeColor(value:uint):void

Example
The following code sets the widget chrome to white.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.initWidget(300,250,0x000000); 
   widget.chrome.chromeColor = 0xFFFFFF;
   widget.chrome.redrawChrome();
  }
 

chromeGradientproperty 
chromeGradient:int  [read-write]

Used to create a downward gradient in the widget, the primary color being the chromeColor. The chrome must be redrawn or resized after setting to have an effect.

Implementation
    public function get chromeGradient():int
    public function set chromeGradient(value:int):void

Example
The following code sets the chromeGradient to black
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.initWidget(300,250,0x000000);
   widget.chrome.chromeGradient = 0x000000;
   widget.chrome.redrawChrome();
  }
 

chromeTextureproperty 
chromeTexture:BitmapData  [read-write]

Used to set the widget chrome to a textured bitmap. The chrome must be resized or redrawn after setting to have an effect.

Implementation
    public function get chromeTexture():BitmapData
    public function set chromeTexture(value:BitmapData):void

Example
The following code sets the widget to be tiled with a dynamically linked bitmap from the library
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.initWidget(300,250,0x000000);  
   widget.chrome.chromeTexture = new GrassBitmap(120,120);
   widget.chrome.redrawChrome();
  }
 

cornerRadiusproperty 
cornerRadius:int  [read-write]

Used to set the roundness of the widgets corners (default is 10, square corners is 0).

Implementation
    public function get cornerRadius():int
    public function set cornerRadius(value:int):void

Example
The following code sets the widget to have square corners
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);  
   widget.chrome.cornerRadius = 0;
   widget.chrome.redrawChrome();   
  }
 

draggableproperty 
draggable:Boolean  [read-write]

Boolean used to allow the widget to be dragged in free floating environments (such as the gallery sandbox).

Implementation
    public function get draggable():Boolean
    public function set draggable(value:Boolean):void

Example
The following code disables dragging of the widget
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.chrome.draggable = false;
   widget.initWidget(300,250,0x000000); 
  }
 

editEnabledproperty 
editEnabled:Boolean  [read-write]

Used to set the visibility of the dropdown button in the widget chrome

Implementation
    public function get editEnabled():Boolean
    public function set editEnabled(value:Boolean):void

Example
The following sets the dropdown button to invisible.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.editEnabled = false; 
  }
 

enabledproperty 
enabled:Boolean  [read-write]Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
heightproperty 
height:Number  [read-write]

The height of the widget

Implementation
    public function get height():Number
    public function set height(value:Number):void

Example
The following code prints out a message to the console when the widget is resized
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.addEventListener(widget.WIDGET_RESIZED,onWidgetResized);
   widget.debugMode = true;
   widget.initWidget(300,250,0x000000); 
  }
  function onWidgetResized(evt:Event):void {
   widget.debug("Widget resized to: " + widget.chrome.width + " by " + widget.chrome.height); 
  }
 

resizableproperty 
resizable:Boolean  [read-write]

Boolean to determine whether or not the widget is resizable (by the user or widget environment--the widget will always be able to be programatically resized).

Implementation
    public function get resizable():Boolean
    public function set resizable(value:Boolean):void

Example
The following code prevents the widget from being resized in the sandbox by the user (hides resize button)
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.initWidget(300,250,0x000000); 
   widget.chrome.resizable = false;
  }
 

shadowEnabledproperty 
shadowEnabled:Boolean  [read-write]

Used to set the visibility of the chrome shadow. Note that when the chrome shadow is enabled 10 pixels from the with and 10 pixels from the height of the widget are used to give space for the shadow.

Implementation
    public function get shadowEnabled():Boolean
    public function set shadowEnabled(value:Boolean):void

Example
The following disables the chrome shadow.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.shadowEnabled = false; 
  }
 

visualsEnabledproperty 
visualsEnabled:Boolean  [read-write]

Used to set the visibility of the color picker button in the widget chrome

Implementation
    public function get visualsEnabled():Boolean
    public function set visualsEnabled(value:Boolean):void

Example
The following sets the color picker button to invisible.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.visualsEnabled = false;
  }
 

widthproperty 
width:Number  [read-write]

The width of the widget

Implementation
    public function get width():Number
    public function set width(value:Number):void

Example
The following code prints out a message to the console when the widget is resized
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.addEventListener(widget.WIDGET_RESIZED,onWidgetResized);
   widget.debugMode = true;
   widget.initWidget(300,250,0x000000); 
  }
  function onWidgetResized(evt:Event):void {
   widget.debug("Widget resized to: " + widget.chrome.width + " by " + widget.chrome.height); 
  }
 

Constructor detail
Chrome()constructor
public function Chrome(_widget:Widget, initWidth:int, initHeight:int, initColor:uint, ... bounds)Parameters
_widget:Widget
 
initWidth:int
 
initHeight:int
 
initColor:uint
 
... bounds
Method detail
redrawChrome()method
public function redrawChrome():void

Used to redraw the widget chrome. Useful for refreshing the chrome after you make a change.


Example
The following sets the chromeColor to black, the chromeGradient to white and redraws the chrome
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000); 
   widget.chrome.setTheme(0x000000);
   widget.chrome.chromeGradient = 0xFFFFFF;
   widget.chrome.redrawChrome();
  }
 

setBounds()method 
public function setBounds(minWidth:int, minHeight:int, maxWidth:int, maxHeight:int):*

Used to set the resizable boundaries of the widget. Note that if dropshadown is enabled, it increased the widget canvas size by 10 pixels in each direciton.

Parameters
minWidth:int — the minimum width of the widget
 
minHeight:int — the minimum height of the widget
 
maxWidth:int — the maximum width of the widget
 
maxHeight:int — the maximum height of the widget

Returns
*

Example
The following sets the min dimensions to 200,160 and the max dimensions to 800x600;
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.setBounds(200,160,800,600);
  }
 

setSize()method 
public function setSize(newWidth:Number, newHeight:Number, init:Boolean = false):void

Used to set the dimensions of the chrome in pixels.

Parameters
newWidth:Number — The desired width of the chrome.
 
newHeight:Number — The desired height of the chrome.
 
init:Boolean (default = false)

Example
The following code sets the dimensions of the chrome to 240px x 200px
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.setSize(240,200);
  }
 

setSkin()method 
public function setSkin(skin:String):void

Used to set the skin picture of the chrome.

Parameters
skin:String — The url of the picture to load.

Example
The following sets the theme to black.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.setSkin("http://www.example.com/my_picture.jpg"); 
  }
 

setTheme()method 
public function setTheme(_color:uint, init:Boolean = false):void

Used to set the theme color of the chrome.

Parameters
_color:uint — The desired color of the theme.
 
init:Boolean (default = false)

Example
The following sets the theme to black.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.setTheme(0x000000);
  }
 

setTitle()method 
public function setTitle(txt:String, xoffset:int = 0, yoffset:int = 0):void

Used to set the text of the title bar in the chrome.

Parameters
txt:String — The desired title text.
 
xoffset:int (default = 0) — The number of pixels to offset the title location by horizontally. Defaults to 0.
 
yoffset:int (default = 0) — The number of pixels to offset the title location by vertically. Defaults to 0.

Example
The following code sets the title of the widget to "Test Widget".
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.setTitle("Test Widget");
  }
 

setView()method 
public function setView(isFullView:Boolean):void

Used to show/hide the chrome background

Parameters
isFullView:Boolean — If false, will hide the background of the chrome (but the interface buttons will still be usable).

Example
The following code hides the background of the widget.
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void { 
   widget.initWidget(300,250,0x000000);
   widget.chrome.setView(false);
  }