Strange Text/XML Behavior

Ask a Question related to Macromedia Flash Sitedesign, Design and Development.

  1. #1

    Default Strange Text/XML Behavior

    I have a strange problem that I spent quite some time trying to debug last night. I'll try and explain this as well as I can.

    I have a simple base movie that contains a dynamic text box. There is only one frame in the base movie, which contains several functions. The script of frame 0 says:

    init();
    getAuthors();
    showAuthors();
    stop();

    The init() function creates a global array to store a list of book authors. That array is populated from the getAuthors() function via a PHP XML feed. During the loading of the array, I output each array element to the text box as they are added. The showAuthors() function is setup to to display the length of the array in the dynamic text box, and then loop through the array and display all elements to the same text box.

    Here's the problem. I've debugged this sucker with break points at the init(), getAuthors(), and showAuthors() function. The functions run in the order inteded. However, the text box lists the following output:

    Array size from ShowAuthors() = 0
    Terry Brooks
    Robin Hobb
    Anne McCaffrey
    Array size from getAuthors() = 3

    How is it that the text from the showAuthors() function is showing up before the output text from getAuthors() function? How can that be when the getAuthors() function is running first? That, and it seems that the text doesn't show until every possible function is completed in frame 1. Am I missing something?




    Dahgu webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Strange behavior
      The problem seems to be in c code calling ruby calling c code. ======== start test.rb puts "about to require curses" require "curses" puts...
    2. Strange behavior of $.
      Apparently $. is not always set correct (see second ruby 1liner). Is this a bug? 12:12:42 : cat -n n 1 2 3 BAR="hello" 4 12:12:47 : ruby...
    3. ruby 1.8 strange behavior
      Hi, I've started making my own C extension to ruby, and found that strange behavior: class MyTest def =(key,val) "my_own_return_value" end end...
    4. Strange cookie behavior
      Maybe the remote server is in a different time zone. Ray at work -- Will trade ASP help for SQL Server help "AHN" <anerse@excite.com>...
    5. Why strange IF...ELSE behavior
      Hi all, I'm getting a strange result with the following IF statement: $bar = ($foo == 'last') ? true : false; In my script $foo normaly has...
  3. #2

    Default Re:Strange Text/XML Behavior

    Can anyone help with this strange XML.load problem?

    I decided to pear down the code a bit, include it here, and show the trace. What makes no sense to me is that all of the functions seem to run through, and THEN the dang XML.load fires at the very end. As you'll see in the trace, the getAuthors() function runs but no XML is loaded until AFTER every other function is complete. It makes no sense. :) Please help if you can.

    //Intialize the movie.
    init();
    //Load the authors XML doc into the authors array.
    getAuthors();
    //Trace out all the elements in the authors array.
    showAuthors();
    //Stop the movie.
    stop();

    function init() {
    //Change XML prototypes
    XML.prototype.ignoreWhite = true;
    XML.prototype.contentType = "text/xml";
    //Set global variables
    _global.serverPath = "http://zeus/bookshelf/";
    _global.authorsArray = new Array();
    }

    function getAuthors() {
    trace("Begin getAuthors() function");
    myXML = new XML();
    myXML.onLoad = function (success) {
    if (success) {
    for (i=0 ; i < this.firstChild.childNodes.length ; i++) {
    id = this.firstChild.childNodes.attributes["id"];
    name = this.firstChild.childNodes.attributes["name"];
    authorsArray = new Array(id, name);
    trace(authorsArray[0] + " " + authorsArray[1]);
    }
    } else {
    trace("Loading Error!");
    }
    }
    myXML.load (serverPath + "getAllAuthors.php");
    trace("End of getAuthors() function");
    }

    function ShowAuthors() {
    trace("Begin ShowAuthors() function");
    trace("Authors array length is " + authorsArray.length);
    for (i=0 ; i < authorsArray.length ; i++) {
    trace(authorsArray[0] + authorsArray[1]);
    }
    trace("End ShowAuthors() function");
    }

    ******* TRACE for the code above *******
    Begin getAuthors() function
    End of getAuthors() function
    Begin ShowAuthors() function
    Authors array length is 0
    End ShowAuthors() function
    14 -none-
    6 Angus Wells
    13 Anne McCaffrey
    4 Deborah Chester
    1 J.V. Jones
    8 Margaret Weis and Tracy Hickman
    9 Michael Crichton
    5 Micky Zucker Reichert
    12 Piers Anthony
    11 Robert N. Charrette
    2 Robin Hobb
    7 Stephen King
    3 Terry Goodkind
    10 Ursula K. LeGuin



    Dahgu webforumsuser@macromedia.com Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139