Hello,

I was hoping if someone could explain why the (nearly) same code works on web 
flex, but does not work in AIR. I am trying to isolate some weird behaviour I 
get when I try and scroll some formatted text in a TextArea. It seems to work 
fine as a web application, but does not work in an AIR 2 application.

Basically all the code does below is format some text with a light red 
background. The error happens with I try and scroll the text. The formatted 
text disappears.

Thank you

Web Flex Application code
--------------------
<?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" 
                           xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Script>
                <![CDATA[
                        import flashx.textLayout.formats.TextLayoutFormat;
                        
                        import mx.events.FlexEvent;

                        protected function formatSomeText():void
                        {
                                var textLayoutFormat:TextLayoutFormat = 
textArea.getFormatOfRange(null, 30, 50);
                                textLayoutFormat.backgroundColor = 0xFF8080;
                                textArea.setFormatOfRange(textLayoutFormat, 30, 
50);                            
                        }

                ]]>
        </fx:Script>
        <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) 
here -->
        </fx:Declarations>
        <s:TextArea id="textArea"
                                width="100" height="50"
                                text="This is some text the should be more than 
what can fit into the TextArea"
                                creationComplete="formatSomeText()"/>
</s:Application>

Desktop AIR WindowedApplication code
-------------------------------  
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"; 
                                           
xmlns:s="library://ns.adobe.com/flex/spark" 
                                           
xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Script>
                <![CDATA[
                        import flashx.textLayout.formats.TextLayoutFormat;
                        
                        import mx.events.FlexEvent;
                        
                        protected function formatSomeText():void
                        {
                                var textLayoutFormat:TextLayoutFormat = 
textArea.getFormatOfRange(null, 30, 50);
                                textLayoutFormat.backgroundColor = 0xFF8080;
                                textArea.setFormatOfRange(textLayoutFormat, 30, 
50);                            
                        }
                        
                ]]>
        </fx:Script>
        <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) 
here -->
        </fx:Declarations>
        <s:TextArea id="textArea"
                                width="100" height="50"
                                text="This is some text the should be more than 
what can fit into the TextArea"
                                creationComplete="formatSomeText()"/>
</s:WindowedApplication>

Reply via email to