CurveText

Package:
Class:
Inheritance:
biz.flashscript.text
public class CurveText
Sprite
The CurveText class allows to create arched text using the Flash 10 TextEngine. Use the constructor to trigger an instance of the new CurveText().

See also

   biz.flashscript.text.CurveTextField

Public Properties
Property Defined By
horiZontal : Boolean
Create vertical or horizontal text.
CurveText
setAngleFactor : Number
This determines the distribution of the letters.
CurveText
Public Methods
Method Defined By
CurveText()
Creates a new instance of the CurveText class.
CurveText
createCurve(_string:String, pathWidth:int=150, pathHeight:int=150, radius:int=0, _textSpace:int=2, fontsSize:int=12, textColors:uint=0x000000, myFont:String="Arial"):void
This is the main function to create the arched text.
CurveText
Events
Event Defined By
All inherited events for the Sprite class. N/A
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
CurveText ()  Constructor
public function CurveText()
Intializes a new CurveText instance.
Method Detail

createCurve()  method
public function createCurve(_string:String, pathWidth:int=150, pathHeight:int=150, radius:int=180, _textSpace:int=2, fontsSize:int=12, textColors:uint=0x000000, myFont:String="Arial"):void

This is the main function to create the arched text.

Parameters

  • _string:String ____ Specifies the text.
  • pathWidth:int=150 ____ Specifies the arch width. Default is 150.
  • pathHeight:int=150 ____ Specifies the arch height. Default is 150.
  • 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 2.
  • fontsSize:int=12 ____ Specifies the letter size. Default is 12.
  • textColors:uint=0x000000 ____ Specifies the text color. Default is 0x000000.
  • myFont:String="Arial" ____ Specifies the font. Default is Arial.
Event Detail

All Events are inherited from the Sprite class.

Examples
Create a new fla file and name it CurveText.fla. Place the fla in the same folder as the biz folder. Put ComboBox components, one TextInput component and one Button component 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.Event;
	import flash.events.MouseEvent;
	import biz.flashscript.text.CurveText;

	public class Curvetext extends Sprite
	{
		private var ms:String = "Initial Text";
		private var pathWidth:int = 50;
		private var pathHeight:int = 50;
		private var _textSpace:int = 40;
		private var radius:int = 180;
		private var angle:Number = 1;
		private var fontsSize:int = 14;
		private var textColors:uint = 0x000000;
		private var myFont:String = "Arial";
		private var ct:CurveText;
		
		public function Curvetext ():void
		{
			createNewCurve ();
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
			submitBut.width = 125;
			submitBut.label = "Create new text";
			submitBut.addEventListener (MouseEvent.CLICK, it);

			fontSelection.addItem ({label:"Helvetica"});
			fontSelection.addItem ({label:"Impact"});
			fontSelection.addItem ({label:"Arial"});
			fontSelection.addItem ({label:"Courier"});
			fontSelection.addEventListener (Event.CHANGE, fs);

			colorSelection.addItem ({label:0x000000});
			colorSelection.addItem ({label:0xFF0000});
			colorSelection.addItem ({label:0x0000FF});
			colorSelection.addItem ({label:0x00FF00});
			colorSelection.addEventListener (Event.CHANGE, cos);

			circleRadius.addItem ({label:90});
			circleRadius.addItem ({label:180});
			circleRadius.addItem ({label:270});
			circleRadius.addItem ({label:360});
			circleRadius.addEventListener (Event.CHANGE, cr);

			fSize.addItem ({label:12});
			fSize.addItem ({label:14});
			fSize.addItem ({label:16});
			fSize.addItem ({label:18});
			fSize.addEventListener (Event.CHANGE, fos);

			pWidth.addItem ({label:50});
			pWidth.addItem ({label:100});
			pWidth.addItem ({label:150});
			pWidth.addItem ({label:200});
			pWidth.addEventListener (Event.CHANGE, pw);

			pHeight.addItem ({label:50});
			pHeight.addItem ({label:100});
			pHeight.addItem ({label:150});
			pHeight.addItem ({label:200});
			pHeight.addEventListener (Event.CHANGE, ph);

		}
		private function createNewCurve ():void
		{
			if (ct != null)
			{
				removeChild (ct);
				ct = null;
			}
			ct = new CurveText();
			ct.x = stage.stageWidth/3;
			ct.y = 150;
			addChild (ct);
		}
		private function it (e:MouseEvent):void
		{
			createNewCurve ();
			ms = insertText.text;
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
		}
		private function fs (e:Event):void
		{
			createNewCurve ();
			myFont = e.currentTarget.selectedItem.label as String;
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
		}
		private function cr (e:Event):void
		{
			createNewCurve ();
			radius = e.currentTarget.selectedItem.label as int;
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
		}
		private function fos (e:Event):void
		{
			createNewCurve ();
			fontsSize = e.currentTarget.selectedItem.label as int;
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
		}
		private function pw (e:Event):void
		{
			createNewCurve ();
			pathWidth = e.currentTarget.selectedItem.label as int;
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
		}
		private function ph (e:Event):void
		{
			createNewCurve ();
			pathHeight = e.currentTarget.selectedItem.label as int;
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
		}
		private function cos (e:Event):void
		{
			createNewCurve ();
			textColors = e.currentTarget.selectedItem.label as uint;
			ct.createCurve (ms, pathWidth, pathHeight, radius,_textSpace, fontsSize, textColors, myFont);
		}
	}
}