A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: [F8] Add/remove bullets in html selection??

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,929

    [F8] Add/remove bullets in html selection??

    I've got a text field that I need to be able to add and remove bullets from using the <li> html tag. I figured out how to get the selection and wrap it with the <li> tag, but, I'm not sure how to determine if there's an <li> tag around the selection html and remove it. I would just do a split and join to remove the tags from the whole text box, but there might be two bulleted sections on one page, so I can't just remove all the bullets...

    Anyone??

    Sample attached...

    Edit: And here's the code I'm using...as you can guess, the first part of the if statement isn't working since the <li> tag doesn't show up in the selection, since it's not html:

    Code:
    on (release) {
    	Selection.setFocus(this._parent.text_txt.text);
    	Selection.setSelection(this.SelBegin, this.SelEnd);
    	allText = this._parent.text_txt.text;
    	selText = allText.substring(this.SelBegin, this.SelEnd);
    	if (selText.substring(1, 4) == "<li>") {
    		initString = this._parent.text_txt.text.substring(0, this.SelBegin);
    		replaceString = selText.substring(5, selText.length-5);
    		finalString = this._parent.text_txt.text.substring(this.SelEnd, this._parent.text_txt.text.length);
    		this._parent.text_txt.htmlText = initString+replaceString+finalString;
    	} else {
    		initString = this._parent.text_txt.text.substring(0, this.SelBegin);
    		replaceString = "<li>"+this._parent.text_txt.text.substring(this.SelBegin, this.SelEnd)+"</li>";
    		finalString = this._parent.text_txt.text.substring(this.SelEnd, this._parent.text_txt.text.length);
    		this._parent.text_txt.htmlText = initString+replaceString+finalString;
    	}
    }
    Last edited by flashpipe1; 11-18-2008 at 08:44 PM.
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

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