A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Rich text editor - selection into variable

  1. #1
    Junior Member
    Join Date
    Nov 2006
    Posts
    3

    Rich text editor - selection into variable

    Hi,
    I having problem with a simple RTE. I need to be able to edit text (bold, italic, size, align) and save it, later recall in a php page.

    I can not figure out, how can I pull the selection into a variable or string to be able to change it and save it as an HTML.

    Could any1 get me going? Where to start? What is "Selection" object in 3dfa exactly?

    THX

    Janos

  2. #2
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Hiya,

    Not sure if I understand the question right. If the question is:

    I have some text that I want to store in a PHP file, and send to 3DFA on demand. The text needs to contain HTML tags, then my answer would be:

    Save the text as HTML. (Using Frontpage, or Word, or some other text editor).

    Then edit the file in notepad and add the following to the top of the document:
    <?
    echo "&text=";
    echo "

    Then leave all the HTML that you've saved, and end the document with:

    "
    ?>

    The HTML stuff will be sent in the PHP scripts as if it's a variable called text. Then use the following to pull the data into a variable in 3DFA.

    url="The path of your PHP script"
    loadVariables (url,"POST")

    Once you do this, the variable text in 3DFA will contain all the HTML data.

    Remember that only certain HTML tags work in Flash using the dynamic HTML functionality. More complex tags can't be used.

    If that wasn't the question, then sorry, you may need to rephrase, or someone else may have a better idea.

    Cheers,

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  3. #3
    Junior Member
    Join Date
    Nov 2006
    Posts
    3
    Hi,

    Thx for the interest.
    I need to make a simple text editor in flash. That could edit the txt file. Stick the html to the required places.
    Something like this:
    http://www.flashloaded.com/flashcomp...ashtexteditor/

    The problem is the selection.

    The text in the edit box can be selectable. What for, if you can not handle the selected part of the text?

    When I select some of the text, example to make it bold (in the working swf) I need to pull it into a var or array to be able to add the <b> and </b> tags. I know that is possiblein MX with the selection object. Is it possible in 3dfa?

    This swf needs to output this html to a txt file.

  4. #4
    Junior Member
    Join Date
    Nov 2006
    Posts
    3
    ----Just to finish the post properly:

    Thanks,

    Janos

  5. #5
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Ahah,

    Now I see what you mean Sorry for the confusion.

    I believe it will be possible, but probably not as straightforward as in MX, as you'll have to play around with actionscript. This isn't well documented in 3DFA and doesn't work in preview mode, so you'll have to do a bit of research, and try a bit of trial and error, and always export to test everything.

    I bet it's possible though. Anyone gonna take the bet?

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  6. #6
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Quote Originally Posted by ForumNewbie

    I bet it's possible though. Anyone gonna take the bet?

    M.

    Anything is possible

  7. #7
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    I think it will be relatively easy, if we can find a way to use the following actionscript commands in 3DFA:

    sel_begin= Selection.getBeginIndex();
    sel_end= Selection.getEndIndex();
    sel_char = Selection.getCaretIndex();

    When trying to use these in 3DFA, it says that Selection is an object type and not a variable. Therefore, I think we need to change it to something like:

    sel_begin= element("Name Of Edit Box").Selection.getBeginIndex();

    But this just returns 'undefined' in the variable sel_begin.

    Can anyone think of a way to get the Selection.getBeginIndex() command to refer to the editbox that the selection is present in?

    If it helps, here's a thread I found whilst researching:

    http://www.actionscript.org/forums/s...d.php3?t=75356

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  8. #8
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Nope. I've tried and tried many times, and I think the syntax is different in 3DFA for these commands than in MX, and I can't work out how it needs to be changed.

    I'm stumped. Any of the real coding guru's out there know how to get these commands to work?

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  9. #9
    Senior Member
    Join Date
    May 2005
    Posts
    163
    It took me awhile to figure this out but I think I have it...

    Since 3DFA has the "Selection" object defined for itself and won't export it the way we need we'll have to reference it some other way. What I found is that the "_global" object is where all the root classes are kept in flash so to reference the "Selection" object we need to use "_global.Selection".


  10. #10
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Nice work. Gonna try and knock together some examples.

    Knew someone out there would be smart enough to work it out

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  11. #11
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Okey dokey.

    Here's some stuff:

    Example:
    http://www.morgan-multinational.co.uk/movie_11.html

    Source Code attached as zip file.

    You'd have to do some work on it to figure the logic of adding and removing tags, but this should give you a starter!

    Simply type text in the top section. Highlight some it, then click the 'make selection bold' button. Apologies for not knowing how to use the <a> tag !

    M.
    Attached Files Attached Files
    Last edited by ForumNewbie; 12-06-2006 at 08:03 PM.
    Please note that my domain has changed to http://www.morganmultinational.com

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