Actionscript 3 Actionscript:定时文本格式xml

Actionscript 3 Actionscript:定时文本格式xml,actionscript-3,flash,Actionscript 3,Flash,我不熟悉actionscript。有谁能帮助我尝试以以下定时文本格式从XML中获取值: <?xml version="1.0" encoding="UTF-8"?> <tt xml:lang="en" xmlns:tts="http://www.w3.org/2006/10/ttaf1#styling" xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata" xmlns:smpte="http://www

我不熟悉actionscript。有谁能帮助我尝试以以下
定时文本格式从XML中获取值

<?xml version="1.0" encoding="UTF-8"?>
<tt xml:lang="en"
    xmlns:tts="http://www.w3.org/2006/10/ttaf1#styling"
    xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata"
    xmlns:smpte="http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt"
    xmlns:m608="http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt#cea608">
   <head>
      <ttm:title>SCCconvert </ttm:title>
      <ttm:desc>converted document; </ttm:desc>
      <ttm:copyright>Copyright (C) Computer Prompting and Captioning Co.</ttm:copyright>
      <styling>
      <style xml:id='basic' tts:color='white' tts:fontFamily='proportionalSansSerif' 
            tts:lineHeight='8%' 
            tts:fontSize='8%' 
            tts:fontWeight='bold'
            tts:textOutline='black 8% 8%' />
      </styling>
      <layout>
         <region xml:id='pop1' tts:backgroundColor='transparent'></region>
         <region xml:id='pop2' tts:backgroundColor='blue'></region>
       </layout>
   </head>
   <body>
      <div>
         <p region='pop1' style='basic' xml:space='preserve' begin='00:00:02:05' end='00:00:06:16' tts:origin='47% 10%'>
            <span>♫</span>
         </p>
         <p region='pop1' style='basic' xml:space='preserve' begin='00:00:06:16' end='00:00:08:05' tts:origin='27% 84%'>
            <span>I can&apos;t do this!</span>
         </p>
         <p region='pop2' style='basic' xml:space='preserve' begin='00:00:08:05' end='00:00:09:17' tts:origin='10% 78%'>
            <span>You fail because</span>
         </p>
        </div>
   </body>
</tt>

SCCconvert
转换文件;
版权所有(C)计算机提示和字幕公司。

我能&apos;不要这样做!

你失败是因为


我可以读取XML值,如果它是正常形式的。但是我需要以
部分中提到的样式显示值,这段代码将帮助您解析xml

import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;


var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onXMLLoaded);
loader.load(new URLRequest("style.xml"));

function onXMLLoaded(e:Event){
    loader.removeEventListener(Event.COMPLETE, onXMLLoaded);

    var xml:XML = new XML(loader.data);

    var xlist:XMLList = xml.head.layout.child("region");

    for(var i=0;i<xlist.length();i++){
        trace("--->"+xlist[i].attributes()[0]);
        trace("--->"+xlist[i].attributes()[1]);
    }
}
导入flash.net.urloader;
导入flash.events.Event;
导入flash.net.URLRequest;
变量加载器:URLLoader=新的URLLoader();
addEventListener(Event.COMPLETE,onXMLLoaded);
load(新的URLRequest(“style.xml”);
onXMLLoaded函数(e:事件){
removeEventListener(Event.COMPLETE,onXMLLoaded);
var xml:xml=新的xml(loader.data);
var xlist:XMLList=xml.head.layout.child(“区域”);

对于(var i=0;i这是因为您的属性前面有一个名称空间,所以您必须为ttm、tts等创建一个新的名称空间,然后使用它访问属性

访问layout.region节点内所有backgroundColor的示例:

// namespace creation for tts
var tts:Namespace=new Namespace("http://www.w3.org/2006/10/ttaf1#styling");

// and use of the namespace tts for accessing the attribute
// @my_namespace::my_attribute
trace(xml..layout.region.@tts::backgroundColor.toXMLString());
wonderfl上的实时示例:

关于在Adobe channel上使用xml命名空间的文章: