Download xLabel Flash Label Class for UDK Scaleform

Current Version : 0.2b

 — last updated 18th August 2010 —

This Flash Label class extends the Scaleform GFX Label component to add the following functionality :

  • Set Font Size – You can now set the font size through the component inspector and through actionscript
  • Initialize on textChange – The component will automatically re-initialize when the text changes due to actionscript or localization from unrealscript.

:: Installation ::

- I STRONGLY RECOMMEND creating a copy of the original Label component however this is not a requirement if you add the class path to the component.

 - Make sure the paths for the class is setup for your project ( right-click component -> properties -> Class ) and simply add your Label components.

- To catch the event in flash / actionscript use the example below :

 

 

:: Code ::

 

/*
xLabel class  v0.2b by Marc Rogerson - http://www.f00n.com/unreal
Feel free to improve this simple class. 

:Installation:
You can keep the class anywhere in your class file structure but I have setup the class to run out of the com.f00n class folder.
If you wish to move it you will need to alter the class constructor to relate to the new file location

- Create a copy of the Scaleform GFX Label Component in your flash library named xLabel (you can change this or use the original Label component if you update the class constructor).

- Right-Click the component and click Properties. Set the Class Path to where you installed the class

- Right-Click the component again and click Component Definition. Make sure the class is set to the new xLabel class and click ok for the component inspector properties to update.

- Make sure the flash document knows where the class folder is. File -> Publish settings -> Flash -> Actionscript 2.0 Settings.


:Usage:

- Add a component to the stage ( in editor or through actionscript )

- Set the properties in the component inspector or through actionscript / unrealscript at runtime

- Catch the TEXT_CHANGE event using this code example :

myLabel.textChange = function() { //your code here }
myLabel.addEventListener("textChange", textChange);

	
** : Update 0.2b Changelog : **
- added support for Word Wrap. If WordWrap is enabled it will use the _maxWidth to size the textfield.
- added support for Max Width to use in conjunction with Word Wrap
- over-ride on draw() function to include re-initialization

*/

import gfx.controls.Label;
[InspectableList("disabled", "visible", "textID", "bindingEnabled", "enableInitCallback", "autoSize", "labelFontSize", "setWordWrap", "setMaxWidth")]
class com.f00n.xLabel extends gfx.controls.Label {
	//define a labelFontSize 
	private var _labelFontSize:Number;
	private var _wordWrap:Boolean;
	private var _maxWidth:Number;
	
	private var dispatchEvent:Function;
	
	public function xLabel() {
		super();
		_labelFontSize = labelFontSize;
		initLabel(_text, this);
	}
	
	public function initLabel(lbl:String, o:MovieClip):Void {
		
		var txt_format:TextFormat = new TextFormat();
		txt_format.size = _labelFontSize;
		
		o.textField.wordWrap = _wordWrap;
		
		o.textField.setTextFormat(txt_format);
		
		if(_wordWrap==false) {
			//added extra pixel space for filters
			o.textField._width = textField.textWidth + 20;
			o.textField._height = textField.textHeight + 5;
		}else{
			o.textField._width = _maxWidth;
			o.textField._height = textField.textHeight + 5;
		}
	}
	
	[Inspectable(name="Font Size", type=Number, defaultValue="60")]
	public function get labelFontSize():Number { return _labelFontSize; }
	public function set labelFontSize(value:Number):Void {
		if(value >= 1) {
			_labelFontSize = value;
			initLabel(_text, this);
		}
	}
	
	[Inspectable(name="Word Wrap", type=Boolean, defaultValue=false)]
	public function get setWordWrap():Boolean { return _wordWrap; }
	public function set setWordWrap(value:Boolean):Void {
		if(value == true || value == false) {
			_wordWrap = value;
			initLabel(_text, this);
		}
	}
	
	[Inspectable(name="Max Width", type=Number, defaultValue=0)]
	public function get setMaxWidth():Number { return _maxWidth; }
	public function set setMaxWidth(value:Number):Void {
		if(value>=0) {
			_maxWidth = value;
			initLabel(_text, this);
		}
	}

	public function get text():String { return _text; }
	public function set text(value:String):Void { 
		isHtml = false;
		_text = value; 
		if (textField != null) { textField.text = value; }
		alignForAutoSize();
		initLabel(_text, this);
		super.dispatchEvent({type:"textChange"});
	}
	
	private function draw():Void {
		if (sizeIsInvalid) { 
			alignForAutoSize();
			_width = __width;
			_height = __height; 
		}
		constraints.update(__width,__height);
		initLabel(_text, this);
	}
	

}

 

Tagged with:
 

Flash Cursor Class ( as2.0 )

On 06/30/2010, in Flash, flash classes, by Marc

Hi

Download Cursor.as

This is a flash cursor class I made that utilises the flash PopUpManager class in order to make the cursor stay on top of any other PopUps that are created through scaleform gfx CLIK components.

For example : The cursor would not be on top of a dropdown menu when it was opened.  Regular DepthManager usage was unable to be utilised as it requires a UI component from Flash to work.  However adding a regular flash component when scaleform components are being used conflicts with their classes.

:Installation: You can keep the class anywhere in your class file structure but I have setup the class to run out of the gfx.controls class folder. If you wish to move it you will need to alter the class constructor to relate to the new file location

:Usage:
- In actionscript you need to instantiate the class using - 
     var myCursor = new Cursor("myLibrarySymbolName"); 
- You can enable and disable the cursor using - 
     myCursor.enable(); 
    myCursor.disable();
- The _disabled Property (boolean) is available  to check if the mouse is enabled -
     if(myCursor._disabled==true) return;

- Code -

/*
Cursor class by Marc Rogerson - http://www.f00n.com/unreal
Feel free to improve this simple class. 

:Installation:
You can keep the class anywhere in your class file structure but I have setup the class to run out of the gfx.controls class folder.
If you wish to move it you will need to alter the class constructor to relate to the new file location

:Usage:
- In actionscript you need to instantiate the class using -

	var myCursor = new Cursor("myLibrarySymbolName");
	
- You can enable and disable the cursor using -

	myCursor.enable();
	myCursor.disable();

- The _disabled Property (boolean) is available  to check if the mouse is enabled -
	if(myCursor._disabled==true) return;
	


*/


import gfx.managers.PopUpManager;


class gfx.controls.Cursor extends MovieClip {
	//public vars
	public var _disabled:Boolean = false;
	//private vars
	private var mCursor:MovieClip;
	private var libraryMC:String;

	//instantiate the class
	public function Cursor(linkage:String) {
		libraryMC = linkage;
		//initialise
		init();
	}
	
	private function init():Void {
		//attach the cursor with the PopUpManager class
		createCursor();
	}
	
	private function createCursor():Void {
		//create the pop up
		mCursor = PopUpManager.createPopUp(_root, libraryMC);
		//set the dimensions of the cursor **possibly make this a public function**
		setCursorDims(25, 25, mCursor);
		//enable the cursor
		this.enable();
	}
	
	private function setCursorDims(w:Number, h:Number, o:MovieClip):Void {
		o._width = w;
		o._height = h;
		
	}
	//disable the cursor
	public function disable():Void {
		mCursor.stopDrag();
		mCursor._visible = false;
		_disabled = true;
	}
	//enable the cursor
	public function enable():Void {
		mCursor.startDrag(true);
		mCursor._visible = true;
		_disabled = false;
	}

}
Tagged with:
 
Page generated in 1.93043 seconds ( 97.79% PHP, 2.21% MySQL )