It's still not working. Here's the code:
function formatLink():void {
var myCSS:StyleSheet = new StyleSheet();
myCSS.setStyle("a:link", {color:'#0000CC',textDecoration:'none'});
myCSS.setStyle("a:hover", {color:'#0000FF',textDecoration:'underline'});
txtFormat.font = weiss.fontName;
txtFormat.color=0x000066;
txtFormat.size=24;
//myTxtField.setTextFormat(txtFormat);
myTxtField.defaultTextFormat(txtFormat);
myTxtField.embedFonts = true;
//loading external CSS file
/*cssLoader = new URLLoader();// Create a new URLLoader object
cssLoader.load(new URLRequest("eGreeting.css"));// Load "default.css" with a new URLRequest object
css = new StyleSheet();// Create a new StyleSheet object
css.parseCSS(cssLoader.data);// Parsing CSS*/
//end of loeading external CSS file
myTxtField.styleSheet = myCSS; // Linking CSS to TextField
//end creating css
myTxtField.htmlText="";
myTxtField.htmlText="<p><a href='http://www.mysite.com/' target='_blank'>My Link</a></p>";
myTxtField.wordWrap=false;
//myTxtField.embedFonts = true;
myTxtField.x=150;
myTxtField.y=100;
//trace("Third txtField.y: " + txtField.y);
myTxtField.alpha=0;
}And the error for the defaultTextFormat:
1195: Attempted access of inaccessible method defaultTextFormat through a reference with static type flash.text:TextField.
Is the above error means I can't do this?
myTxtField.htmlText="<p><a href='http://www.mysite.com/' target='_blank'>My Link</a></p>";
the defaultTextFormat is a property, not a method. instead of:
myTxtField.defaultTextFormat(txtFormat);
use:
myTxtField.defaultTextFormat = txtFormat;