protected function application1_creationCompleteHandler(event:FlexEvent):void
{
loader = new Loader();
loader.contentLoaderInfo.addEventListener( Event.COMPLETE, loaderComplete );
loader.load( new URLRequest( "cards.png" ) );
}
/**
* Extract each card in the deck into their own object
* The object includes a label (rank of suit) and a Bitmap image of the card
*/
protected function loaderComplete( event:Event ):void
{
var suitsIdx:Number = 0;
var ranksIdx:Number = 0;
var cardWidth:Number = 79;
var cardHeight:Number = 123;
var a:Array = [];
var img:BitmapData;
var d:BitmapData = Bitmap( loader.content ).bitmapData;
for ( var i:int = 0; i < 52; i++ )
{
img = new BitmapData( cardWidth, cardHeight );
img.copyPixels( d, new Rectangle( ranksIdx * cardWidth, suitsIdx *
cardHeight, cardWidth, cardHeight ), new Point( 0, 0 ) );
img.draw( img, new Matrix() );
a.push( new Bitmap( img ) );
if ( i == 12 || i == 25 || i == 38 )
{
suitsIdx++;
ranksIdx = 0;
}
else
{
ranksIdx++;
}
}
list.dataProvider = new ArrayCollection(a);
list.selectedIndex = 25;
}
Wednesday, November 11, 2009
Creating in Memory BitMaps from a single image file.
I found this today while looking up information on the new Flex 4 Layout classes. This guy has a single .png file with a bunch of cards on it that he wants to use as individual images in his application. I was pretty impressed with the code, mainly because I had never really thought about it and it's an easy solution.
Friday, November 6, 2009
Getting Behind!
Wow I've really fallen off of keeping updates on here. It's been really busy here at 3-GIS over the past six or so months. We're doing a ton of extensions for our base product and continuing to push our Flex applications to do more than nature intended.
One of the cool things we've done in recent months is release a product called Mapper in a joint venture with another company. You can check it out here tucuxisoftware.com just don't ask me to explain the company name.
I think I dropped off the blog updates when I switched over my main development machine to a Mac. I got busy at that point figuring out everything about it and lost track of doing updates.
In the Adobe world this month's user group meeting we talked about Photoshop to Catalyst to Flash Builder. You can find the post about it here. You may have to be a member to see it, let me know if anyone has any issues.
The other hot topic right now is Google Wave! I've been playing around with it for the last couple of weeks. I'm still not sure what the total value of it is going to be. If anyone is reading this and would like an invite just let me know. I have 10 invites open to the first 10 people to comment here!
One of the cool things we've done in recent months is release a product called Mapper in a joint venture with another company. You can check it out here tucuxisoftware.com just don't ask me to explain the company name.
I think I dropped off the blog updates when I switched over my main development machine to a Mac. I got busy at that point figuring out everything about it and lost track of doing updates.
In the Adobe world this month's user group meeting we talked about Photoshop to Catalyst to Flash Builder. You can find the post about it here. You may have to be a member to see it, let me know if anyone has any issues.
The other hot topic right now is Google Wave! I've been playing around with it for the last couple of weeks. I'm still not sure what the total value of it is going to be. If anyone is reading this and would like an invite just let me know. I have 10 invites open to the first 10 people to comment here!
Subscribe to:
Posts (Atom)