A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: to select and make bold with HTML text...

Threaded View

  1. #1
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833

    to select and make bold with HTML text...

    Hi,

    I'm trying to make a text editor in flash but I'm having way too much trouble with it (my scripting is just too bad I guess)

    What I'm trying to do is a 'bold' button. With this button I want selected text to be bold; if no text is selected I want the text that is inserted after 'bold' to be bold (sounds confusing but the same way as for example MS Word)

    What I have now is this:

    'bold' button:
    code:

    on(rollOver){
    startSel = Selection.getBeginIndex();
    endSel = Selection.getEndIndex();
    oudeSelectie = Selection.getFocus();
    if (endSel - startSel > 0){
    selected = "true";
    } else {
    selected = "false";
    }
    }

    on (release) {
    if (selected eq "true"){
    Selection.setFocus(oudeSelectie);
    Selection.setSelection(startSel,endSel);
    begin = tfield.slice(0,startSel);
    z= tfield.slice(startSel,endSel);
    end = tfield.slice(endSel,1000000);
    output= begin add "<B>" add z add "</B>" add end;
    tfield = output;
    }
    Selection.setFocus("textfield.text");
    Selection.setSelection(100000,100000000);
    }



    When HTML formatting is set off to in the textfield it seems to work fine but as I turn it on all text is gone after selecting and pressing the button.

    If I make trace 'output' I see a long string of HTML tags plus the two tags for bold but the bold tags(<b></b>) are at the wrong place.

    Is there any way to go this way with HTML formatted text?

    I would be most greatfull
    (and happy)

    Thanks,

    Vincent
    Last edited by Vincent26381; 07-31-2003 at 02:55 PM.

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