PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
random image/xml loader problem
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: random image/xml loader problem

  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    47

    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)

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    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.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    oh wait now I'm getting the XML

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    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>"
    }

  5. #5
    Member
    Join Date
    Jan 2011
    Posts
    47
    Thanks it worked!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center