A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Selection in HTML formatted input textfield

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

    Selection in HTML formatted input textfield

    Hi,

    To make a small text editor for a mailinglist front-end I have this code on a '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);
    beg = _root.ber.slice(0,startSel);
    sel = _root.ber.slice(startSel,endSel);
    end = _root.ber.slice(endSel,10000000);
    _root.ber = beg + "<b>" + sel + "</b>" + end;
    Selection.setSelection(0,0);
    }
    }



    When my input textfield is not formatted with HTML it works perfectly. But I would really like to be able to have it work when HTML formatting is turned on too.

    It seems to set the '< b >' and '< /b >' on the wrong place when the text is HTML formatted. It places it on the place where it should be when it's not HTML formatted; with other tags it completely messes everything up.

    I have been busy with this for almost a week and can't figure it out

    Any help would be so much appriciated!


    _____________
    Vincent

  2. #2
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833
    Sorry to bumb this
    Is this impossible or do I need to go another way?
    I have seen examples online I have no clue how to do it though. The selection thing works but I can't seem to get it to work when the textfield is HTML formatted...

    Any help, please?
    Vincent
    SWIS BV

    Last edited by Markp.com on 07-23-2003 at 02:25 AM

  3. #3
    Junior Member
    Join Date
    Aug 2003
    Posts
    5

    like this ?

    So you want something like this:
    http://www.myrichtext.com


    Im not trying to sell you something, don't worry. The bad news is that you are way off, you don't want to specifically write the tags, let Flash do it for you.

    Step 1:
    It seems you have a decent grasp on getbeginIndex, you need to check out getTextFormat, getNewTextFormat, setNewTextFormat, and setTextFormat.

    They let you do things like myFormat = mytextfield.getTextFormat
    if (myFormat.bold) {
    newFormat.bold = false;
    mytextfield.setTextFormat(newFormat)
    } else {
    newFormat.bold = true;
    mytextfield.setTextFormat(newFormat)

    }

  4. #4
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833
    your first post on Flashkit and helping me out, thanks

    Still have some questions though....

    code:
    on (release) {
    myFormat = mytextfield.getTextFormat;
    if (myFormat.bold) {
    newFormat.bold = false;
    mytextfield.setTextFormat(newFormat);
    } else {
    newFormat.bold = true;
    mytextfield.setTextFormat(newFormat);
    }
    }



    This doesn't seem to work

    And how would this generate HTML code in the end?

    Thanks again
    Vincent
    SWIS BV

    Last edited by Markp.com on 07-23-2003 at 02:25 AM

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