If user want to find out number of characters in a string. In this case String has a length property that return the number of characters in the specified String object.
If user want to find out number of characters in a string. In this case String has a length property that return the number of characters in the specified String object.String Length property example in Action Script3:-
If user want to find out number of characters in a string. In this case String has a length property that return the number of characters in the specified String object. In case of string null and empty, the string length is 0.
Example:-
<?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" creationComplete="init();"> <fx:Script> <![CDATA[ private function init():void{ var str:String = "Brijesh says \'Hello Sir\'"; var strlength:Number = str.length; myText1.text = str; myText2.text = "The String length is " + strlength.toString(); } ]]> </fx:Script> <s:Panel width="200" height="200" title="String Length Panel" backgroundColor="0x81B5AA"> <s:VGroup> <mx:Text id="myText1"/> <mx:Text id="myText2"/> </s:VGroup> </s:Panel> </s:Application> |
In this example we have created a string type variable and initialize string value. After that we have apply length property to find out the length of the string.
Output:-