26 Replies Latest reply on Jul 26, 2007 8:54 AM by Newsgroup_User

    XML and AS2.0

    shurleynova
      OK I have been going down one road for this and have taken a few wrong turns.

      A few things about what we are looking at:
      I am using Flash CS3 but I am using Action Script 1.0/2.0 for compatability purposes.

      What I have been able to do so far is create random instances of a movie clip to appear over a set amount of time but I need to go a bit further. The web application needs to be updated regularly and the best way I can think of doing that is with keeping all the variables in an XML. The problem is I am not sure how to format the XML properly to get Flash to read it and load the variables.

      I am creating an online version of a vision screening tool we use. The test is graphically simple just a collection of a few primitives on a dark background. There are basically two objects a fixation point and a stimulus. What I need to be able to do is this.

      Display either movieclip at (x,y) for (z)ms where x,y,& z are all variables loaded from an xml. I have asked questions along this line before but this is a different scope in case anyone wants to claim I double posted, this is quite different than they way I was doing it before.

      Any help with the XML or even any actionscript suggestions would be greatly appreciated.

      Thanks
        • 1. Re: XML and AS2.0
          kglad Adobe Community Professional & MVP
          you only need to 3 variable/value pairs to load into flash? if so, the following is all your need. just remember to convert each variable's value to a number for use in flash.

          • 2. Re: XML and AS2.0
            shurleynova Level 1
            Man that was so easy I almost feel retarded. Thank you I was making it way to hard I am kinda new at XML and the make your own <tags> kinda throws me sometimes. I think I need to go get a good XML book any suggestions?
            • 3. Re: XML and AS2.0
              Level 7
              Hi shurleynova,

              XML is pretty versatile; you should be able to get it do do whatever
              you want. With AS2.0, it's also very loose so you can get away with poor
              formatting.

              Let me suggest a format like this to begin with:

              <timeline>
              <point x="20" y="30" z="15"/>
              <point x="10" y="30" z="35"/>
              <point x="60" y="10" z="2"/>
              <point x="80" y="5" z="4"/>
              </timeline>

              This format is actually proper and easy to work with in Flash. Many
              people would parse this data into multi-dimensional arrays but this is
              automatically done by Flash. If you save this to a file named
              "timeline.xml", your script would look something like this:

              var timelineXML=new XML();

              timelineXML._context=this;
              timelineXML.ignoreWhite=true;

              timelineXML.onLoad=function(success:Boolean) {
              trace ('Data loaded: '+success);
              this._context.parseXMLData(this.firstChild);
              }//onLoad

              function parseXMLData(data:XMLNode) {
              for (var count:Number=0;count<data.childNodes.length;count++) {
              var currentNode:XMLNode=data.childNodes[count];
              var xValue:Number=Number(currentNode.attributes.x);
              var yValue:Number=Number(currentNode.attributes.y);
              var zValue:Number=Number(currentNode.attributes.z);
              trace ('x='+xValue);
              trace ('y='+xValue);
              trace ('z='+xValue);
              }//for
              }//parseXMLData

              timelineXML.load('timeline.xml');

              If you wanted to access a specific node in the list once the data is
              loaded, a simple function like this does the trick:

              function getPointNode(index:Number):XMLNode {
              return (timelineXML.firstChild.childNodes[index]);
              }//getPointNode

              As you can see, XML is parsed into an associative array so dealing with
              it in memory is very straightforward. If you wanted to get the "x" value
              from node 1 (index 0), you would call:

              var myXValue=getPointNode(0).attributes.x;

              Just keep in mind that all attributes are text so if you want to work
              with them as numbers, convert them first.

              And there you go!

              Patrick

              shurleynova wrote:
              > OK I have been going down one road for this and have taken a few wrong turns.
              >
              > A few things about what we are looking at:
              > I am using Flash CS3 but I am using Action Script 1.0/2.0 for compatability
              > purposes.
              >
              > What I have been able to do so far is create random instances of a movie clip
              > to appear over a set amount of time but I need to go a bit further. The web
              > application needs to be updated regularly and the best way I can think of doing
              > that is with keeping all the variables in an XML. The problem is I am not sure
              > how to format the XML properly to get Flash to read it and load the variables.
              >
              > I am creating an online version of a vision screening tool we use. The test is
              > graphically simple just a collection of a few primitives on a dark background.
              > There are basically two objects a fixation point and a stimulus. What I need to
              > be able to do is this.
              >
              > Display either movieclip at (x,y) for (z)ms where x,y,& z are all variables
              > loaded from an xml. I have asked questions along this line before but this is a
              > different scope in case anyone wants to claim I double posted, this is quite
              > different than they way I was doing it before.
              >
              > Any help with the XML or even any actionscript suggestions would be greatly
              > appreciated.
              >
              > Thanks
              >

              --
              http://www.baynewmedia.com
              Faster, easier, better...ActionScript development taken to new heights.
              Download the BNMAPI today. You'll wonder how you ever did without it!
              Available for ActionScript 2.0/3.0.
              • 4. Re: XML and AS2.0
                Level 7
                I wouldn't waste money on an XML book. The format is open by
                specification, meaning you can do with it what you like. It's better if
                you do some experiments to see how nodes and attributes are accessed in
                Flash, then you make up any XML formats you want. That's the beauty of
                XML, it's eXtensible.

                Patrick

                shurleynova wrote:
                > Man that was so easy I almost feel retarded. Thank you I was making it way to
                > hard I am kinda new at XML and the make your own <tags> kinda throws me
                > sometimes. I think I need to go get a good XML book any suggestions?
                >

                --
                http://www.baynewmedia.com
                Faster, easier, better...ActionScript development taken to new heights.
                Download the BNMAPI today. You'll wonder how you ever did without it!
                Available for ActionScript 2.0/3.0.
                • 5. Re: XML and AS2.0
                  Damon Edwards Level 3
                  I bought "Foundation XML for Flash" a long time ago when I was starting out.. It helped a great deal.
                  • 6. Re: XML and AS2.0
                    shurleynova Level 1
                    What if I had several variables for each such as I had 4 different movieclips, each had to display for only 200ms, and there were 10 possible x and 10 possible y coordinates for each would I format it like this?

                    Then in my actionscript just have it load the next variable from the list? I think this is where I am stuck.

                    • 7. Re: XML and AS2.0
                      shurleynova Level 1
                      Oh I didnt see that post from Patrick B when I posted that last one I think that migth be what I needed to know, thanks all I'll be back if I still get stuck.
                      • 8. Re: XML and AS2.0
                        shurleynova Level 1
                        Ok I have it I created an xml using the example from Patrick B and I can see in the Output window that the variables are loaded correctly. The XML and AS is formatted like the code attached I get an out put that looks like this:

                        Data loaded: true
                        object_type=stimuli
                        x_coordinates=25
                        y_coordinates=25
                        z_display_interval=200
                        object_type=stimuli
                        x_coordinates=85
                        y_coordinates=175
                        z_display_interval=200
                        object_type=stimuli
                        x_coordinates=325
                        y_coordinates=55
                        z_display_interval=200
                        object_type=stimuli
                        x_coordinates=115
                        y_coordinates=355
                        z_display_interval=200
                        object_type=fixation
                        x_coordinates=289
                        y_coordinates=229
                        z_display_interval=200

                        Thanks to all now I have to figure out how I am going to use the variables to display my clips :)




                        • 9. Re: XML and AS2.0
                          Level 7
                          That's the way we do ;) Good luck!

                          shurleynova wrote:
                          > Ok I have it I created an xml using the example from Patrick B and I can see in
                          > the Output window that the variables are loaded correctly. The XML and AS is
                          > formatted like the code attached I get an out put that looks like this:
                          >
                          > Data loaded: true
                          > object_type=stimuli
                          > x_coordinates=25
                          > y_coordinates=25
                          > z_display_interval=200
                          > object_type=stimuli
                          > x_coordinates=85
                          > y_coordinates=175
                          > z_display_interval=200
                          > object_type=stimuli
                          > x_coordinates=325
                          > y_coordinates=55
                          > z_display_interval=200
                          > object_type=stimuli
                          > x_coordinates=115
                          > y_coordinates=355
                          > z_display_interval=200
                          > object_type=fixation
                          > x_coordinates=289
                          > y_coordinates=229
                          > z_display_interval=200
                          >
                          > Thanks to all now I have to figure out how I am going to use the variables to
                          > display my clips :)
                          >
                          >
                          >
                          >
                          >
                          >
                          > <?xml version="1.0"?>
                          > <!-- Where omc is the object to display xp is x position, yp is y position,
                          > zms is display interval -->
                          > <timeline>
                          > <point omc="stimuli" xp="25" yp="25" zms="200"/>
                          > <point omc="stimuli" xp="85" yp="175" zms="200"/>
                          > <point omc="stimuli" xp="325" yp="55" zms="200"/>
                          > <point omc="stimuli" xp="115" yp="355" zms="200"/>
                          > <point omc="fixation" xp="289" yp="229" zms="200"/>
                          > </timeline>
                          >
                          > // Then the actionScript in Flash looks like this
                          >
                          > var timelineXML=new XML();
                          >
                          > timelineXML._context=this;
                          > timelineXML.ignoreWhite=true;
                          >
                          > timelineXML.onLoad=function(success:Boolean) {
                          > trace ('Data loaded: '+success);
                          > this._context.parseXMLData(this.firstChild);
                          > }//onLoad
                          >
                          > function parseXMLData(data:XMLNode) {
                          > for (var count:Number=0;count<data.childNodes.length;count++) {
                          > var currentNode:XMLNode=data.childNodes[count];
                          > var oValue:String=String(currentNode.attributes.omc);
                          > var xValue:Number=Number(currentNode.attributes.xp);
                          > var yValue:Number=Number(currentNode.attributes.yp);
                          > var zValue:Number=Number(currentNode.attributes.zms);
                          > trace ('object_type='+oValue);
                          > trace ('x_coordinates='+xValue);
                          > trace ('y_coordinates='+yValue);
                          > trace ('z_display_interval='+zValue);
                          > }//for
                          > }//parseXMLData
                          >
                          > timelineXML.load('input.xml');
                          >

                          --
                          http://www.baynewmedia.com
                          Faster, easier, better...ActionScript development taken to new heights.
                          Download the BNMAPI today. You'll wonder how you ever did without it!
                          Available for ActionScript 2.0/3.0.
                          • 10. Re: XML and AS2.0
                            shurleynova Level 1
                            One quick question that has me confused however

                            It is awesome that I now have the variables in Flash from the XML but...

                            I am familiar with attaching variables to dynamic text by adding the variable in the properties box but how do I assign the variable to a movieClip?
                            • 11. Re: XML and AS2.0
                              Level 7
                              Hi again,

                              I *think* what you're asking is, how do you place a variable inside a clip?

                              It's simply: clipInstanceName.variableName=value;

                              For example, say your clip instance is named "magicSquare" and the
                              variable is "myVar":

                              magicSquare.myVar=123;

                              -or-

                              magicSquare['myVar']=123;

                              Is this what you're asking?

                              shurleynova wrote:
                              > One quick question that has me confused however
                              >
                              > It is awesome that I now have the variables in Flash from the XML but...
                              >
                              > I am familiar with attaching variables to dynamic text by adding the variable
                              > in the properties box but how do I assign the variable to a movieClip?
                              >

                              --
                              http://www.baynewmedia.com
                              Faster, easier, better...ActionScript development taken to new heights.
                              Download the BNMAPI today. You'll wonder how you ever did without it!
                              Available for ActionScript 2.0/3.0.
                              • 12. Re: XML and AS2.0
                                shurleynova Level 1
                                sort of
                                the variables contain the x,y coordinates and the name of the movieClip instance as well as a value for a timer event. The last one is not the most important so lets just leave that out for the moment.

                                I was trying to state it with a with statement as in:

                                with(oValue){
                                _x=xValue
                                _y=yValue
                                }

                                but that is when I get the error that the object does not exist. Do I need to add some actionscript to my movieClip to make it work? Or is there another way to do it? Do I need to add an event to the clip itself I guess is what I am asking or do I need to attach the code that makes the clip appear the clip itself?

                                I did already make sure that the clips were exported for Actionscript but that didnt seem to make a difference
                                • 13. Re: XML and AS2.0
                                  Level 7
                                  Hi again,

                                  I'm still a little fuzzy on what you're trying to do. Are you trying to
                                  set the X and Y position of the clip? What is ovalue, or rather, what do
                                  you want it to be? When you trace (ovalue), what do you get? What about
                                  trace (typeof(ovalue))?

                                  Patrick



                                  shurleynova wrote:
                                  > sort of
                                  > the variables contain the x,y coordinates and the name of the movieClip
                                  > instance as well as a value for a timer event. The last one is not the most
                                  > important so lets just leave that out for the moment.
                                  >
                                  > I was trying to state it with a with statement as in:
                                  >
                                  > with(oValue){
                                  > _x=xValue
                                  > _y=yValue
                                  > }
                                  >
                                  > but that is when I get the error that the object does not exist. Do I need to
                                  > add some actionscript to my movieClip to make it work? Or is there another way
                                  > to do it? Do I need to add an event to the clip itself I guess is what I am
                                  > asking or do I need to attach the code that makes the clip appear the clip
                                  > itself?
                                  >
                                  > I did already make sure that the clips were exported for Actionscript but that
                                  > didnt seem to make a difference
                                  >

                                  --
                                  http://www.baynewmedia.com
                                  Faster, easier, better...ActionScript development taken to new heights.
                                  Download the BNMAPI today. You'll wonder how you ever did without it!
                                  Available for ActionScript 2.0/3.0.
                                  • 14. Re: XML and AS2.0
                                    shurleynova Level 1
                                    Hello again,

                                    "Are you trying to
                                    set the X and Y position of the clip? What is ovalue, or rather, what do
                                    you want it to be? When you trace (ovalue), what do you get? What about
                                    trace (typeof(ovalue))?"

                                    I am tracing the oValue and yes I am trying to set the x,y of the clip. The oValue is a variable that is either one of two things "stimuli" or "fixation" and when I trace it that is what is says in the output window. What the oValue is meant to represent is an instance name. but even something as simple as setProperty does not recognize the variable in place of the clip's instance name. So here I am thinking that it may not be possible to pass a variable to call an instance name but it doesn't make sense, because in theory I figure it should work.

                                    thnx a million - your solutions have been the most helpful thus far.
                                    • 15. Re: XML and AS2.0
                                      Level 7
                                      Okay, so "stimuli" and "fixation" are clips, right? You should be able
                                      to simply set:

                                      this[ovalue]._x=xValue;
                                      this[ovalue]._y=yValue;

                                      The only issue that you may encounter is, is "this" the object that
                                      holds the clip. When you trace (this[ovalue]), what do you get? It
                                      should show you a movie clip instance. If not, you need to figure out
                                      where your clips actually are. When you trace (this)...what do you get?
                                      This should give you a clue as to why your clip(s) aren't being targetted.

                                      Patrick

                                      shurleynova wrote:
                                      > Hello again,
                                      >
                                      > "Are you trying to
                                      > set the X and Y position of the clip? What is ovalue, or rather, what do
                                      > you want it to be? When you trace (ovalue), what do you get? What about
                                      > trace (typeof(ovalue))?"
                                      >
                                      > I am tracing the oValue and yes I am trying to set the x,y of the clip. The
                                      > oValue is a variable that is either one of two things "stimuli" or "fixation"
                                      > and when I trace it that is what is says in the output window. What the oValue
                                      > is meant to represent is an instance name. but even something as simple as
                                      > setProperty does not recognize the variable in place of the clip's instance
                                      > name. So here I am thinking that it may not be possible to pass a variable to
                                      > call an instance name but it doesn't make sense, because in theory I figure it
                                      > should work.
                                      >
                                      > thnx a million - your solutions have been the most helpful thus far.
                                      >

                                      --
                                      http://www.baynewmedia.com
                                      Faster, easier, better...ActionScript development taken to new heights.
                                      Download the BNMAPI today. You'll wonder how you ever did without it!
                                      Available for ActionScript 2.0/3.0.
                                      • 16. Re: XML and AS2.0
                                        shurleynova Level 1
                                        Maybe this makes more sense

                                        if I have the following action script on a movieclip

                                        onClipEvent (enterFrame) {
                                        setProperty(_root.stimuli,_x,55);
                                        setProperty(_root.stimuli,_y,115);

                                        }

                                        The instance "stimuli" appears at 55,115 on my stage

                                        what I want to do is replace the instance name, the x and y coodinates with the variables that I loaded from the XML.

                                        for some reason I thought it would be as simple as

                                        onClipEvent (enterFrame) {
                                        setProperty(oValue,_x,xValue);
                                        setProperty(oValue,_y,yValue);

                                        }

                                        but that, while not giving me an error , does nothing I can still see the clip sitting in the position I placed it in to start.

                                        So my thought is my error is in the syntax of the script.
                                        • 17. Re: XML and AS2.0
                                          Level 7
                                          Your notation is a bit archaic but we can work with it :)

                                          onClipEvent (enterFrame) {
                                          setProperty(_root[oValue],_x,xValue);
                                          setProperty(_root[oValue],_y,yValue);

                                          }

                                          Better still:

                                          onClipEvent (enterFrame) {
                                          _root[oValue]._x=xValue;
                                          _root[oValue]._y=yValue;

                                          }

                                          Just make sure xValue and yValue exist and are numbers and you should be
                                          okay. How does that work out?

                                          Patrick


                                          shurleynova wrote:
                                          > Maybe this makes more sense
                                          >
                                          > if I have the following action script on a movieclip
                                          >
                                          > onClipEvent (enterFrame) {
                                          > setProperty(_root.stimuli,_x,55);
                                          > setProperty(_root.stimuli,_y,115);
                                          >
                                          > }
                                          >
                                          > The instance "stimuli" appears at 55,115 on my stage
                                          >
                                          > what I want to do is replace the instance name, the x and y coodinates with
                                          > the variables that I loaded from the XML.
                                          >
                                          > for some reason I thought it would be as simple as
                                          >
                                          > onClipEvent (enterFrame) {
                                          > setProperty(oValue,_x,xValue);
                                          > setProperty(oValue,_y,yValue);
                                          >
                                          > }
                                          >
                                          > but that, while not giving me an error , does nothing I can still see the clip
                                          > sitting in the position I placed it in to start.
                                          >
                                          > So my thought is my error is in the syntax of the script.
                                          >

                                          --
                                          http://www.baynewmedia.com
                                          Faster, easier, better...ActionScript development taken to new heights.
                                          Download the BNMAPI today. You'll wonder how you ever did without it!
                                          Available for ActionScript 2.0/3.0.
                                          • 18. Re: XML and AS2.0
                                            Level 7
                                            If you put this on the frame within the clip itself (rather than on the
                                            clip), you could use:

                                            this.onEnterFrame=function() {
                                            _root[ovalue]._x=xValue;
                                            _root[ovalue]._y=yValue;
                                            }

                                            But maybe that's something you can implement when you get the initial
                                            problem fixed.

                                            Patrick

                                            Patrick B wrote:
                                            > Your notation is a bit archaic but we can work with it :)
                                            >
                                            > onClipEvent (enterFrame) {
                                            > setProperty(_root[oValue],_x,xValue);
                                            > setProperty(_root[oValue],_y,yValue);
                                            >
                                            > }
                                            >
                                            > Better still:
                                            >
                                            > onClipEvent (enterFrame) {
                                            > _root[oValue]._x=xValue;
                                            > _root[oValue]._y=yValue;
                                            >
                                            > }
                                            >
                                            > Just make sure xValue and yValue exist and are numbers and you should be
                                            > okay. How does that work out?
                                            >
                                            > Patrick
                                            >
                                            >
                                            > shurleynova wrote:
                                            >> Maybe this makes more sense
                                            >>
                                            >> if I have the following action script on a movieclip
                                            >>
                                            >> onClipEvent (enterFrame) {
                                            >> setProperty(_root.stimuli,_x,55);
                                            >> setProperty(_root.stimuli,_y,115);
                                            >>
                                            >> }
                                            >>
                                            >> The instance "stimuli" appears at 55,115 on my stage
                                            >>
                                            >> what I want to do is replace the instance name, the x and y
                                            >> coodinates with the variables that I loaded from the XML.
                                            >>
                                            >> for some reason I thought it would be as simple as
                                            >>
                                            >> onClipEvent (enterFrame) {
                                            >> setProperty(oValue,_x,xValue);
                                            >> setProperty(oValue,_y,yValue);
                                            >>
                                            >> }
                                            >>
                                            >> but that, while not giving me an error , does nothing I can still see
                                            >> the clip sitting in the position I placed it in to start.
                                            >>
                                            >> So my thought is my error is in the syntax of the script.
                                            >>
                                            >

                                            --
                                            http://www.baynewmedia.com
                                            Faster, easier, better...ActionScript development taken to new heights.
                                            Download the BNMAPI today. You'll wonder how you ever did without it!
                                            Available for ActionScript 2.0/3.0.
                                            • 19. Re: XML and AS2.0
                                              shurleynova Level 1
                                              quote:

                                              Originally posted by: Newsgroup User
                                              If you put this on the frame within the clip itself (rather than on the
                                              clip), you could use:

                                              this.onEnterFrame=function() {
                                              _root[ovalue]._x=xValue;
                                              _root[ovalue]._y=yValue;
                                              }

                                              But maybe that's something you can implement when you get the initial
                                              problem fixed.

                                              Patrick

                                              Patrick B wrote:
                                              > Your notation is a bit archaic but we can work with it :)
                                              >
                                              > onClipEvent (enterFrame) {
                                              > setProperty(_root[oValue],_x,xValue);
                                              > setProperty(_root[oValue],_y,yValue);
                                              >
                                              > }
                                              >
                                              > Better still:
                                              >
                                              > onClipEvent (enterFrame) {
                                              > _root[oValue]._x=xValue;
                                              > _root[oValue]._y=yValue;
                                              >
                                              > }
                                              >
                                              > Just make sure xValue and yValue exist and are numbers and you should be
                                              > okay. How does that work out?
                                              >
                                              > Patrick
                                              >
                                              >



                                              Ok I know my syntax is a bit rusty but I am slowly learning to appreciate the dot notation as a much easier way to read the code.

                                              so I went ahead and place this code on a movie clip

                                              onClipEvent (enterFrame) {
                                              _root[oValue]._x=xValue;
                                              _root[oValue]._y=yValue;

                                              }

                                              I checked the output window and the action script to make sure the xValue and yValue were being read as numbers and that it refelcted that in the output I have attached the action script below. Also this is what is in the output window:

                                              Data loaded: true
                                              object_type=stimuli
                                              x_coordinates=25
                                              y_coordinates=25
                                              z_display_interval=200
                                              object_type=stimuli
                                              x_coordinates=85
                                              y_coordinates=175
                                              z_display_interval=200
                                              object_type=stimuli
                                              x_coordinates=325
                                              y_coordinates=55
                                              z_display_interval=200
                                              object_type=stimuli
                                              x_coordinates=115
                                              y_coordinates=355
                                              z_display_interval=200
                                              object_type=fixation
                                              x_coordinates=289
                                              y_coordinates=229
                                              z_display_interval=200

                                              Maybe I am looking at this wrong and maybe there is one other step I need to include is what I keep thinking but I dont knwo what it is.


                                              • 20. Re: XML and AS2.0
                                                Level 7
                                                Okay, you still need to check what _root[oValue] is:

                                                trace (_root[oValue]);

                                                Is it a movie clip, undefined, string?

                                                shurleynova wrote:
                                                >
                                                quote:

                                                Originally posted by: Newsgroup User
                                                > If you put this on the frame within the clip itself (rather than on the
                                                > clip), you could use:
                                                >
                                                > this.onEnterFrame=function() {
                                                > _root[ovalue]._x=xValue;
                                                > _root[ovalue]._y=yValue;
                                                > }
                                                >
                                                > But maybe that's something you can implement when you get the initial
                                                > problem fixed.
                                                >
                                                > Patrick
                                                >
                                                > Patrick B wrote:
                                                > > Your notation is a bit archaic but we can work with it :)
                                                > >
                                                > > onClipEvent (enterFrame) {
                                                > > setProperty(_root[oValue],_x,xValue);
                                                > > setProperty(_root[oValue],_y,yValue);
                                                > >
                                                > > }
                                                > >
                                                > > Better still:
                                                > >
                                                > > onClipEvent (enterFrame) {
                                                > > _root[oValue]._x=xValue;
                                                > > _root[oValue]._y=yValue;
                                                > >
                                                > > }
                                                > >
                                                > > Just make sure xValue and yValue exist and are numbers and you should be
                                                > > okay. How does that work out?
                                                > >
                                                > > Patrick
                                                > >
                                                > >
                                                >

                                                >
                                                > Ok I know my syntax is a bit rusty but I am slowly learning to appreciate the
                                                > dot notation as a much easier way to read the code.
                                                >
                                                > so I went ahead and place this code on a movie clip
                                                >
                                                > onClipEvent (enterFrame) {
                                                > _root[oValue]._x=xValue;
                                                > _root[oValue]._y=yValue;
                                                >
                                                > }
                                                >
                                                > I checked the output window and the action script to make sure the xValue and
                                                > yValue were being read as numbers and that it refelcted that in the output I
                                                > have attached the action script below. Also this is what is in the output
                                                > window:
                                                >
                                                > Data loaded: true
                                                > object_type=stimuli
                                                > x_coordinates=25
                                                > y_coordinates=25
                                                > z_display_interval=200
                                                > object_type=stimuli
                                                > x_coordinates=85
                                                > y_coordinates=175
                                                > z_display_interval=200
                                                > object_type=stimuli
                                                > x_coordinates=325
                                                > y_coordinates=55
                                                > z_display_interval=200
                                                > object_type=stimuli
                                                > x_coordinates=115
                                                > y_coordinates=355
                                                > z_display_interval=200
                                                > object_type=fixation
                                                > x_coordinates=289
                                                > y_coordinates=229
                                                > z_display_interval=200
                                                >
                                                > Maybe I am looking at this wrong and maybe there is one other step I need to
                                                > include is what I keep thinking but I dont knwo what it is.
                                                >
                                                >
                                                >
                                                >
                                                > var timelineXML=new XML();
                                                >
                                                > timelineXML._context=this;
                                                > timelineXML.ignoreWhite=true;
                                                >
                                                > timelineXML.onLoad=function(success:Boolean) {
                                                > trace ('Data loaded: '+success);
                                                > this._context.parseXMLData(this.firstChild);
                                                > }
                                                > //onLoad
                                                >
                                                > function parseXMLData(data:XMLNode) {
                                                > for (var count:Number=0;count<data.childNodes.length;count++) {
                                                > var currentNode:XMLNode=data.childNodes[count];
                                                > var oValue:String=String(currentNode.attributes.omc);
                                                > var xValue:Number=Number(currentNode.attributes.xp);
                                                > var yValue:Number=Number(currentNode.attributes.yp);
                                                > var zValue:Number=Number(currentNode.attributes.zms);
                                                > trace ('object_type='+oValue);
                                                > trace ('x_coordinates='+xValue);
                                                > trace ('y_coordinates='+yValue);
                                                > trace ('z_display_interval='+zValue);
                                                >
                                                > }
                                                > }
                                                > //parseXMLData
                                                >
                                                > timelineXML.load('input.xml');
                                                >

                                                --
                                                http://www.baynewmedia.com
                                                Faster, easier, better...ActionScript development taken to new heights.
                                                Download the BNMAPI today. You'll wonder how you ever did without it!
                                                Available for ActionScript 2.0/3.0.
                                                • 21. Re: XML and AS2.0
                                                  shurleynova Level 1
                                                  when I trace using trace (_root[oValue]);

                                                  my output is:

                                                  Data loaded: true
                                                  object_type=stimuli
                                                  x_coordinates=25
                                                  y_coordinates=25
                                                  z_display_interval=200
                                                  _level0.stimuli
                                                  object_type=stimuli
                                                  x_coordinates=85
                                                  y_coordinates=175
                                                  z_display_interval=200
                                                  _level0.stimuli
                                                  object_type=stimuli
                                                  x_coordinates=325
                                                  y_coordinates=55
                                                  z_display_interval=200
                                                  _level0.stimuli
                                                  object_type=stimuli
                                                  x_coordinates=115
                                                  y_coordinates=355
                                                  z_display_interval=200
                                                  _level0.stimuli
                                                  object_type=fixation
                                                  x_coordinates=289
                                                  y_coordinates=229
                                                  z_display_interval=200
                                                  _level0.fixation

                                                  --
                                                  is _level0 and _root the same thing?

                                                  because if I add the action to the clip

                                                  onClipEvent (enterFrame) {
                                                  _level0.stimuli._x=55;
                                                  _level0.stimuli._y=55;

                                                  }

                                                  or

                                                  onClipEvent (enterFrame) {
                                                  _root.stimuli._x=55;
                                                  _root.stimuli._y=55;

                                                  }

                                                  the results are the same the movieclip with the instance name 'stimuli' appears at (x,y) 55,55. So my guess is even though the variables are loaded and the trace shows me they are the onClipEvent doesn't see it that way. Logically the action script

                                                  onClipEvent (enterFrame) {
                                                  _root.[oValue]._x=55;
                                                  _root.[oValue]._y=55;

                                                  }

                                                  should have the same effect but it doesn't that is kinda why I am confused. If the variables are loaded and the code works with hardcoded data why does replacing the hard coded information with the variable not work.
                                                  • 22. Re: XML and AS2.0
                                                    shurleynova Level 1
                                                    So I guess the short answer to that question is it is a movieclip

                                                    the movieclip is named "mc_stimuli" and has an instance name "stimuli" and its path is simply "_root.stimuli" or "_level0.stimuli" which appear to be one in the same.
                                                    • 23. Re: XML and AS2.0
                                                      Level 7
                                                      Woaw....when your trace _root[ovalue] you get all that? This doesn't
                                                      look right at all. If this was a complex object, you should see "[object
                                                      Object]", if it's a movie clip you should see "[object MovieClip]" or
                                                      the path to the movie clip.

                                                      What I'm seeing here looks like many trace statements. Did you remove
                                                      the ones from the "for" loop? If you leave all the other ones in there,
                                                      what you end up with is meaningless because any one of thos lines may or
                                                      may not be what we want to see. We're trying to isolate one value
                                                      here...you're showing me everything you're receiving plus some other
                                                      data without any context. Get rid of all your trace statements and,
                                                      leaving only the one, ....what does trace(_root[ovalue]); show you?
                                                      Don't put it in a loop. We want only one line of text. If you get more
                                                      than that, check your code again and remove any remaining traces.


                                                      shurleynova wrote:
                                                      > when I trace using trace (_root[oValue]);
                                                      >
                                                      > my output is:
                                                      >
                                                      > Data loaded: true
                                                      > object_type=stimuli
                                                      > x_coordinates=25
                                                      > y_coordinates=25
                                                      > z_display_interval=200
                                                      > _level0.stimuli
                                                      > object_type=stimuli
                                                      > x_coordinates=85
                                                      > y_coordinates=175
                                                      > z_display_interval=200
                                                      > _level0.stimuli
                                                      > object_type=stimuli
                                                      > x_coordinates=325
                                                      > y_coordinates=55
                                                      > z_display_interval=200
                                                      > _level0.stimuli
                                                      > object_type=stimuli
                                                      > x_coordinates=115
                                                      > y_coordinates=355
                                                      > z_display_interval=200
                                                      > _level0.stimuli
                                                      > object_type=fixation
                                                      > x_coordinates=289
                                                      > y_coordinates=229
                                                      > z_display_interval=200
                                                      > _level0.fixation
                                                      >
                                                      > --
                                                      > is _level0 and _root the same thing?
                                                      >
                                                      > because if I add the action to the clip
                                                      >
                                                      > onClipEvent (enterFrame) {
                                                      > _level0.stimuli._x=55;
                                                      > _level0.stimuli._y=55;
                                                      >
                                                      > }
                                                      >
                                                      > or
                                                      >
                                                      > onClipEvent (enterFrame) {
                                                      > _root.stimuli._x=55;
                                                      > _root.stimuli._y=55;
                                                      >
                                                      > }
                                                      >
                                                      > the results are the same the movieclip with the instance name 'stimuli'
                                                      > appears at (x,y) 55,55. So my guess is even though the variables are loaded
                                                      > and the trace shows me they are the onClipEvent doesn't see it that way.
                                                      > Logically the action script
                                                      >
                                                      > onClipEvent (enterFrame) {
                                                      > _root.[oValue]._x=55;
                                                      > _root.[oValue]._y=55;
                                                      >
                                                      > }
                                                      >
                                                      > should have the same effect but it doesn't that is kinda why I am confused.
                                                      > If the variables are loaded and the code works with hardcoded data why does
                                                      > replacing the hard coded information with the variable not work.
                                                      >
                                                      >

                                                      --
                                                      http://www.baynewmedia.com
                                                      Faster, easier, better...ActionScript development taken to new heights.
                                                      Download the BNMAPI today. You'll wonder how you ever did without it!
                                                      Available for ActionScript 2.0/3.0.
                                                      • 24. Re: XML and AS2.0
                                                        Level 7
                                                        Okay...I'm not sure how you came up with that but assuming you're
                                                        right...first...are the values you're trying to set numbers? They may
                                                        *look* like numbers but if they're strings, the X and Y position won't
                                                        be affected.

                                                        _root[ovalue]._x=Number(xValue);
                                                        _root[ovalue]._y=Number(yValue);


                                                        Second, do you still have this?

                                                        onClipEvent (enterFrame) {
                                                        setProperty(_root.stimuli,_x,55);
                                                        setProperty(_root.stimuli,_y,115);

                                                        }

                                                        This continually loops and sets the clip X and Y to 55,115 so get rid of
                                                        it. It sounds like you're making a bit of a dog's breakfast of your code
                                                        because you're trying to fix things piecemeal.

                                                        At this point you may have 2 or 3 things that are working against each
                                                        other. I only see the tiny bits of code you are posting here and not
                                                        seeing it in context. If you were to ask me what could be causing the
                                                        clips not to go to their target position, the answer is literally
                                                        "anything". It certainly sounds like you're not sure how to set X and Y
                                                        position or how to correctly work with values but how many other
                                                        problems do you have in your code that could be causing this? I've seen
                                                        one onEnterFrame loop and I've suggested an XML parsing routine that's
                                                        out of context (it's very generic and not suited to what you're doing
                                                        specifically...whatever that is). I would advise that you either read up
                                                        on core Flash concepts like movie clip references, scope, setting
                                                        properties, and looping...or you post your code in its entirety so I can
                                                        give you a rundown how the pieces fit together. It's very difficult to
                                                        work with bits and pieces when other bits and pieces may the crucial
                                                        problems.

                                                        Feel free to drop me an email if you want and we can continue this off
                                                        the forums.

                                                        Patrick


                                                        shurleynova wrote:
                                                        > So I guess the short answer to that question is it is a movieclip
                                                        >
                                                        > the movieclip is named "mc_stimuli" and has an instance name "stimuli" and its
                                                        > path is simply "_root.stimuli" or "_level0.stimuli" which appear to be one in
                                                        > the same.
                                                        >

                                                        --
                                                        http://www.baynewmedia.com
                                                        Faster, easier, better...ActionScript development taken to new heights.
                                                        Download the BNMAPI today. You'll wonder how you ever did without it!
                                                        Available for ActionScript 2.0/3.0.
                                                        • 25. Re: XML and AS2.0
                                                          shurleynova Level 1
                                                          Ok I see your point, I commented out the other trace statements and only left the following two trace statements

                                                          trace ('Data loaded: '+success);
                                                          and
                                                          trace (_root[oValue]);

                                                          and the output file now looks like this:

                                                          Data loaded: true
                                                          _level0.stimuli
                                                          _level0.stimuli
                                                          _level0.stimuli
                                                          _level0.stimuli
                                                          _level0.fixation

                                                          so it looks like it is grabbing the right variable from the XML
                                                          • 26. Re: XML and AS2.0
                                                            Level 7
                                                            Okay, that looks good. So, in this case _root and _level0 are the same
                                                            thing (this isn't always the case but here it is).

                                                            So, the only two things I can see, as per my previous post, are:

                                                            1. Your enterFrame loop is hard-setting the position. Whatever you set
                                                            it to outside of this, this loop simply resets it next time the frame
                                                            loop hits. So...comment it out or get rid of it.

                                                            2. Your X and Y values may not be numbers. You should try something like:

                                                            _root[ovalue]=Number(xValue);
                                                            _root[ovalue]=Number(yValue);

                                                            If they are numbers, no problem. If they're not, this should convert it.
                                                            Like I said, this is a 2-inch view of the whole canvas so this is the
                                                            best I can do without seeing everything you've written.

                                                            Good luck!

                                                            Patrick

                                                            shurleynova wrote:
                                                            > Ok I see your point, I commented out the other trace statements and only left
                                                            > the following two trace statements
                                                            >
                                                            > trace ('Data loaded: '+success);
                                                            > and
                                                            > trace (_root[oValue]);
                                                            >
                                                            > and the output file now looks like this:
                                                            >
                                                            > Data loaded: true
                                                            > _level0.stimuli
                                                            > _level0.stimuli
                                                            > _level0.stimuli
                                                            > _level0.stimuli
                                                            > _level0.fixation
                                                            >
                                                            > so it looks like it is grabbing the right variable from the XML
                                                            >

                                                            --
                                                            http://www.baynewmedia.com
                                                            Faster, easier, better...ActionScript development taken to new heights.
                                                            Download the BNMAPI today. You'll wonder how you ever did without it!
                                                            Available for ActionScript 2.0/3.0.