A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Changing Font size in Dynamic Text Field

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    105

    Changing Font size in Dynamic Text Field

    I'm trying to change the size of a font in a dynamic text field.

    Keep in mind, the text field is not dynamically generated using createTextField.

    I've tried the following with no success:
    myTextFormat = new TextFormat();
    myTextFormat.font = "Verdana";
    myTextFormat.size = 40;
    newbutton2.myLabel.setTextFormat(myTextFormat);

    Where newbutton2.myLabel is the instance name of the text field.
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    If myLabel is the instance name of the text field.

    What is newbutton2 ? is it a button ?

    do you have a textfield on the timeline of your button ?

    that will not work

    i'll show you a movieclip trick, if the above is so. Is the above so ??

  3. #3
    this.me = !(perfect)
    Join Date
    Dec 2001
    Location
    Toronto, ON Canada EH?!
    Posts
    47
    If you are loading the contents of a dynamic text field from a .txt file then you have to format this text with HTML to change portions of it, you cannot do that with the text field properties in flash.

    If you want to just change the overall appearance of the text it is possible for you to just select the text field then change the text field properties in the properties window in flash MX. This will allow you to change numerous things like face, format (i.e. bold, underline, italic) colour and even size.

    Hope this helps.
    I will get around to it...

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    105
    Hi,

    newbutton2 is a MovieClip not a button.

    The MovieClip contains a dynamic textfield with the instance name myLabel.

    I'm trying to dynamically change the properties of the text field and it will vary from one clip to the next.

    It appears the problem is with attachMovie. I failed to leave off that fact since I didn't think it would be the cause of the problem.

    I've created a button and placed the following script on it:
    on (release) {
    _root.attachMovie("ButtonTest", "newbutton2",528);
    myTextFormat = new TextFormat();
    myTextFormat.textColor = "0xFFFFFF";
    myTextFormat.embedFonts = true;
    myTextFormat.font = "Verdana";
    myTextFormat.size = 40;
    newbutton2.myLabel.setTextFormat(myTextFormat);
    }

    This attaches the movieclip fine but doesn't apply myTextFormat to the text field.

    However, if I create a second button and put the following on it:
    on (release) {
    myTextFormat = new TextFormat();
    myTextFormat.textColor = "0xFFFFFF";
    myTextFormat.embedFonts = true;
    myTextFormat.font = "Verdana";
    myTextFormat.size = 40;
    newbutton2.myLabel.setTextFormat(myTextFormat);
    }

    It applies the myTextFormat to the previously attached MovieClip.

    It appears it's a timing issue.

    Is there a way to check that the movieClip is attached and then apply textformatting?

    Any other tips or tricks would be greatly appreciated.
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    can't attach and change in the same instance, by the time the attachMovie has completed, Flash has attempted to setTextFormat() and not finding an object, has ignored it

    try this method
    Code:
    action on the button -
    
    on (release) {
    attachNB2();
    }
    
    action on the main timeline -
    
    function attachNB2(){
    _root.attachMovie("ButtonTest", "newbutton2",528,
    {_x:250,_y:100});
    this.onEnterFrame = function(){
    if(newbutton2._width){
    myTextFormat = new TextFormat();
    myTextFormat.textColor = "0xFFFFFF";
    myTextFormat.embedFonts = true;
    myTextFormat.font = "banana";
    myTextFormat.size = 40;
    newbutton2.myLabel.setTextFormat(myTextFormat);
    delete this.onEnterFrame;
    }
    };
    };

  6. #6
    Senior Member
    Join Date
    Jan 2001
    Posts
    105
    Thanks much.

    That did it.

    Kind of a difficult work around for my situation...but it works.

    Greatly appreciated!
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

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