Adobe Camp: 1 Day, 3 Camps: 5280 Reasons to Use the Flash Platform

Rocky Mountain Adobe CampIf you haven’t heard already, the first Rocky Mountain Adobe Camp is open for registration.

The first ever, one of a kind, Rocky Mountain Adobe Camp is right here in Denver on June 22, 2009. Digital professionals at all experience levels are invited to this one-day event to participate in in-depth sessions, and unique hands-on activities taught by some of the most influential speakers in the “Flash-o-sphere”.

Want more information?
Check out http://camp.rmaug.com for event date and location as well as speaker and session info.

Use twitter?
Follow @adobecamp’s updates for more information and news.

There are some interesting sessions that will be divided between 3 different “tracks”:

  • Flash Camp: Get ready to learn best practices, discover hidden features, and extend your abilities
  • Dynamic Media Camp: Developers and content owners alike will expand their current knowledge of the Flash Media Server family
  • eLearning Camp: Trainers, staff development managers, and Human Resource professionals will all gain valuable insight for eLearning development using tools such as Adobe Connect, Adobe Captivate, and Adobe Acrobat

So pick one and register for the First Rocky Mountian Adobe Camp!

Quick fun with AIR & Dailymugshot.com

So i’ve been playing with DailyMugShot.com for the past couple of months. DailyMugShot is just that – you take 1 picture every day of your mug. Well I wanted all my mugshots and there wasn’t a direct way of downloading them from the site. They have an RSS feed for your shots, but it only shows the current picture.

They do have a little flash based badge that you can post to your site.

So with some hunting around in the firebug output I found where the little flash piece calls a service for the sequence of images. The dataservice is simple XML (Yay!), and I like ActionScript 3 and XML. So, I wrote an AIR app that downloads all my mugshot images. It is really basic and urls and final file locations are all hard-coded, but it was a fun 45 minutes and worked like a charm and I have all my past mug shots.

Here are a few of my favorites:
02-03-200902-18-200902-24-200903-14-200903-17-200904-06-2009

Update: If you’d like to play with dailymugshot.com I’ve compiled an AIR Application that will download all the images for a given user ID (you can get the userID from the slide show page URL)

[dm]9[/dm]

E4X XML Namespaces

For XML that looks like the following response from Yahoo’s weather service:
[xml]
< ?xml version=’1.0′ encoding=’UTF-8′?>
http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*
http://weather.yahoo.com/forecast/94089_f.html Yahoo! Weather for Sunnyvale, CA
en-us
Tue, 06 Nov 2007 6:56 pm PST
60

142
18

http://weather.yahoo.com/ http://l.yimg.com/us.yimg.com/i/us/nws/th/main_142b.gif
37.39
-122.03

http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/94089_f.html Tue, 06 Nov 2007 6:56 pm PST

< ![CDATA[

Current Conditions:
Fair, 55 F

Forecast:
Tue – Mostly Clear. High: 67 Low: 49
Wed – Partly Cloudy. High: 71 Low: 49

Full Forecast at Yahoo! Weather
(provided by The Weather Channel)
]]>

94089_2007_11_06_18_56_PST

[/xml]

When you need to access the nodes with complex node names such as yweather:location think XML namespaces.
In the above example, look for the xmlns declaration in the rss node
xmlns:yweather='http://xml.weather.yahoo.com/ns/rss/1.0'.
Creating a Namespace object using the declaration will allow us to access the nodes with complex names.
Creating a Namespace object is a pretty simple process:

[as]
var yweatherNS:Namespace = new Namespace( http://xml.weather.yahoo.com/ns/rss/1.0 );
[/as]

Now we can access the node with the following code:

[as]
yahooWeaterXML.channel.yweatherNS::location

trace( yahooWeaterXML.channel.yweatherNS::location.@city ); // outputs ‘Sunnyvale’
trace( yahooWeaterXML.channel.yweatherNS::location.@region); // outputs ‘CA’
trace( yahooWeaterXML.channel.yweatherNS::location.@country ); // outputs ‘US’
[/as]

With the preceding example we need to know the namespace url ahead of time. E4X gives us the namespaceDeclarations() method that will return an array that contains the namespace declarations associated with the XML document

Using the namespaceDeclarations() method from the XML object:

[as]
var namespaces:Array = myXML.namespaceDeclarations();
[/as]

Now we have an array of namespace declarations that we can use to dynamically declare Namespace objects and access our complex node names:

[as]
var yweatherNS:Namespace
var geoNS:Namespace
var nsLen:uint = nameSpaces.length;
for(var i:uint = 0; i < nsLen; i++)
{
var newNamespace:Namespace = new Namespace( nameSpaces[i] );
if( String( nameSpaces[i].prefix ).toLowerCase() == “yweather” )
{
yweatherNS = newNamespace;
}
else
{
geoNS = newNamespace;
}
}
[/as]

So we can access the geo and yweather nodes without any problems now.

More Flexible Code – Programming to an Interface

Keep your code flexible – program to interfaces. What does this mean? Well there are a few things that we need to discuss before we can really answer that question. For this discussion you’ll need a decent understanding of Object Oriented programming…but, hey if you don’t have that it still may make some sense anyhow and you might even get something that you don’t understand explained for you as we go along.

First things first, Polymorphism – The ability for one class to stand in for another, kind of. By “kind of” I mean that by programming to an interface, a variable or property’s value can be assigned to an object that conforms to a “formal interface”, more on that in a second. This means that if you crate a property or variable that is typed to an interface – myPet:IAnimal; – (where IAnimal is the interface) that item can be any number of classes that follow the “interface” defined by IAnimal .

Example:
[as]
public var myPet:IAnimal = new Dog();
public var yourPet:IAnimal = new Fish();
public var hirPet:IAnimal = new Camel();
public var herPet:IAnimal = new Giraffe ();

[/as]

Each of the classes, Dog, Fish, Camel, Giraffe must “implement” the IAnimal interface.

Okay, so what is a formal interface you say?
First off, a formal interface is a definition, some might say a contract, but I think that is confusing, of what a class’s publically accessible methods should be and what they should look like. ActionScript 3 provides a construct to create these interfaces that is very similar to classes. Basically you create the public methods, their parameters and their return types, but nothing that has to do with what happens inside the method.

Example:
[as]
package
{
public interface IAnimal
{
function create(p_name:String):void
function feed(p_food:Object):void
function sleep():void
}
}
[/as]
Notice that there is nothing that tells you what you need to do in the methods, or anything about properties or private methods. That is determined by the needs of the class that implements the interface. This is a good point to take hold of and knock into your head:

A class has an implementation (what the class does ) and an interface (how the outside world interacts with it).

This is what allows your code to be flexible. If you program to interfaces, you can crate objects that are much more flexible and powerful by have the ability to “stand in” for any property or variable.

You can also create an “interface” through inheritance by using something called an “abstract” class. An abstract class isn’t intended for instantiation, so it is up to you to manage that. But abstract classes do allow for a default implementation (what the class does) as well as allowing for the type of interface implementation mentioned above because sub-classes inherit the interface of their parent classes.

So, keep your code flexible, program to interfaces!

Continious Integration for Flash and Flex

Lately I’ve been working with CruiseControl, a continuous integration tool, and unit testing (ASUnit and FlexUnit) for our ActionScript 2, ActionScript 3/Flex projects. With the help of a couple of some great posts from eyefodder and Peter Martin, I’ve finally come up with a nice little system that isn’t too much of a headache to set up and is very easy to maintain once it is set up.

When I get some real time, I’ll be sure to blog about the set up and give some walk-throughs on how to get everything up and running.

The basic ‘gist’ of continuous integration is:

To build your code as soon as it changes. This helps to identify problems with the source code as quickly as possible after the problem is introduced. By introducting unit tests into the build process, you add more integrity to the build as well as your code.

So, like I said as soon as I get some real time, I’ll be sure to put together some set up information.

Dispatching a custom event

There are many common events for Flex components, such as the click or change events. These events are very usefull and great for many situations. Your application or custom component may require more from an event than is provided in these built-in events. Not a problem! You can dispatch any of the predefined events inherited by a component’s superclass, as well as new, custom, events that you define within the component.

To dispatch a new event from your custom component, you must do the following:

  1. Create a subclass from the flash.events.Event class (or another event class) to create an event class that describes the event object. This step is optional.[as]
    public class MyCustomEvent extends Event
    {
    static public var customEventName:String = “customEventName”; public var myEventData:*;

    public function MyCustomEvent(type:String, p_eventData:*, bubbles:Boolean=false, cancelable:Boolean=false)
    {
    super(type, bubbles, cancelable);

    myEventData = p_eventData;
    }

    }
    [/as]

  2. Use the [Event] metadata tag to make the event public so that the MXML compiler recognizes it. This step is optional.
    [as]
    [Event(name=”customEventName”, type=”com.events.MyCustomEvent”)]
    public class MyCustomEvent extends Event
    { …[/as]
  3. Dispatch the event using the dispatchEvent() method.
    [as]
    dispatchEvent(new MyCustomEvent(MyCustomEvent.customEventName, eventData));
    [/as]

[Simple Custom Event Sample]

[Simple Custom Event Source]

Flex Doumentation:

Flex 2.0.2 hotfix released!

Adobe has released a hotfix for the Flex SDK. Looks like there are quite a few things for the DataGrid.

Adobe – TechNote : Flex 2.0.1 SDK Hotfix 1

Flex 2.0.1 SDK hotfix 1 (build 159086) is a collection of bug fixes that have been completed since the Flex 2.0.1 release on January 5, 2007.I like this note: “Installation of this hotfix release is not recommended for customers who are not experiencing one of the described issues”

FlexLib Launched

Darron Shall announced on his blog that FlexLib is now launched.

FlexLib is a Google Code project that aims at being a concentrated effort by the Flex 2 community for creating high quality user interface components. FlexLib provides a standard component namespace, package structure, code and naming conventions, and common reusable base classes to unify the various efforts people have put forth on their own.

Also mentioned it FlexBox which Jun Heider brought to my attention yesterday. FlexBox is directory of Adobe Flex components available for developers.

Darron Shall’s full post includes some additional Flex resources. Check it out and get Flexified!