我是 flash 新手,想在 flash as3 和 Flash player 10 中加载 xml 文件。我不想使用 TLF!(TextLayoutFramework) 因为它在编译时会引发错误当
我以 utf-8 编码加载我的 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;
}