The Yahoo! maps AS3 API provides a SearchMarker class that is used to display on the map an icon representing a LocalSearchItem class object. The LocalSearchItem class is used to store data contained in a result returned from searching the Yahoo! Local listings (see the related entry below). This data includes phone, address, website, title, etc. However, you can create your own LocalSearchItem objects and use these objects to create SearchMarker objects and display those on the map. The LocalSearchItem class documentation is a bit confusing on how to create an object of the class, so I thought a blog entry and example (right click on the app to view source code) might be helpful.
At the end of my previous post on the new Yahoo! maps AS3 API, I mentioned that I wanted to learn how to create my own custom Marker class so that I could display my own graphic and text on the map. After some playing around, I figured out how to create a custom Marker class. You can view an example Flex application here (right click to get the source code).
I was excited to learn that Yahoo! released an ActionScript 3.0 API for their maps service. I've just started to play with the API, but it looks relatively easy to use. I do wish there was a bit more developer's documentation. Since even after studying the examples provided by Yahoo!, I was confused on how to create a map and display places on the map (especially the results of doing a search on Yahoo! Local), I thought a beginner's guide might be useful for others.
I've created a simple Flex application demonstrating how to create a map, place a SimpleMarker object on the map, and display the results of doing a search of the Yahoo! Local listings. You can view the application and get its source code (right click on the application) here. I tried to include some good comments in the source code to help you follow what I did. Here are the key steps:
One of the web applications I'm developing for the Kansas City Adobe User Group uses a Flex front end. The backend CFCs are managed by ColdSpring (see part 1 Naked ColdSpring). Since ColdSpring is managing the CFCs and their dependencies, I cannot just call my UserService CFC from Flex. My Flex application needs to connect to the UserService object being managed by ColdSpring, which has all of its dependencies resolved.
ColdSpring provides a means to create a version of my UserService CFC that Flex can connect to. References 1 and 2 provide some advanced explanations of how to get ColdSpring to create a remote version of a CFC. This blog entry will provide the grade school version.
I was recently working my way through a Flex tutorial on exchanging data with a backend ( see: http://learn.adobe.com/wiki/display/Flex/Part+II.+Exchanging+Data) provided by Adobe's Flex Developer's Center. The example in Adobe's tutorial uses the Flex HTTPService to consume XML produced by ColdFusion (there is also backend code for Java, ASP.net, and PHP provided). Unfortunately, there are some mistakes in the ColdFusion backend code that prevented me from getting the example using ColdFusion on the backend to work. I posted a comment about the problem to the page and pointed readers to this blog entry.
Now that I've your attention...
I own and have studied almost all the Flex 2 and ActionScript 3 books published. However, when I encounter a problem in my Flex application development I first search through the online documentation provided by Adobe. Almost always I find the answer to my problem in the documentation.
I've found the Flex and ActionScript documentation provided by Adobe to be well-written, with example code I can follow and learn from. It's nice to have an online version and a PDF I can download for those (rare) times I'm not connected to the net.
Here's a big "Thank You!" to all the people who wrote the Flex and ActionScript documentation and created the examples. I also appreciate the ability to link directly to a specific part of the documentation and to post (and read other's) comments about specific topics.
So sometimes, after I've found the answer to my problem in the Adobe documentation, I ask myself..."Did I really need to pay $35 for that new Flex book?"
A well-designed Flex 2.0 application involves integrating various components. Many of these components are provided for us in Flex (for example, DataGrid). But as you develop more sophisticated Flex applications you’ll want to create your own custom components.
Creating custom components that can be easily integrated into your overall Flex application but able to communicate with outside users involves two concepts – custom events and public functions. Custom events enable your Flex application to easily announce when something significant has occurred and for outside users to register and respond to the custom event. Public functions in your custom component provide an interface that allows users of your custom component to manipulate it.
I'm working on a project where we allow the user to select multiple items from a list. If the user has previously selected multiple items in the list, then we show the user his previous selections as selected items in the list. I've developed a methodology to do this but would appreciate any feedback. Additionally, I'm using the selectedIndices property of the list control, but from the description of the selectedItems property, the selectedItems property would seem to be a better choice for pre-selecting multiple list items. However, I cannot figure out what values need to be in the array that I could assign to the selectedItems property. Please comment if you've learned how to assign a value to the list control's selectedItems property.
I recently had to create an "upcoming events" Flex widget for work. The widget had to include an image and a title that linked to the area of our website that had more information. I started with the excellent image gallery tutorial provided by Sas Jacobs (see references 1 and 2). However, I needed to add to her example the ability for the images to auto advance and for the image to be constrained to the size of the widget. You can view an example and its source code here.
I sometimes use class URLLoader (see reference 1) to load into my Flex applications an XML file that sets up the initial configuration of the application or provides some initial data needed by the application. For an example of using class URLLoader see reference 2.
I recently had an issue where the XML file that URLLoader was trying to load was not present (it had been deleted by mistake), so when that application ran URLLoader could not load the file. The user just saw the confusing Adobe Flash Player 9 error box since I wasn't handling the error that is generated when the URLLoader cannot load the file. Now that I've learned how to handle this error, I want to share the code in my blog. Reference 3 is an example that will show the user an error message if the URLLoader object cannot load the file. You can right click on the application to view the source code.