Welcome to Mediasparkles

News : Flash

After some reader comments I have decided to expand my Central Sample app slightly. Julian asked about setting up a link from a Notice back to the app. So the Notices now have engage links that will send info back to the app. The Notices also disappear after 30 seconds so that they don't clutter your screen.

Here is the new code on the app and pod side that creates a notice (changes in bold):

notice = new Object();
notice.name = "The console said hi!";
notice.description = "This is an example of a Central notice.";
notice.timeout = 30;
notice.engageString = "React";
notice.navigate = true;
notice.alert = true;
vShell.addNotice(notice);


The engageString property specifies which text to display as the engage link inside the Notice. In order to handle the user engagement, you have to write an onNoticeEvent function in either the app, the Agent, or the Pod or all of them, depending on which part of your app you want to handle the Notice event. I only included it in the app itself, and it looks like this:


onNoticeEvent = function(event, noticeData) {
   if (event.type == "engage") {
      star.gotoAndPlay("dance");
   }
}


Very simple. It just plays a little animation in the main app window, indicating that the engage link was clicked.

Adam asked how to use a Blast in another app once it has been blasted. So I made a new Central app that can receive the blasted zip code from the Sample app, the Zip & Area Code Info app. It also can receive zip code Blasts from Hilary Bridel's PostalCode Search app. Again, it's very simple and certainly no killer app; I was just trying to show how to use a Blast sent from another app. As you can probably guess, it is set up to receive a zip code from the Sample app and then do something with it. It connects to a web service to look up information about any U.S. zip code. It can also look up information about U.S. area codes, but I didn't set up a Blast for that.

To receive the zip code Blast from the Sample app, I have the following inside the Zip & Area Code Info app:

// function that is called when a Blast is received
onSelectedItem = function (data) {
   // loop through the data
   for (var i = 0; i<data.length; i++) {
      // this app only accepts addresses, so check for that
      if (data[i].address != null) {
         // display the received zip code in text field
         var zip = data[i].address.postalCode;
         container.selectedChild.inputText.text = zip;
         container.selectedChild.blasted._visible = true;
      }
   }
}


I also have to make a correction to my last post: For a Blast to work correctly, the <supportedTypes> element is only needed in the product.xml file of the app receiving a Blast. It is not necessary in the one sending a Blast.

Downloads:
Sample App v1.1
Sample App source files, updated (164K)
Zip & Area Code App v1.0
Zip & Area Code App source files (378K)

 posted by Vera Fleischer (1/11/2004 12:56:59 PM);