Strange XML parsing error
/**
* Copyright Quasimondo ( http://wonderfl.net/user/Quasimondo )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/7NY8
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.accessibility.Accessibility;
public class XMLTest extends Sprite {
private var tf:TextField;
private var xml:XML = <uielement type="Slider" label="Slider" ui="true" active="true" id="324">
<parameters>
<parameter id="decimals" value="0" label="Decimals" randomize="true" type="NUMBER" order="3" input="228"/>
<parameter id="value" value="0" label="Intensity" randomize="true" type="NUMBER" order="0" input="225" output="224"/>
<parameter id="max" value="100" label="Maximum Value" randomize="true" type="NUMBER" order="2" input="227"/>
<parameter id="label" value="Intensity" randomize="true" type="STRING" order="10"/>
<parameter id="order" value="0" randomize="true" type="NUMBER" order="11"/>
<parameter id="min" value="-100" label="Minimum Value" randomize="true" type="NUMBER" order="1" input="226"/>
</parameters>
</uielement>
public function XMLTest()
{
tf = new TextField();
addChild( tf );
tf.autoSize = "left";
test1();
test2();
}
private function test1():void
{
var l:String = xml..parameter.(@id=="label").@value;
switch ( xml.@type.toString() )
{
case "Slider":
tf.text = "Test 1: "+l + "\n";
break;
default:
trace( xml.@type )
break;
}
}
private function test2():void
{
switch ( xml.@type.toString() )
{
case "Slider":
// This still works:
tf.appendText( "Test 2: "+xml..parameter.(@id=="label").@value +"\n");
// This will cause an error
// var l:String = xml..parameter.(@id=="label").@value;
// This workaround found by @deafmetal fixes it:
var l:String = "";
l = xml..parameter.(@id=="label").@value;
break;
default:
trace( xml.@type )
break;
}
}
}
}