User login

Text-Field-Factory

Product Class- Concrete

package textFieldfact
{
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
import flash.text.TextFormat;

public class TextFieldConcrete extends TextFieldAb
{
internal var tf:TextField;
internal var obName:String;

public function TextFieldConcrete(aModel:Object,aController:Object = null)
{
super(aModel,aController);
this.addEventListener(MouseEvent.CLICK, clickHandler);
}
private function clickHandler(event:MouseEvent):void
{
(controller as IController).setView(this.obName);
}
override public function update(event:Event = null):void
{

Product Class- Abstract

package textFieldfact {

import flash.events.*;

internal class TextFieldAb extends CompositeView
{
public function TextFieldAb(aModel:Object,aController:Object = null)
{
super(aModel,aController);
}
internal function create(data:Array):void
{
trace('this must be subclassed');
//return null;
}
internal function addTitle(data:XML):void
{
trace('this must be subclassed');
}
internal function setLoc(xLoc:int, yLoc:int):void
{
this.x = xLoc;
this.y = yLoc;
}
}
}

Creator Class- Concrete

package textFieldfact
{
import flash.display.*;

public class TextFieldCreatorConcrete extends TextFieldCreator
{
override internal function createTf(aModel:Object,aController:Object = null):TextFieldAb
{
return new TextFieldConcrete(aModel,aController);
}
}
}

Creator Class- Abstract

Creator Class- Abstract
Tue, 01/27/2009 - 13:50 — Eric

package textFieldfact
{

public class TextFieldCreator
{
public function addTf(aModel:Object,aController:Object,data:XML,xLoc:int,yLoc:int,passParent:Object):void
{
var textfield:TextFieldAb = this.createTf((aModel as IModel),(aController as IController));
textfield.addTitle(data);
textfield.setLoc(xLoc,yLoc);
passParent.add(textfield);
passParent.addChild(textfield);
}
internal function createTf(aModel:Object,aController:Object = null):TextFieldAb
{
return new TextFieldAb(aModel,aController);
}
}
}

Textfield Factory

This factory places text fields on the page. The factory is initialized like this:

var tfFactory:TextFieldCreator = new TextFieldCreatorConcrete();

and new textfields are created like this:
item is an XML piece,
100 is the x location,
150 is the y location,
this is the parent
tfFactory.addTf(model,controller,item,100,150,this);

You can download the package here:
http://www.code.ericschleeper.com/samples/textFieldfact.zip

The class that this code is located it in is here:
http://www.code.ericschleeper.com/samples/CompositeViewWithFactory.as
and this is the XML:

Syndicate content