<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Qns 1" viewActivate="creationComplete()"
>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
privatevar myXML:XML;
privatevar myLoader:URLLoader;
privatefunction creationComplete():void {
var ran:Number=Math.round(Math.random()*40);
trace(ran);
myLoader = new URLLoader();
myLoader.load(new URLRequest("assets/questions.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);
questionLabel.text = myXML.question[ran-1].text;
ans1Btn.label=(myXML.question[ran-1].ans1.te xt());
ans2Btn.label=(myXML.question[ran-1].ans2.te xt());
ans3Btn.label=(myXML.question[ran-1].ans3.te xt());
}
}
]]>
</fx:Script>
<s:Image x="0" y="0" width="320" height="415" source="assets/qns1.jpg"/>
<s:Button x="168" y="355" width="139" height="33" label="Next" click="navigator.pushView(qns2)"/>
<s:Label id="questionLabel" x="25" y="35" width="267" height="79" color="#000000"
fontFamily="_sans" fontSize="16" fontStyle="normal" textAlign="center"
textDecoration="none"/>
<s:Button x="26" y="355" width="134" height="33" label="Back" click="navigator.popView()"/>
<s:Button id="ans1Btn" x="25" y="173" width="268" height="45" fontSize="12" />
<s:Button id="ans2Btn" x="26" y="227" width="268" height="45" fontSize="12"/>
<s:Button id="ans3Btn" x="26" y="289" width="268" height="45" fontSize="12"/>
</s:View>