4 Replies Latest reply on Apr 19, 2010 3:11 AM by David_F57

    Creating a clickable dot at a position relative to parent Window

    hINTModuleState

      Hi there,

       

      I am a beginner.

       

      My problem is the following :

       

      I have a Window ( Canvas ).

       

      And I have a dot that need be inserted at , let's say, x = 50%, y =75%

       

      I also want the dot to be clikable or at least be able to show a tooltip when the mouse is over it.

      Note :

      The dot can be a small shape in form of a cercle.

       

       

      Thank you in advance.

        • 1. Re: Creating a clickable dot at a position relative to parent Window
          David_F57 Level 5

          hi,

           

          The quickest way is to have an image, saves getting into the drawing of graphics etc.

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">

          <mx:Script>

          <![CDATA[

          import mx.controls.Alert;

          protected function clickHandler(event:MouseEvent):void

          {

          Alert.show("hello","message");

          }

           

          ]]>

          </mx:Script>

          <mx:Image id="hitDot" x="370" y="263" width="12" height="12" toolTip="hi there" click="clickHandler(event)" source="red.jpg"/>

          </mx:Application>

           

          you can also add or remove the image as you see fit(or just move it off the stage if you don't want to see it), to change its position just set the x and y properties

           

          hotDot.x = width*0.75-6;

          hotDot.y= height*0.50-6;

           

          the minus 6 indicates half the hieght/width of the image to'center' it on the exact co-ordinate.

           

          David.

           

           

           

          1 person found this helpful
          • 2. Re: Creating a clickable dot at a position relative to parent Window
            hINTModuleState Level 1

            Thank you so much.

             

            Infact, because I could not find a ready control, this is my last resort in an attempt to create a sort of interactive map that is able to show icons at specified lon/lat positions.

             

            I found a Word Map and I managed to draw it as image.

             

            So after using your code, only remains to intercept the WordMap image move events and update all dots accordingly right ?

             

             

            Thank you again.

            • 3. Re: Creating a clickable dot at a position relative to parent Window
              David_F57 Level 5

              hi,

               

              If the dots relate to cordinates on the map i.e if the map is extended past the display co ordinates you can just place the "dots" in the correct place, for example if you have a map of the world and paris equates to x=50 and y = 300 in the image you set the "dots" as children of the map container when the map is "panned" the dots are always correctly located. I say this on the assumption you are using some sort of panning (viewport) for the map.

               

               

              David.

              • 4. Re: Creating a clickable dot at a position relative to parent Window
                David_F57 Level 5

                hi,

                 

                Just to clarify say you have a container that its pixels relate to lat and long the dots can be placed by using the conversion of lat/long to pixels.

                 

                when the container moves or is scaled the dots remain in the correct place (the container has a world map as background and dots in the foreground)

                 

                David