views:

187

answers:

1

I have a Box container that has a label element inside it. When the box is transformed using a Matrix the label element is not visible anymore. How do I make the elements visible?

<mx:Script>
    <![CDATA[

        private function onBoxClick(event:MouseEvent):void
        {
            var transformMatrix:Matrix = this.box.transform.matrix;
            transformMatrix.c = Math.PI * 2 * -15 / 360;; 
            this.box.transform.matrix = transformMatrix;
        }

    ]]>
</mx:Script>

<mx:HBox id="box" 
    x="100" y="100" 
    width="100" height="100" 
    backgroundColor="0x000000" 
    click="onBoxClick(event)">

    <mx:Label id="textLabel" text="This is a test" color="#FFFFFF" visible="true"/>
</mx:HBox>
+2  A: 

I'm guessing the TextField inside the Label component doesn't have the font embedded. If you plan to use .rotation or .alpha on a dynamic text you must embed the font.

You can easily test this with a regular TextField:

var t:TextField = new TextField();
t.defaultTextFormat = new TextFormat('Verdana',12,0x000000);
t.embedFonts = true;
t.rotation = 10;
t.text = 'rotated';

addChild(t);

That is assuming you have the Verdana font embedded in this example. If you comment out the 3rd line you will see the text disappear.

George Profenza