A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Dynamic Text Controlled with button

  1. #1
    Member
    Join Date
    Apr 2001
    Location
    Minneapolis, MN
    Posts
    36

    Dynamic Text Controlled with button

    HELP!!
    Using Flash MX 2004, Pro.
    I have a button on the main timeline.
    on (rollOver) the button creates a dynamic text box.
    How do I remove the text box when the user does rollOut?

    Thanks in advance,
    Christine

    On the main timeline, frame 1:
    //create text formatting for dynamic text headline
    var txt_fmtA:TextFormat = new TextFormat();
    txt_fmtA.font = "Arial";
    txt_fmtA.bold = true;
    txt_fmtA.size = 11;
    txt_fmtA.leftMargin = 3;
    txt_fmtA.rightMargin = 3;
    txt_fmtA.color = 0xFFFFFF;

    //create text formatting for dynamic body text
    var txt_fmt:TextFormat = new TextFormat();
    txt_fmt.font = "Arial";
    txt_fmt.size = 9;
    txt_fmt.leftMargin = 3;
    txt_fmt.rightMargin = 3;
    txt_fmt.leading = 2;

    On the Button:
    on (rollOver) {
    //Headline Box
    this.createTextField("hdrWA", 11, 104, 13, 150, 23);
    hdrWA.setNewTextFormat(txt_fmtA);
    hdrWA.multiline = false;
    hdrWA.wordWrap = true;
    hdrWA.autoSize = false;
    hdrWA.background = true;
    hdrWA.border = false;
    hdrWA.backgroundColor = 0x334C8F;
    hdrWA.text = "Headline";

    //Body Text Box
    this.createTextField("WA", 10, 104, 36, 150, 50);
    WA.setNewTextFormat(txt_fmt);
    WA.multiline = true;
    WA.wordWrap = true;
    WA.autoSize = true;
    WA.background = true;
    WA.border = false;
    WA.backgroundColor = 0xECEDE7;
    WA.text = "This is a test. This is only a test.";

    }

    //this part doesn't work Please Help?
    on (rollOut, release, releaseOutside) {
    this.removeTextField("hdrWA", 11, 104, 13, 150, 23);
    }
    Last edited by zuk; 02-18-2005 at 07:50 PM.

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    You should just need
    Code:
    hdrWA.removeTextField();

  3. #3
    Member
    Join Date
    Apr 2001
    Location
    Minneapolis, MN
    Posts
    36
    That's it!

    You are my hero. Thank you.

    One more thing...would you happen to know how to make the background color of the text box semi-transparent, about 70%?

    I tried _alpha, but I don't think i'm doing it correctly.
    I tried:

    WA.backgroundColor._alpha = 70;
    and
    WA.background._alpha = 70;

    Christine

  4. #4
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Unfortunately you can't do that, you can only change the alpha of the whole textfield.

    If you really want a semi-transparent background you'll have to have a separate MC/graphic behind it.

  5. #5
    Member
    Join Date
    Apr 2001
    Location
    Minneapolis, MN
    Posts
    36
    Rats. I was afraid of that..actually that wouldn't be too bad.

    I just need to put the dynamic text field in the same movie clip with the colored background. Then, just place the movieclip where I want it on the main timeline.

    Oh, wait, then I'm back to my problem of making the background box fit the text. The final .swf will call text from an external file.

    Is there a way to calculate the size of a text chunk and then tell the background movie clip to fit that size?

    some kind of get script?

    Christine

  6. #6
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Sure, look into TextField.autoSize then use TextField._height.

  7. #7
    Member
    Join Date
    Apr 2001
    Location
    Minneapolis, MN
    Posts
    36
    Sweet. I'll play around with that when I have some time again.

    Thanks!!!

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