I have a Flex mobile project with a .mxml file like this:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
applicationDPI="160">
<fx:Script>
<![CDATA[
import com.djar.Test;
protected function button1_clickHandler(event:MouseEvent):void
{
var d:Test = new Test();
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:Button x="0" y="0" label="click" click="button1_clickHandler(event)"/>
</s:Application>
And the .as file:
package com.djar
{
import flash.display.Sprite;
import flash.text.*;
public class Test extends Sprite
{
public var myText:TextField = new TextField();
public function Test()
{
trace("1111111111");
myText.autoSize = TextFieldAutoSize.LEFT;
myText.text = "HELLO,MY FLASH";
var myFormat:TextFormat = new TextFormat();
myFormat.size = 40;
myFormat.font = "Cooper Black";
myFormat.color = 0xcc0000;
myText.x=0
myText.y=50
myText.setTextFormat(myFormat);
trace("2222222222");
addChild(myText);
}
}
}
When I debug and click the button on my phone, I can see 1111111111
and 2222222222
in the console, but nothing happens on my phone. What should I do to make it show HELLO,MY FLASH
?
Currently you are adding
myText
as a child of yourTest
Sprite
, however you are not adding thatSprite
to thestage
. This can be addressed in your button handler.