A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Urgent - problem converting style code from classic text to TLF text

  1. #1
    Junior Member
    Join Date
    Jan 2003

    resolved Urgent - problem converting style code from classic text to TLF text

    I've got a project that currently uses classic dynamic text fields that pull in information from an XML file. The text contains a 'keyword' that's referenced in the XML, that can be situated anywhere in the complete sentence. This keyword needs to be a different colour and font size... but as I said, it can appear anywhere.

    Currently this works by getting the keyword from the XML, finding its length, finding the index of where it starts, splicing the main string, and then setting TextFormat to the number of chars in keyword, which changes the font size and colour for just that keyword in the sentence.

    This works great for the classic dynamic text boxes. It doesn't however work with TLF text, it just applies the new format to the entire text field. I don't have any experience with TLF text as I've just upgraded to CS5 and now need to make this work in Hebrew.

    Any help would be really appreciated, I'm up against it on this one!

    The code snippet for the keyword colour change looks like this:

    Where screen01Norm & screen01Key are things pulled from XML & screen_01.txt_box_combined is the text field.

    var newFormat:TextFormat = new TextFormat();
    newFormat.color = 0x319aca;
    newFormat.size = 50;

    var masterString:String = screen01Norm;
    var keyLength:* = String(masterString.indexOf(screen01Key));

    var keyInt:int = keyLength
    var newLength:int = keyInt+keywordLength;

    for(var i:int = keyLength; i <newLength; i++){
    screen_01.txt_box_combined.setTextFormat(newFormat , i);
    Last edited by f0ld; 01-10-2011 at 11:41 AM.

  2. #2
    Junior Member
    Join Date
    Jan 2003
    Doesn't matter. Got it working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center