ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Working with String Strategies | 421

Feel free to change any of the support classes’ features to meet your own tastes.


String Strategy Test


The test of the applied Strategy design pattern uses two objects (Example 11-33).


The first object instantiates the concrete context class,Checker, and the second uses


Passwork.


{

this.type=TextFieldType.DYNAMIC;
this.multiline=true;
this.wordWrap=true;
this.border=true;
this.borderColor=0xcccccc;
}
}
}


Example 11-32. TextShow.as


package
{
import flash.text.TextFormat;


class TextShow extends TextFormat
{
function TextShow( ):void
{
this.font="Verdana";
this.color=0xcc0000;
this.size=11;
this.leading=3;
this.leftMargin=11;
this.rightMargin=6;
}
}
}


Example 11-33. TestStringStrategy.as


package
{
import flash.display.Sprite;


public class TestStringStrategy extends Sprite
{
private var showText:ShowText;
private var showText2:ShowText;
private var textShow:TextShow;


public function TestStringStrategy( ):void


Example 11-31. ShowText.as (continued)

Free download pdf