问问题
3609 次
3 回答
2
正如你所说,Flash 在样式表方面存在问题。也许您应该尝试直接在 as3 中设置样式!一直为我工作!
var style:StyleSheet = new StyleSheet();
var hover:Object = new Object();
hover.color = "#FF9900";
var link:Object = new Object();
link.fontWeight = "bold";
link.textDecoration= "underline";
link.color = "#00FF00"; //green
style.setStyle("a:link", link);
style.setStyle("a:hover", hover);
html_txt.styleSheet = style;
那就是链接问题!对于其他人,我必须自己测试,当我这样做时我会更新答案!但是您可以尝试在 as3 中设置所有样式属性。
于 2013-03-10T16:04:02.220 回答
0
在 CSS 中使用 a:link 设置 Flash 中的链接样式。
插入具有特定样式(没有行高)的段落标签有效地解决了标题问题。
还没有弄清楚粗体和斜体,但这并不是一个主要的担忧。如果有人这样做,请告诉我!
这是任何感兴趣的人的当前工作代码:
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.text.TextField;
import flash.events.ProgressEvent;
import fl.text.TLFTextField;
var fonts:Array = Font.enumerateFonts();
for each (var font:Font in fonts)
{
trace( font.fontName+":"+font.fontType );
}
var rss_xml:XML = new XML();
var test_txt:TLFTextField = new TLFTextField ;
with (test_txt)
{
antiAliasType = AntiAliasType.ADVANCED;
width = 940;
height = 600;
x = 0;
y = 0;
autoSize = TextFieldAutoSize.LEFT;
wordWrap = true;
embedFonts = true;
}
var sulsc_style:StyleSheet = new StyleSheet();
var css_loader:URLLoader = new URLLoader();
css_loader.load(new URLRequest("sulsc_style.css"));
css_loader.addEventListener(Event.COMPLETE, onCSSComplete);
function onCSSComplete(e:Event):void
{
sulsc_style.parseCSS(e.target.data);
rss_xml.ignoreWhitespace = false;
var rss_loader:URLLoader = new URLLoader(new URLRequest("http://news.sulsc.org/feed"));
rss_loader.addEventListener(Event.COMPLETE,rss_loaded);
l.mode = "manual";
rss_loader.addEventListener(ProgressEvent.PROGRESS,rss_load);
}
function rss_load(e:ProgressEvent):void
{
//trace(e.bytesLoaded/(113*1024));
l.setProgress(e.bytesLoaded,(113*1024));
}
function rss_loaded(e:Event):void
{
removeChild(l);
l = null;
rss_xml = XML(e.target.data);
rss_xml.ignoreWhiteSpace = true;
var rss_raw:String = String(rss_xml);
rss_raw = rss_raw.split(":encoded").join("");
rss_raw = rss_raw.split("\n").join("");
rss_raw = rss_raw.split('<p style="text-align: right;">').join('<p class="right">');
rss_raw = rss_raw.split('<p style="text-align: center;">').join('<p class="centre">');
rss_raw = rss_raw.split('<p style="text-align: left;">').join('<p class="left">');
rss_raw = rss_raw.split('<p style="text-align: justify;">').join('<p class="just">');
var heading_replace:RegExp = new RegExp("(</h[0-9]>)(<h[0-9]>)","g9");
var underline_replace:RegExp = new RegExp('<span style="text-decoration: underline;">(.*?)</span>',"gi");
var bold_replace:RegExp = new RegExp('<strong>(.*?)</strong>',"gi");
var italic_replace:RegExp = new RegExp('<em>(.*?)</em>',"gi");
rss_raw = rss_raw.replace(heading_replace,'$1<p class="space"></p>$2');
rss_raw = rss_raw.replace(underline_replace,'<u>$1</u>');
rss_raw = rss_raw.replace(bold_replace,'<b>$1</b>');
rss_raw = rss_raw.replace(italic_replace,'<i>$1</i>');
rss_xml = XML(rss_raw);
test_txt.styleSheet = sulsc_style;
test_txt.htmlText = rss_xml.channel.item.(guid == "http://news.sulsc.org/?page_id=400").content;
addChild(test_txt);
}
和CSS:
/*
flash doesn't support:
-bold and italic
-strikethrough
*/
p, ol, ul, li, body {
font-family: Fontin Sans Rg;
font-size: 12pt;
color: #666666;
text-align: justify;
padding-bottom: 12px;
padding-top: 6px;
}
h1 {
font-family: Nilland;
font-size: 30pt;
text-align:left;
color: #999999;
}
h2 {
font-family: Nilland;
font-size: 20pt;
color: #ff9900;
margin-left:25px;
letter-spacing: 1px;
}
h3 {
font-family: GeosansLight;
font-size: 16pt;
text-align:left;
color: #999999;
margin-left:50px;
letter-spacing: 1px;
}
h4, h5, h6 {
font-family: GeosansLight;
font-size: 14pt;
text-align:left;
color: #999999;
margin-left:75px;
letter-spacing: 1px;
}
ol, ul, li {
margin-left: 50px;
line-height:5px
}
b-quote,blockquote {
font-family: Fontin Sans Rg;
font-style:italic;
color:#999999;
margin-left: 100px;
margin-right: 100px;
padding-bottom: 12px;
}
a:link {
text-decoration: underline;
color: #666666;
}
a:hover {
color: #FF9900;
text-decoration: underline;
}
/* DO NOT DELETE THESE */
.space {
line-height:1px;
padding-bottom: 0px;
padding-top:0px;
}
.right {
text-align:right;
}
.centre {
text-align:center;
}
.left {
text-align:left;
}
.just {
text-align:justify;
}
这使得:
谢谢你的帮助!
于 2013-03-10T19:10:12.607 回答
0
在粗体/斜体问题上,我们发现我们需要完全独立的字体/类来处理它们。因此,您需要分别导出一个常规、斜体和粗体样式的字体,然后将相应的部分包装在字体标签中。我们使用 and 进行查找/替换,将 parentClassName_italic 添加到字体标签,然后指向 css 中导出的字体。一个真正的皮塔饼,但你去。
于 2013-09-12T22:48:00.923 回答