-
random image/xml loader problem
hey,
i am making a quiz that gives random image and 3 statements about it.
and i can't find the problem in my script:
Code:
var high:Number = 3;
var low:Number = 1;
Next_btn.addEventListener(MouseEvent.CLICK, randomImageEvent);
function randomImageEvent(e:MouseEvent):void
{
var randomnumber:String = (Math.floor(Math.random()*(1+high-low))+low).toString();
var request:URLRequest = new URLRequest("http://foxchannelsbenelux.com/fb/images/" + randomnumber + ".jpg");
var XMLLoader:URLLoader = new URLLoader();
XMLLoader.load(new URLRequest("http://www.foxchannelsbenelux.com/fb/NatGeo%20Wild%20Quiz/" + randomnumber + ".xml"));
XMLLoader.addEventListener(Event.COMPLETE, processXML);
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
}
function processXML(e:Event):void{
var myXML:XML = new XML(e.target.data);
vraag1.htmlText = "<font color='#000000'>" + myXML.stellingen.stelling1.text + "</font>"
vraag2.htmlText = "<font color='#000000'>" + myXML.stellingen.stelling2.text + "</font>"
vraag3.htmlText = "<font color='#000000'>" + myXML.stellingen.stelling3.text + "</font>"
}
the XML is in dutch but i think it doesn't matter ^^
if anyone can help me find out the problem in my script it would be amazing!
the problem wit the script is that it doesn't load the text of the XML file, it loads up but the text that it loads is empty. and yes it can find the XML file.
if you need more info just say it^^
(I'm using AS3.0 and flash CS5.5)
-
KoolMoves Moderator
http://www.foxchannelsbenelux.com/fb/NatGeo%20Wild%20Quiz/" + randomnumber + ".xml"
returns 404 error with all three numbers substituted.
I'd start by doing some trace commands to make sure you are getting what you expect from the server.
-
KoolMoves Moderator
oh wait now I'm getting the XML
-
KoolMoves Moderator
Here you go. small change in your function
Actionscript Code:
function processXML(e:Event):void{ var myXML:XML = new XML(e.target.data); trace (myXML.stelling1); vraag1.htmlText = "<font color='#000000'>" + myXML.stelling1.text + "</font>" vraag2.htmlText = "<font color='#000000'>" + myXML.stelling2.text + "</font>" vraag3.htmlText = "<font color='#000000'>" + myXML.stelling3.text + "</font>" }
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|