Created
August 16, 2015 19:54
-
-
Save illuzor/b6e6b3ecea396e16987b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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