Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-09-2009, 05:28 PM   #1
mavi
Senior Member
 
Join Date: Jan 2008
Posts: 108
Default Dynamic Text - First Letter Bold

Hi again.
I have a dynamic text field with a very simple external text loader.
this text field just contains t list of people...

Code:
function textLoadComplete(event:Event):void
{
clientList.text = textLoader.data;
}

var textLoader:URLLoader = new URLLoader();
var textReq:URLRequest = new URLRequest('clientlist.txt');

textLoader.load(textReq);
textLoader.addEventListener(Event.COMPLETE, textLoadComplete);
But now a want the first letter of every line in bold or 2 point sizes bigger.
I know I can only embed one text style - and bold would be an additional style, right?
But it's only a simple list of words - no links - no other extras.
Does anybody know if this can be done...
THAAAAAAANX
martin...
__________________
FM

Last edited by mavi; 09-09-2009 at 06:38 PM.
mavi is offline   Reply With Quote
Old 09-09-2009, 08:17 PM   #2
Slowburn
[Invent:Design:Create]
 
Join Date: Sep 2002
Location: Toronto, ON
Posts: 2,068
Default

hope this demo helps. you can just copy and paste it in the actions panel of the Flash IDE to see it work.
ActionScript Code:
// base format for field text var normalFormat:TextFormat = new TextFormat( "Arial", 12, 0x000000 ); // bold format for first character in a line var boldFormat:TextFormat = new TextFormat( "Arial Bold", 14, 0x000000 ); // your text var strList:String = "Harry\nMary\nSue\rWillie"; // the text field, base setup var field:TextField = new TextField(); field.border = true; field.width = 200; field.autoSize = TextFieldAutoSize.NONE; // auto set normal format field.defaultTextFormat = normalFormat; // set your text field.text = strList; addChild( field ); // now format the first character in each line // with bold and bigger font-size formatList(); function formatList():void {     // get the total number of text lines     var numLines:int = field.bottomScrollV;     // loop through each line     for( var i:int = 0; i < numLines; i++ )     {         // get the index of the first character of this line         var charcterIndex:int = field.getLineOffset( i );         // set the format of the charcter         field.setTextFormat( boldFormat, charcterIndex, charcterIndex + 1 );     } }
__________________
o Please do a search before you post
o Please use the [ as][ /as] tag for your code (so we can read it clearly)
Slowburn is offline   Reply With Quote
Old 09-10-2009, 08:47 PM   #3
mavi
Senior Member
 
Join Date: Jan 2008
Posts: 108
Default

Wow... That was AWESOME
THAAAAAAANX
__________________
FM
mavi is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:22 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.