| Flashscript classes (ActionScript 3) | Home | MX | MX 2004 | Flash 8 | Flash 9 |Flash 10 |PHP |Components | Snippets | Contact | |
CurveTextField |
|
|
See also
| Property | Defined By |
|---|---|
|
horiZontal
: Boolean
Create vertical or horizontal text. |
CurveTextField |
|
setAngleFactor
: Number
This determines the distribution of the letters. |
CurveTextField |
| 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")
This is the main function to create the arched text. |
CurveTextField |
| 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. Implementationpublic function get horiZontal():Booleanpublic function set horiZontal(value:Boolean):void |
|
setAngleFactor
property
horiZontal:Number [read-write] This determines the distribution of the letters. Implementationpublic function get setAngleFactor():Numberpublic function set setAngleFactor(value:Number):void |
| Constructor Detail |
|---|
|
CurveTextField () Constructor
public function CurveTextField() |
| Intializes a new CurveTextField instance. |
| Method Detail |
|---|
|
createCurve() method
Description here...... |
Parameters
|
| 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 = 18;
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 = 10;
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 = 200;
currentSelection.y = 400;
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;
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;
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);
}
}
}
|