This is very useful if you do custom actions based on XML or any other method. This post explains thing quite nicely:
http://thillerson.wordpress.com/2007/03/01/runtime-class-instantiation-in-actionscript-30/
Tuesday, March 30, 2010
Friday, March 5, 2010
AS3: Does my xml doc contain a attribute
This is a simple check which increases the ease of using xml.
if you have a xml file like so:
<root_node some_attribute="">
</root_node>
in AS3 you can decide if a attribute exist by using the lenght() method. So code using the xml would be:
Note it is easy to make a mistake and forget to use length as a method i.e. "length()" and use it as variable i.e. just "length" which will not work.
if you have a xml file like so:
<root_node some_attribute="">
</root_node>
in AS3 you can decide if a attribute exist by using the lenght() method. So code using the xml would be:
var my_xml:XML = some_function_to_get_xml();
if( my_xml.@some_attribute.length() != 0 ) {
trace("Yup, some_attribute exists");
}
if( my_xml.@some_non_existant_attribute.length() != 0) {
trace("This will not be printed since attribute does not exist");
}
Note it is easy to make a mistake and forget to use length as a method i.e. "length()" and use it as variable i.e. just "length" which will not work.
Subscribe to:
Posts (Atom)