开发者

Using imported shared fonts in flash as3 css

开发者 https://www.devze.com 2023-01-16 02:33 出处:网络
I have a main.fla, in the library, i created two new fonts: RegularFont and BoldFont. And I found the following piece of code somewhere, which works fine!

I have a main.fla, in the library, i created two new fonts: RegularFont and BoldFont.

And I found the following piece of code somewhere, which works fine!

var regularFont:Font = new RegularFont();
var boldFont:Font = new BoldFont();
var regular:Object = {fontFamily:regularFont.fontName};
var bold:Object = {fontFamily:boldFont.fontName};

var ss:StyleSheet = new StyleSheet();
ss.setStyle(".bold", bold);
ss.setStyle(".regular", regular);

testFld.embedFonts = true;
testFld.styleSheet = ss;
testFld.htmlText = "<span class='regular'>testing </span><span class='bold'>123</span>";

// I can see the embedded regular font开发者_Python百科 and bold font in a same dynamic html textfield correctly.

BUTTTTTTTTTTTTTTTTTTTTTT

In my actual project implementation, I have to host the fonts hosted in another swf. So I simply modified in this way:

Instead of declaring new font the in the main.fla, i imported the BigFont and RegularFont from another fonts.swf (dynamic fonts sharing)

HERE COMES THE PROBLEM, THESE TWO LINES WONT COMPILE

var regularFont:Font = new RegularFont();
var boldFont:Font = new BoldFont();

Flash IDE is throwing this error: 1180: Call to a possibly undefined method RegularFont.

WHYYYYYYYYYYYYYYYYYYYYYYY?


because you have no longer defined RegularFont or BoldFont in the compiler presumably. you have to extract the classes from the other swf, like so:

font SWF

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号