CurveTextField

Package:
Class:
Inheritance:
biz.flashscript.text
public class CurveTextField
MovieClip
The CurveTextField class allows arching of text using regular textfields. Text can be embedded. This class is different from the CurveText class, which uses the Flash 10 TextEngine. Use the constructor to trigger a new CurveTextField().

See also

   biz.flashscript.text.CurveText

Public Properties
Property Defined By
horiZontal : Boolean
Create vertical or horizontal text.
CurveTextField
setAngleFactor : Number
This determines the distribution of the letters.
CurveTextField
Public Methods
Method Defined By
CurveTextField()
Creates a new instance of the CurveTextField class.
CurveTextField
createCurve(_string:String, _radius:int=180, _textSpace:int=0, fontsSize:int=12, textColors:uint=0x000000, myFont:String="Verdana"):void
This is the main function to create the arched text.
CurveTextField
Events
Event Defined By

All events are inherited from the MovieClip class.

MovieClip
Property Detail
horiZontal property
horiZontal:Boolean [read-write]

Create vertical or horizontal text.

Implementation

public function get horiZontal():Boolean
public function set horiZontal(value:Boolean):void
setAngleFactor property
horiZontal:Number [read-write]

This determines the distribution of the letters.

Implementation

public function get setAngleFactor():Number
public function set setAngleFactor(value:Number):void
Constructor Detail
CurveTextField ()  Constructor
public function CurveTextField()
Intializes a new CurveTextField instance.
Method Detail

createCurve()  method
public function createCurve(_string:String, _radius:int=180, _textSpace:int=0, fontsSize:int=12, textColors:uint=0x000000, myFont:String="Verdana"):void

Description here......

Parameters

  • _string:String ____ Specifies the text.
  • radius:int=180 ____ Specifies the radius of the arch whether it is a full arch (360) or a half arch (180). Default is 180.
  • _textSpace:int=2 ____ Specifies the space between letters. Default is 0.
  • fontsSize:int=12 ____ Specifies the letter size. Default is 12.
  • textColors:uint=0x000000 ____ Specifies the text color. Default is 0x000000.
  • myFont:String="Verdana" ____ Specifies the font. Default is Verdana.
Examples
Create a new fla file and name it CurveText.fla. Place the fla in the same folder as the biz folder. Put one TextInput component and two NumericStepper components on the stage, name them according to the script. Then create an Actionscript file, name it Curvetext.as and place this script.
package 
{
	import flash.display.Sprite;
	import flash.events.*;
	import flash.text.*;
	import biz.flashscript.text.CurveTextField;
	import fl.controls.NumericStepper;
	import biz.flashscript.utils.LoaderClass;
	import fl.controls.ComboBox;
	import flash.utils.setTimeout;
	public class Curvetextfield extends Sprite
	{
		//
		private var fontsSize:int = 12;
		private var myFont:String;
		private var stepNumber:int;
		private var _color:uint;
		private var fontSelection:ComboBox;
		//
		private var ms:String = "Text here....";
		private var _textSpace:int;
		private static var radius:int;
		private var ct:CurveTextField;
		private var lineInput:TextField;
		private var currentSelection:Sprite;
		public function Curvetextfield ():void
		{
			currentSelection = new Sprite  ;
			currentSelection.x = 10;
			currentSelection.y = 200;
			addChild (currentSelection);
			//
			lineInput = new TextField  ;
			lineInput.x = 19;
			lineInput.y = 7;
			lineInput.width = 213;
			lineInput.height = 21;
			lineInput.type = "input";
			lineInput.text = "Add text here...";
			lineInput.addEventListener (FocusEvent.FOCUS_IN,whenFocus);
			lineInput.addEventListener (Event.CHANGE,textChange);
			addChild (lineInput);
			//
			sizeStepper.addEventListener (Event.CHANGE,stepNext);
			curveStepper.addEventListener (Event.CHANGE,stepNext);
			//
			ct = new CurveTextField  ;
			ct.name = "ct";
			currentSelection.addChild (ct);
			radius = 0;
			_textSpace = 5;
			myFont = "Verdana";
			ct.createCurve (ms,radius,_textSpace,fontsSize,_color,myFont);
			var xpos:int = ct.x;
			var ypos:int = ct.y;
		}
		private function stepNext (e:Event):void
		{
			if (ct != null)
			{
				var oldNumber:int = stepNumber;
				var _value:int = e.currentTarget.nextValue as int;
				var _name:String = e.currentTarget.name as String;
				stepNumber = e.currentTarget.value as int;
				var subtract:uint = stepNumber - oldNumber;
				_textSpace = 5;
				switch (_name)
				{
					case "sizeStepper" :
						createNewCurve ();
						fontsSize = stepNumber;
						ct.createCurve (ms,radius,_textSpace,fontsSize,_color,myFont);
						break;
					case "curveStepper" :
						createNewCurve ();
						radius = stepNumber;
						var _string:String = ms;
						var textRotation:int = 0;
						if (stepNumber == 0)
						{
							textRotation = 0;
							radius = 0;
						}
						ct.createCurve (ms,radius,_textSpace,fontsSize,_color,myFont);
						ct.rotation = textRotation;
						break;
				}
			}
		}
		private function createNewCurve ():void
		{
			if (currentSelection.numChildren != 0)
			{
				currentSelection.removeChild (ct);
			}
			ct = null;
			ct = new CurveTextField  ;
			currentSelection.addChild (ct);
		}
		private function whenFocus (e:Event):void
		{
			if (e.currentTarget.text == "Add text here...")
			{
				e.currentTarget.text = "";
			}
		}
		private function textChange (ev:Event):void
		{
			if (currentSelection.numChildren != 0 && currentSelection.visible && ct != null)
			{
				createNewCurve ();
			}
			else
			{
				ct = new CurveTextField  ;
				ct.name = "ct";
				currentSelection.addChild (ct);
			}
			ms = ev.currentTarget.text;
			ct.createCurve (ms,radius,_textSpace,fontsSize,_color,myFont);
		}
	}
}