2
我是flash新手,想要在flash as3和Flash player 10中加載xml文件。 我不想使用TLF ! (TextLayoutFramework),因爲它在編譯時引發錯誤
當我以utf-8編碼加載我的XML時,這些詞按從左到右而不是從右到左的順序排列 - 每個詞都寫在最後一個詞之前而不是之後。在Flash(AS3)中加載RTL(從右到左的語言文本)XML文件
任何想法如何解決這個問題?
這裏是我的XML裝載機代碼:
var css_file:String = "gstyle.css";
var fa_item_list = new Array();
var fa_item_group:MovieClip = new MovieClip();
var item_width:Number = fa_mask.width;
var item_height:Number = 0;
var item_spacing:Number = 15;
var item_padding:Number = 0;
var i:Number;
var total:Number;
var fa_xml:XML = new XML();
var fa_style:StyleSheet = new StyleSheet();
var css_loader:URLLoader = new URLLoader();
function push_array(e:Event):void
{
fa_xml = XML(e.target.data);
total = fa_xml.item.length();
for(i = 0; i < total; i++)
{
fa_item_list.push({ content: fa_xml.item[i].content.toString() });
}
load_css();
}
function load_xml(xml_file:String):void
{
var xml_loader:URLLoader = new URLLoader();
xml_loader.load(new URLRequest(xml_file));
xml_loader.addEventListener(Event.COMPLETE, push_array);
}
function load_css():void
{
css_loader.load(new URLRequest(css_file));
css_loader.addEventListener(Event.COMPLETE, css_complete);
}
function css_complete(e:Event):void
{
var css_format:TextFormat = new TextFormat();
fa_style.parseCSS(css_loader.data);
create_item_list();
}
function create_item_list():void
{
for(i = 0; i < total; i++)
{
var fa_item = new MovieClip();
fa_item.addChild(create_item_desc(fa_item_list[i].content));
fa_item.addChildAt(create_item_bg(fa_item.height, i), 0);
fa_item.y = item_height;
item_height += fa_item.height + item_spacing;
fa_item_group.addChild(fa_item);
}
this.addChild(fa_item_group);
fa_item_group.mask = fa_mask;
fa_sb.scrolling("fa_item_group", "fa_mask", 0.50); // ScrollBar Added
}
function create_item_bg(h:Number, item_no:Number)
{
var fm_rect:Shape = new Shape();
fm_rect.graphics.beginFill(0xDED9D1, 0); // ITEM BACKGROUND COLOR
fm_rect.graphics.drawRoundRect(0, 0, item_width, h + item_padding * 2, 0);
fm_rect.graphics.endFill();
return fm_rect;
}
function create_item_desc(item_desc:String)
{
var fm_text = new TextField();
fm_text.x = item_padding;
fm_text.y = item_padding;
fm_text.width = item_width - item_padding * 2;
fm_text.styleSheet = fa_style;
fm_text.htmlText = item_desc;
fm_text.multiline = true;
fm_text.wordWrap = true;
fm_text.selectable = false;
fm_text.autoSize = TextFieldAutoSize.LEFT;
return fm_text;
}
什麼是正在使用TLF時拋出的錯誤?另外,你在哪裏調用load_xml()函數與上面的代碼? – TheDarkIn1978