A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] [F8] object at the end of a text

  1. #1
    wierd
    Join Date
    Sep 2008
    Posts
    46

    resolved [RESOLVED] [F8] object at the end of a text

    Hey there,

    I hope you guys can help me.

    I want to put an object for example a red square at the end of a multiline text.

    I know I can find out the textlength with the attribute textHeight or textWidth.

    But if my text is for example like this:

    [Lorem ipsum dolor sit] <--- Textfield
    [amet [x] ]

    [x] = red square.

    So how to I put the red square at the end of this example?
    It have to be dynamic.

    I uploaded a picture for better understanding.
    Attached Images Attached Images
    • File Type: jpg g.jpg (57.0 KB, 18 views)

  2. #2
    wierd
    Join Date
    Sep 2008
    Posts
    46
    I found something.
    http://www.actionscript.org/forums/s...d.php3?t=90797

    If somehow I can get the width of the last line my problem would be solved.

  3. #3
    wierd
    Join Date
    Sep 2008
    Posts
    46
    bump

  4. #4
    wierd
    Join Date
    Sep 2008
    Posts
    46
    bump2

  5. #5
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    you can embed an object .swf or movie clip..or even an image into a dynamic text field...

    there is a link in my footer called (embed) read it..

  6. #6
    wierd
    Join Date
    Sep 2008
    Posts
    46
    Quote Originally Posted by whispers
    you can embed an object .swf or movie clip..or even an image into a dynamic text field...

    there is a link in my footer called (embed) read it..
    First thanks for ur response.

    I've looked into this embed thing.

    It doesn't seem to work properly. There's always linebreak when you use this embed thing.

    I used this code:
    Code:
    _root.test.htmlText = "1 MovieClip:<img src='square'>:MovieClip";
    Basically it should be between "Moveclip:" and :"Movieclip" right? But instead this turns out.

    Attached Files Attached Files

  7. #7
    wierd
    Join Date
    Sep 2008
    Posts
    46
    Well maybe it's a little bit late no what the hell it's damn late.

    Anyway I think I have a solution which I think it might work for the most cases.


    I split the text on whitespace because that's where the Textfield will make a linebreak if the "word"s width is larger than the Textfield width.

    Next I need to determine what's the max textWidth of the Textfield by putting "i" in the Textfield (in my case 219.75 I rounded it up).

    Then I need to add word by word to see if it's larger than the max textWidth and so on. Someday I might then get the textWidth of the last line.

    PHP Code:
    var my_array:Array = String(normal_txt.text).split(" ");
                
    hidden_txt.text "";
    var 
    temp_end:Boolean false;
    var 
    length_lastline:Number;
                
    for 
    each(var wort:String in my_array){
        if(
    hidden_txt.text == ""){
            
    hidden_txt.text wort;
        }
        else{
            
    hidden_txt.text hidden_txt.text " " wort;
        }
                    
        if(
    hidden_txt.textWidth 220){
            
    temp_end true;
            
    hidden_txt.text wort;
        }
        
    length_lastline hidden_txt.textWidth;
    }
                
    if(
    temp_end){
        
    mc.normal_txt.length_lastline 12;
        
    mc.normal_txt.normal_txt.height 18;
    }
    else{
        
    mc.normal_txt.length_lastline 11;
        
    mc.normal_txt.normal_txt.height 21;

    This is done in CS4 with Actionscript 3.0 not Flash 8. Maybe this thread should moved to Actionscript 3.0.
    Last edited by dkmobi; 08-14-2009 at 05:56 AM. Reason: info

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