XML loads properly in .SWF but not in .AS

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

  1. #1

    Default XML loads properly in .SWF but not in .AS

    I have the following script which works jim-dandy when implimented as a frame
    script in my .swf, but I don't want it there, I want it in a class I've created
    called FigureItem. I've stripped the script down to just the part that loads
    the XML. When the script is inside the .swf (without the class constructor,
    obviously) 'trace(contentXML)' correctly returns the formatted XML. Inside the
    ..as 'trace(contentXML)' returns 'undefined'. SOMETHING is loading becase
    'trace("yay")' returns 'yay'. (loadXML gets called by the FiguireItem movie
    clip inside the .swf).

    class FigureItem extends MovieClip {
    var rollBox:MovieClip;
    var contentXML:XML;
    //
    public function FigureItem() {
    contentXML = new XML();

    }
    public function loadXML(myURL:String):Void {


    contentXML.onLoad = function(success:Boolean):Void {
    if (success) {
    trace ("yay");
    trace(contentXML);
    } else {
    trace ("yay");
    }
    };
    contentXML.load(myURL);
    }
    }

    maija_g Guest

  2. Similar Questions and Discussions

    1. Webpage loads with the below error
      :confused; Server Error in '/' Application. -------------------------------------------------------------------------------- Parser Error...
    2. site loads slow
      My site www.puroconjunto.com was created in Purlisher 2002. I had background music (since it is a music site) and the whole works. All of a...
    3. Preload while video loads
      Hi, I have a flash file that contains a large video file and I am calling it into Director via loadmovie from another flash file already in...
    4. Help, page loads twice
      I need help! A page I'm working on builds an HTML string based on a bunch of data in different tables and databases. Then it does a response.write...
  3. #2

    Default Re: XML loads properly in .SWF but not in .AS

    contentXML is out of scope from the XML object;
    Here are a few ways to deal with scope:

    public function loadXML(myURL:String):Void {

    var xmlOwner = this;
    contentXML._OWNERREF = this;
    contentXML.onLoad = function(success:Boolean):Void {
    if (success) {
    trace ("yay");
    trace(this); // <===
    trace(xmlOwner.contentXML); // <=====
    trace(this._OWNERREF.contentXML); // <=========
    } else { trace ("yay"); }
    };


    contentXML.load(myURL);
    }



    Raymond Basque Guest

  4. #3

    Default Re: XML loads properly in .SWF but not in .AS

    Thanks, but that doesn't seem to work. I copied and pasted and immediately got
    a pile of errors. I commented out all the stuff you added in until there were
    no errors and then started uncommenting until I got an error. Below is the
    first one.

    class FigureItem extends MovieClip {
    var contentXML:XML;
    //
    public function FigureItem() {
    contentXML = new XML();
    contentXML.onLoad = function(success:Boolean):Void {
    if (success) {
    trace ("yay");
    //trace(this); // <===
    //trace(xmlOwner.contentXML); // <=====
    //trace(this._OWNERREF.contentXML); // <=========
    } else {
    trace ("booooo");
    }
    };

    contentXML.load(myURL);
    }
    }



    /**Error** blah/blah/blah/FigureItem.as: Line 11: There is no property with
    the name '_OWNERREF'.
    contentXML._OWNERREF = this;
    */

    maija_g Guest

  5. #4

    Default Re: XML loads properly in .SWF but not in .AS

    Never mind, the 'trace (this)' and 'trace (xmlOwner.contentXML)' both worked so I'll use one of those. Thanks!!
    maija_g 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