Select to view content in your preferred language

Advice for Flex developer wanna-be.

498
1
04-15-2011 06:34 AM
DougKampe
Regular Contributor
I'm trying to learn as much as I can about developing tools for Flex using Adobe Flash Builder 4.

For a few months now, I have been tweaking the code of the shared widgets from the code gallery, but now I want to go beyond this. I figured using ESRI's sample code and adapting it would be a good start, but I'm not finding this to be an easy task.

Here's what I'm trying to do for my first project. I want to use ESRI's reverse geocoding sample code, but have it display the address on the sample Hello World Widget that comes with the viewer. I've watched the Create a Custom Widget video, and while it is somewhat informative, it's not very helpful with my project. Ultimately, I'd like to try to make tools that are more complicated and more useful. 

This is what I thought I could get it to do:


  1. The user clicks on the widget icon in the tray,

  2. The user is advised to "Click on the map to get an address." (I can do this part.),

  3. The address populates on the widget (obviously where I'm stumped),

  4. The user is blown away!, 😉

  5. And finally, the user closes the widget.


Any help from the pros would be greatly appreciated by me and I'm sure all the beginners trying to learn this stuff on their own. I'm not a total novice to programming. I have some experience with VB.NET and am pretty proficient in T-SQL, so it's not as if I've never looked at code. 

Thanks in advance.
Doug
Tags (2)
0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus
Doug,

   So in the widget code to use the Flex Viewers built in drawTool you would use the setMapAction function.

So something like this:

import com.esri.ags.tools.DrawTool;
import com.esri.ags.events.DrawEvent;

            private function activateDrawTool(event:MouseEvent):void
            {
                addSharedData("Deactivate_DrawTool", null); // to be able to deactivate drawTool on other widgets
                setMapAction (DrawTool.MAPPOINT,"Click map to get address", someSymbolorNull, drawEnd);
             }
private function drawEnd(event:DrawEvent):void
{
    var geom:Geometry = event.graphic.geometry;
    // do your magic here
}

<s:HGroup id="drawImageGroup"
                      width="100%"
                      gap="2"
                      horizontalAlign="center">
                <mx:Image name="{DrawTool.MAPPOINT}"
                          width="40" height="40"
                          buttonMode="true"
                          click="activateDrawTool(event)"
                          source="assets/images/i_draw_point.png"
                          toolTip="Reverse Geocode location on the Map"
                          useHandCursor="true"/>
</s:HGroup>
0 Kudos