filling and accessing data from a value object

I had a problem loading and accessing data from a value object in my new project. I upload an XML file through a service that contains the header and location of the asset files, I need to be able to access the location of the asset file by specifying the header and getting it from the value object. I am using Robotlegs framework, here is an xml example:

<?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>

Then I put this data in the value object as a dictionary hash.

//-----------  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( file.@title.toString(),
     file.location.toString()
);

 filePathModel.locationList.push(filePathVO);
filePathModel.locationHash[filePathVO.title] = filePathVO;
 }

I checked access to this from the view component.

// accessing from another class -----------------

var _background_image_path:String = String( filePathModel.locationHash['shell_background_image']);

it returns vague .. any ideas?

+3
source share
1 answer

@ :

var filePathVO:DataVO = new FilePathVO(file.@title.toString(),
     file.location.toString());

:

var files:XMLList = xml.files.file;

var files:XMLList = xml.file;

xml xml; xml.files. xml.files.file file, files, root-xml. , xml - :

<?xml version="1.0" encoding="utf-8" ?>
<root>
  <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>
</root>
+1

Source: https://habr.com/ru/post/1752572/


All Articles