ActionScript 3 Klondike Solitaire Sample Application

| 4 Comments | No TrackBacks

I've made a few changes to my solitaire game, and I'm proud to say it's showcased on labs! Here's a few of the migration issues I've had:

  • Void is now void - This was a minor but very welcome change. A simple find/replace is all you need.
  • [Embed(source="someImage.jpg")] broken? - No, this still works. The problem is that the Embed instructs the compiler to create a class that extends SkinSprite or SkinBitmap, and by default these are not included in ActionScript-only projects in FlexBuilder. The solution is to add the framework.swc to the build path, like this:
    1. Open the project properties and select ActionScript Build Path and then the Libraries tab.
    2. Click the Add SWC button and use "${FRAMEWORKS}\framework.swc" as the location.
  • Event constants no longer have their own "Type" classes for the constants. That is, "EventType.OPEN" is now "Event.OPEN"

These are the main things that I ran into. Of course, there are other migration issues from alpha 1 to beta 1, and I highly recommend you read the release notes as well.

All that being said, you can play the updated game here (requires Flash Player Alpha 3)

No TrackBacks

TrackBack URL: http://www.darronschall.com/mt/mt-tb.cgi/88

4 Comments

I still can't get the Embed syntax to work - can you illustrate how it works nows with a clear example?

Did you add the framework.swc to the build path in FlexBuilder? Your code should look something like this (untested, so maybe a syntax error or two, but you get the idea):

package
{
import flash.display.Sprite;

public class Example extends Sprite
{
[Embed(source="someImage.jpg")]
public var SomeImage : Class;

public function Example() {
// Create the image
var s:Sprite = new SomeImage();
// Display the image by adding it to the display list
addChild( s );
}
}
}

TypeError: Error #1034: Type Coercion failed: cannot convert Example_SomeImage@8dffac6 to flash.display.Sprite
at Example$iinit()

@magicwind - When you embed an image as a .swf file, use the Sprite class to add it to the display list. When you embed it as a regular image file (like .jpg), use Bitmap instead. Updated code example:

package
{
import flash.display.Sprite;
import flash.display.Bitmap;

public class Example extends Sprite
{
[Embed(source="someImage.jpg")]
private var SomeImage : Class;

[Embed(source="someImage.swf")]
private var SomeSwf: Class;

public function Example() {
// Create a bitmap from the .jpg
var b:Bitmap = new SomeImage();
addChild( b );

// Create a sprite from the .swf
var s:Sprite = new SomeSwf();
addChild( s );
}
}
}

Leave a comment



About this Entry

This page contains a single entry by darron published on February 1, 2006 8:32 AM.

O'Reilly Schwag was the previous entry in this blog.

Subtle Change in for..in Loops for ActionScript 3 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Archives

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.02