I hope I'm not flooding the list on my first day, but I gots to axe
questions.

Why do I get the result "I am 2" when I click on of the buttons in the
example below?

I created myText to see if I could affect objects via the array.  I can.

I created Button0 and Button1 to put into an array, and try to generate
their events in a for loop.  Button0 should change myText to "I am 0", and
Button1 should change myText to "I am 1".  Both of them change myText to "I
am 2".  Why?

---
<html>

  <head>

    <script language='JavaScript'
src='/JavaScripts/dynapi/src/dynapi.js'></script>

    <script lanugage='JavaScript'>
      DynAPI.setLibraryPath('/JavaScripts/dynapi/src/lib/');
      DynAPI.include('dynapi.api.*');
      DynAPI.include('dynapi.event.*');
      DynAPI.include('dynapi.ext.inline.js');
      DynAPI.include('dynapi.util.debug');
    </script>

    <script language='JavaScript'>

      DynAPI.onLoad = function(){

        var myText = this.document.getAll()["myText"]
        myText.setVisible(true);
        var myEvent = new EventListener(this.document);
        myEvent.onmouseup = function() {
          Buttons[0].setHTML("Touch 0");
          Buttons[1].setHTML("Touch 1");
        };
        myText.addEventListener(myEvent);


        var Buttons = new Array;
        var Events = new Array;

        for(var i = 0; i < 2; i++) {

          Buttons[i] = this.document.getAll()["Button" + i]
          Buttons[i].setVisible(true);
          Events[i] = new EventListener(this.document);
          Events[i].onmouseup = function() {
            myText.setHTML("I am " + i);
          };
          Buttons[i].addEventListener(Events[i]);

        }

      };

    </script>

  </head>

  <body>

    <div id='myText' style='position:relative;
visibility:hidden;'>Yeap</div>

    <div id='Button0' style='position:relative; visibility:hidden;'>Button
0</div>

    <div id='Button1' style='position:relative; visibility:hidden;'>Button
1</div>

  </body>

</html>
----

Travis Garris, Ciber
Winston-Salem, NC

_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to