ASTRA Badge Kit
The Badge Kit is an an XML-based framework for rapid development of small interactive Flash applications. You can learn how to use the Badge Kit very quickly, and most of the usage scenarios require no knowledge of Flash.
Badge Kit XML Framework
The Badge Kit consists of the base SWF file, Badge.swf, and two files that define the badge content: config.xml and content.xml.config.xml
A typical config.xml file may look as follows: The <contentpath> node defines the location of content.xml. In the example above, content.xml is located in the same folder as the main badge. The <paths> section allows you to specify shorthands for long paths. In the example above, "SWF" is defined as a shorthand for the folder "resources/swf". In content.xml, you can now use "%SWF%" every time you need to refer to that path (e.g., "%SWF%/components.swf" instead of "resources/swf/components.swf"). The <classpaths> section allows you to specify classpaths for different services and elements, so that you can refer to them just by the class name, rather than by full classpath (for example, "Image" instead of "com.yahoo.astra.badgekit.controls.Image"). Finally, the <animations> section defines different animations that can be used when showing or hiding the components. The animation has an "id" attribute, the "property" attribute with the name of the property that's being modified, a start and end values, as well as the duration of animation in seconds. In the example above, the x-coordinate of the element to which the animation is applied will animate from x=200 to x=108 in 1 second.content.xml
Content.xml, the primary description file for the badge, consists of three sections: <resources>, <services> and <elements>.<Resources> section
The <resources> section lists the resource files with components and graphical resources that a particular badge requires. The badge kit accepts SWF files that can encapsulate a variety of content: UI components, services, images, videos, sounds, text, and so on. A typical <resources> section of content.xml may look as follows: The resources are loaded before the badge is rendered on-screen. [Progress bar for loading resources?]<Services> section
The <services> section defines all of the data services used by the badge. The services defined in this section must exist as classes among the resources provided by the resource SWFs; if a particular service is not found, a runtime “Service not found.” error is thrown. Each of the service nodes in this section can be assigned attributes that correspond to specific service properties. For example, consider the following service definition: In this node, we instantiate the FlickrService that exists as a class in the com.yahoo.webapis.flickr classpath in one of the SWF resources we imported (the classpath can also be included in config.xml, in which case you can simply use “FlickrService” for instantiation). Next, we specify the “id” of the service – this is the name by which other elements of the badge can refer to it to extract parameters. We also set some of the properties owned by FlickrService: applicationId, maximumResults, and userId. Finally, we set the “send” property to true – this special setting triggers the send() method of the service (the order of assignments doesn’t actually matter: send() only triggers after all the parameters are assigned.) This particular combination of parameters will retrieve URLs for 10 latest photos for a given userId and applicationId. However, given the current configuration, once the data is loaded, nothing will happen. To add a response to the “result” event dispatched by FlickrService, we can set the “result” attribute of the node:Note on architecture
In the badge kit framework, the only programmatic construct allowed in response to events is a variable assignment. Though this may seem like a major limitation, we believe that for the purposes of badge development, this construct is sufficient to accomplish the necessary tasks. Badges, by design, are not complex applications, and at a high level, they do not require conditional checks (if statements), loops (for and while statements), or other complex functionality. The job of a badge is to move data and modify properties in response to actions and events. If more complex functionality is desired, it should be implemented at the component level by the Flash developer.