-
Am I setting up this global function correctly?
Hi
I have a global function that I'm calling in some text fields to control the font. I get errors though, and was wondering if I'm setting this up correctly?
Here's my globals.as package...
package
{ public class globals
{
import flash.text.TextField;
public static function performAction(myText:TextField):void {
var myFont:Font = new Font1();
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.fontName;
myFormat.size = globals.data.mainFontSize;
myFormat.color = globals.data.mainFontColor;
myText.defaultTextFormat = myFormat;
myText.autoSize = TextFieldAutoSize.LEFT;
myText.embedFonts = true;
myText.filters = [globals.data.upStroke, globals.data.upGlow, globals.data.upShadow];
}
}
}
and my button code...
globals.performAction(myText);
myText.text = "blahblah";
stop();
The function works fine when I have it within the actual text field as3, but as soon as I try to make it work from an external .as fiule, it doesn't.
Here are the error messages:
1046: Type was not found or was not a compile-time constant: Font. - var myFont:Font = new Font1();
1046: Type was not found or was not a compile-time constant: TextFormat. - var myFormat:TextFormat = new TextFormat();
1180: Call to a possibly undefined method TextFormat. - var myFormat:TextFormat = new TextFormat();
1120: Access of undefined property TextFieldAutoSize. - myText.autoSize = TextFieldAutoSize.LEFT;
Thanks for your time and help.
Shaun
-
1046: Type was not found or was not a compile-time constant: Font. - var myFont:Font = new Font1();
You didn't import Font.
1046: Type was not found or was not a compile-time constant: TextFormat. - var myFormat:TextFormat = new TextFormat();
You didn't import TextFormat.
1180: Call to a possibly undefined method TextFormat. - var myFormat:TextFormat = new TextFormat();
You still haven't imported TextFormat.
1120: Access of undefined property TextFieldAutoSize. - myText.autoSize = TextFieldAutoSize.LEFT;
You didn't import TextFieldAutoSize.
-
Hey 5TonsOfFlax - thanks for pointing that out. I'm learning something new everyday.
Much appreciated.
Shaun
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
|