3 Replies Latest reply on Aug 5, 2008 10:39 AM by Cr99

    LinkButton in actionscript dynamic URL

    Cr99 Level 1
      One thing I have run into several times now in Flex is that with mx tags, you can pass your own args to eventlisteners, but not in Actionscript. For example:

      <mx:LinkButton click="myFunction("customArgs")/>

      works great but

      var link:LinkButton = new LinkButton();
      link.addEventListener(MouseEvent.CLICK, myFunction("customArgs"));

      doesn't work in ActionScript. I have an ArrayCollection with two fields: name (for the link name), and id(which helps me generate the url). How can I get the eventlistener to access the id of the object when everything is created in Actionscript?


      repURL in my showReport function is just a placeholder at present. I would like to pass it arr .id in the loop in my initializeBrowser function but as far as I know, this can't be done.
        • 1. Re: LinkButton in actionscript dynamic URL
          Level 7

          "Cr99" <webforumsuser@macromedia.com> wrote in message
          news:g7a1bd$238$1@forums.macromedia.com...
          > One thing I have run into several times now in Flex is that with mx tags,
          > you
          > can pass your own args to eventlisteners, but not in Actionscript. For
          > example:
          >
          > <mx:LinkButton click="myFunction("customArgs")/>
          >
          > works great but
          >
          > var link:LinkButton = new LinkButton();
          > link.addEventListener(MouseEvent.CLICK, myFunction("customArgs"));
          >
          > doesn't work in ActionScript. I have an ArrayCollection with two fields:
          > name (for the link name), and id(which helps me generate the url). How
          > can I
          > get the eventlistener to access the id of the object when everything is
          > created
          > in Actionscript?

          Is there any association between your button and the data? For instance, if
          this is in an itemRenderer, you can probably use event.currentTarget.data.
          Normally, there will be some kind of direct relationship that you can use so
          that the event is able to pass you the data you need.

          If not, you can probably create your own event and dispatch it.

          HTH;

          Amy


          • 2. Re: LinkButton in actionscript dynamic URL
            VarioPegged Level 2
            Have you tried ...

            TS
            • 3. Re: LinkButton in actionscript dynamic URL
              Cr99 Level 1
              Yes that works! Brilliant! I forgot that components already have an 'id' field and that I could smuggle in my id that way.

              Thanks!