1 Reply Latest reply on Mar 3, 2008 10:12 AM by Gregory Lafrance

    On Click?

    jefflemon
      In image is added dynamically with as3, and a click handler is added BUT the click handler does not work... any better ways to do this?

      var profile:Image = new Image;
      profile.source = ("images/myprofile.gif");
      profile.y = 13;
      profile.x = 625;
      profile.addEventListener(MouseEvent.CLICK, clickHandlerProfile);
      addChild(profile);

      and the click handler:

      private function clickHandlerProfile(event:MouseEvent):void {
      myservice.getOperation('goToMyProfile').send();
      }
        • 1. Re: On Click?
          Gregory Lafrance Level 6
          This works. Maybe something wrong with the service?
          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()">
          <mx:Script>
          <![CDATA[
          import mx.controls.Alert;
          import mx.controls.Image;

          private var profile:Image = new Image;

          private function init():void{
          profile.source = ("images/available.GIF");
          profile.y = 13;
          profile.x = 625;
          profile.addEventListener(MouseEvent.CLICK, clickHandlerProfile);
          addChild(profile);
          }

          private function clickHandlerProfile(event:MouseEvent):void {
          mx.controls.Alert.show("It works!!!");;
          }
          ]]>
          </mx:Script>
          </mx:Application>