Skip to content

Instantly share code, notes, and snippets.

@illuzor
Created August 16, 2015 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illuzor/b6e6b3ecea396e16987b to your computer and use it in GitHub Desktop.
Save illuzor/b6e6b3ecea396e16987b to your computer and use it in GitHub Desktop.
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