Skip to content

Instantly share code, notes, and snippets.

@illuzor illuzor/Main.as
Created Aug 16, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.