dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Having some scoping issues.

  1. #1
    Has Returned
    Join Date
    Mar 2001
    Posts
    269

    Having some scoping issues.

    Hello all, i am having some trouble working some some XML function and getting some vaules into the root. Maybe someone can help me?

    I have this code:
    Code:
    ladderXML = new XML();
    ladderXML.load("ladder.xml");
    ladderXML.ignoreWhite = true;
    ladderXML.onLoad = extractData;
    
    
    function extractData(success) {
    	rootHandler = this.firstChild.childNodes;
    	gimble = rootHandler[1].attributes.PicURL;
    	trace(gimble)//works;
    }
    trace(gimble)//unidentified;
    As you can see in my commented code the trace which sits outside of the function is unidentified.

    I tried using _root.gimble when setting the variable and calling it but this was giving me the same result, which i find very odd as i thought _root worked from anywhere (although bad practice, i know).

    Thanks in advance if you can help me understand.
    Turbs.

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    It's not a scoping issue so much as it is a time/sequence issue.
    When you view the trace output, the 'unidentified' will show up before the 'working' trace. This is because flash doesn't wait for a function to complete, it keeps on processing. So the trace outside the function will happen before the trace inside the function has a chance to happen.

    HTH

  3. #3
    Has Returned
    Join Date
    Mar 2001
    Posts
    269
    Of course, should have realised that. threw in a preloader and it all works fine.

    Thanks!

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