3
我有一個問題,加載和訪問我的新項目中的值對象的數據..我通過一個服務,其中包含資產文件的標題和位置加載一個XML文件,我需要能夠通過指定標題和值對象retrieiving它訪問的資源文件的位置..我使用的Robotlegs框架,這裏的XML的例子: -填充和訪問值對象的數據
<?xml version="1.0" encoding="utf-8" ?>
<files id ="xmlroot">
<file title="css_shell" location = "css/shell.css" />
<file title="xml_shell" location = "xml/shell.xml" />
<file title="test" location= "test/location/test.jpg" />
<file title ="shell_background_image" location = "images/shell_images/background_image.jpg" />
</files>
然後我將此數據作爲字典哈希推入一個值對象..希望
//----------- populate value objects ------------------------------------
var xml:XML = new XML(xml);
var files:XMLList = xml.files.file;
for each (var file:XML in files) {
var filePathVO:DataVO = new FilePathVO([email protected](),
file.location.toString()
);
filePathModel.locationList.push(filePathVO);
filePathModel.locationHash[filePathVO.title] = filePathVO;
}
我測試過從視圖組件訪問它。
// accessing from another class -----------------
var _background_image_path:String = String(filePathModel.locationHash['shell_background_image']);
它返回undefined ..任何想法?
感謝馬丁:-)