1 Reply Latest reply on Feb 25, 2008 11:18 AM by ntsiii

    actionscript components

    s.lanton Level 1
      I tried to post this in the actionscript forum but it ended up here. This expands on an earlier post I made in this forum.
      I want to be able to click on the canvas and be able to alert the canvas label ie "Canvas1" but am a bit lost on how to achieve that....anyone?
      My application looks like

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
      layout="absolute"
      creationComplete="doCreationComplete( event )"
      xmlns:mx=" http://www.adobe.com/2006/mxml" width="672" height="546" >



      <mx:Script>
      <![CDATA[

      import mx.containers.Canvas;
      import mx.controls.Label;
      import mx.controls.Alert;
      public var canv:Canvas= new Canvas();
      public var lbl:Label= new Label();

      public function doCreationComplete( event:Event ):void
      {


      lbl.text = "canvas1";
      canv.setStyle("borderStyle","solid");
      canv.width=50;
      canv.height=50;
      canv.x = 22;
      canv.y = 21;
      addChild( canv );
      canv.addChild(lbl);


      canv.addEventListener(MouseEvent.CLICK,click);

      }




      private function click(evt:MouseEvent):void {
      Alert.show(lbl.toString());
      }
      ]]>
      </mx:Script>


      </mx:Application>