-
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.
-
FK'n_dog
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 ??
-
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...
-
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.
-
FK'n_dog
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;
}
};
};
-
Thanks much.
That did it.
Kind of a difficult work around for my situation...but it works.
Greatly appreciated!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|