A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: replaceSel can't get it to work

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

    replaceSel can't get it to work

    Hi,

    After a lot of searching I'm still unable to replace text that is selected. I want to use this for a sort of word-processor. With HTML formatted text I hope then to be able to make buttons for bold, italic and underlined text. (select; press button > bold)

    What I have found is this:

    (input textfield has the var name 'TextBox')
    button:
    code:

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

    if (selected eq "true"){
    Selection.setFocus(oldSelection);
    Selection.setSelection(startSel,endSel);
    TextBox.replaceSel("new text");
    }
    }



    With this code the selected text stays selected after pressing the button (that's good) but nothing will be replaced

    Any-one out there able to help me?
    I would be most greatfull
    Vincent
    SWIS BV

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

  2. #2
    Senior Front End Developper
    Join Date
    Dec 2000
    Location
    Montréal
    Posts
    568
    not sure why your don't work... I copy paste and it worked fine. Don't use textBox as a instance name.

    this is also working fine
    code:

    test_txt.text = "Hello World! This is original!!";
    Selection.setFocus(test_txt);
    Selection.setSelection(6, 11);
    test_txt.replaceSel("Vincent");


  3. #3
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833
    Finally got it to work with your example.
    I don't know why it didn't work at the first time though.

    Thanks a ton!
    Vincent
    SWIS BV

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

  4. #4
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833
    I spoke to soon
    With this HTML formatting get's lost (as stated in flash-help)
    Do you know how this is done?
    Vincent
    SWIS BV

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

  5. #5
    That links is pretty cool....did you ever figure it out. I'm attempting to do something very similar. Thanks!
    We live in an engaging world - now get ready for an ingaging one.

  6. #6
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    hi, use htmlText instead of text and your html formatting should be there

  7. #7
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833
    Pretty old thread

    look here

    Vincent
    SWIS BV

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

  8. #8
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    hehe,

  9. #9
    This is pretty cool! Thanks.
    We live in an engaging world - now get ready for an ingaging one.

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