Create a gist now

Instantly share code, notes, and snippets.

package com.illuzor.antbuilddemo {
import com.illuzor.antbuilddemo.generators.AndroidTextGenerator;
import com.illuzor.antbuilddemo.generators.FlashPlayerTextGenerator;
import com.illuzor.antbuilddemo.generators.IOSTextGenerator;
import com.illuzor.antbuilddemo.interfaces.IGenerator;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class Main extends Sprite {
public function Main() {
if (stage) addEventListener(Event.ADDED_TO_STAGE, onAdded);
else onAdded();
}
private function onAdded(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, onAdded);
makeText();
}
private function makeText():void {
var textGenerator:IGenerator;
CONFIG::flashplayer {
textGenerator = new FlashPlayerTextGenerator();
}
CONFIG::android {
textGenerator = new AndroidTextGenerator();
}
CONFIG::ios {
textGenerator = new IOSTextGenerator();
}
var textString:String = textGenerator.getText();
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.LEFT;
addChild(textField);
textField.text = textString;
textField.x = (stage.stageWidth - textField.textWidth) / 2;
textField.y = (stage.stageHeight - textField.height) / 2;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment