0
点赞
收藏
分享

微信扫一扫

FLEX实践—控件内容与String显示区别


 在解释这个区别之前先来看一段示例:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script> 
        <!--[CDATA[ 
            
            import mx.controls.Alert;
  
            
            private function show():void{
              var contentStr:String = "mailto:meteorWJ@gmail.com?subject=test&body=use mailto sample";
              Alert.show(contentStr);
              Alert.show(content.text);
            }
        ]]--> 
    </mx:Script> 

	<mx:Label x="285" y="146" text="Content:" fontWeight="bold"/>
	<mx:Button x="351" y="343" label="Send" click="show()"/>
	<mx:TextArea x="351" y="145" width="592" height="171" id="content" text="mailto:meteorWJ@gmail?subject=test&body=use mailto sample"/>
	
</mx:Application>

 

演示结果:

contentStr: mailto:meteorWJ@gmail.com?subject=test&body=use mailto sample
content.text: mailto:meteorWJ@gmail.com?subject=test&body=use mailto sample

同样是String类型,由content.text解析的内容将'&amp;' 转换成了 '&'

而contentStr中的内容却没有变化。

 

猜想:可能是因为TextArea控件的text在解析成已经自动将其中的'&amp;'当成转义字符(在XML/HTML中'&amp;'对应的字符是'&'),而对于contentStr只是单纯地输出字符串内容。

 

 

举报

相关推荐

0 条评论