Android Development with Flash

Android Development with FlashThis week my first book will be released, Android Development with Flash. I am pretty excited to see it in print and on the shelf in store. This book has a very interesting story behind it. Back in January of 2010 I had started writing a book for the CS5 iPhone Packager. Literally 2 days after I had sent the final edits back, Apple had mad the announcement that they where not going to allow the use of third party tools to develop applications. I was pretty disappointed for about a week, but then the AIR Android pre-release was made available, and I began rewriting the book for Android. I spent the next 2 months feverishly tweaking and adding features to the book. Fast forward to September and a few weeks before it is set to be released, Apple removes the restriction on third party applications, and it looks like the original iPhone version will be released as well hopefully by the end of the year. I have to say that working with everyone at Wiley was amazing to work with. I was really nervous about writing my first book and everyone there helped me a great deal getting through it. It was a really great experience and I would recommend working with Wiley to anyone.

Here are some links to where you can buy it.
Wiley
Amazon USAmazon Canada
Chapters

Continue reading » · Rating: · Written on: 09-23-10 · 13 Comments »

Simple AIR 2.0 Multitouch Sample

I was really excited when Adobe made the announcement of Multitouch support in the Flash Player. Mainly because we have a bunch of Multitouch screens hanging out in the office, from our Windows 7 Touch Games Development. We made Microsoft Blackboard, Rebound and Garden Pond. So now that it is in public beta I am able to show a really simple example of a paint program running on a Dell Latitude XT Touch Laptop. Nothing fancy, but it shows off the feature.

Simple AIR 2.0 Multitouch Example from Julian Dolce on Vimeo.

Continue reading » · Rating: · Written on: 11-19-09 · 1 Comment »

AS3 SVN Library

A few months ago I started writing a svn protocol library in as3. It started with an idea for a internal tool that would allow us to select files from our svn code repository and export it and all of it’s code dependencies. And because I haven’t done a lot of work with ByteArray, or Sockets before I was pretty excited about giving this a shot. My first attempts where really rough and basic and worked for the most part, but were in no shape to be in the form of a nice library. I let it sit for a while as I was busy getting ready for FOTB and Flashpitt. Then one night I started doing some more research about the protocol and found that SVNKit, a Java SVN library, was open source. So I started going through all the source and spent a great deal of time going through how the code was structured. I couldn’t just do a straight port because of the differences that data gets returned between Java and AS3. Long story short the way they have it set up is you can make the call to the server and on the next line read the input. In AS3 you need to wait for your event to come back, and there is no guarantees that all of it is going to come back in one event either. But I was able to port some important parts like reading and writing the data. I’ve tried to keep the API’s similar, but there are instances where they just couldn’t be or didn’t make sense to. One of my goals for this project to is to make it as platform independent as possible. And by that I mean I want you to be able to use the library in the web, air, and any other Flash Player 10 player. I’ve tried to abstract out the parts that deal with writing files to disk so that this could be accomplished. But there may come a point where a feature may need AIR for whatever reason. But I’ll cross that bridge when I get to it. If that feature isn’t a super high priority chances are I will leave it out just for that reason.

That all being said I just made a fairly big commit today to the google code repository. It isn’t fully featured yet and only supports the svn:// protocol. Once I get some more of that protocol completed I plan on doing the http:// protocol. In the wiki there is an example AIR app that allows you to display directories in a tree, export files and folders, as well as trace out the log for any item in the repository.

This is still a work in progress and lots to do before it gets to a really stable state. For instance the Error handling is almost non-existent but I have placed a lot of //TODO where the errors need to be thrown. I also only have 1 svn server to test on so I am not sure how running it in other environments will work out.

I have created the library to a point where I can create our internal app, so I am not entirely sure what features I will tackle next. I may try doing commit and add, but those are fairly big. So if you have any requests I am all ears.

Continue reading » · Rating: · Written on: 11-13-09 · 5 Comments »

Fuel ANT Tasks

At Fuel Industries our projects always start with a FLA, but we use FDT for all of our coding. We wanted to have a way that we could publish our projects from FDT as well as run daily automatic builds. This is easy when working with Flex because Flex has a command line compiler, but Flash doesn’t. So we wrote custom ANT tasks in Java that will allow us to publish fla’s in multiple ways.

Here are a few examples of some of the things you can do.

First you can simply compile fla’s

<target name="fla_publish">
	<flash>
		<fla file="${src}/redsquare.fla" build="publish"/>
		<fla file="${src}/bluesquare.fla" build="export" swf="${src}/bluesquare.swf"/>
		<fla file="${src}/greensquare.fla" build="test"/>
	</flash>
</target>

The fla task can take multiple different types of values for the build parameter – publish, test, and export.
publish will simply publish the file at the current settings set for the fla.
test will compile and run the swf in the Flash IDE. This is like hitting cmd-enter/ctrl-enter
export will export the swf. In order to use this mode you must specify a output swf file.

You can also publish and test Flash CS3 Flp files

<target name="flp_publish">
	<flash>
	     <flp file="${src}/fuelanttask.flp" build="publish"/>
	</flash>
</target>

If set the build mode to “test” it will look for the flp project default file and compile that project last and test the default file.
The nice thing about using the flp task is that if one of your files has a compile error, it will stop the build process and alert you of the error. This is different then the IDE as it just keeps compile the project and you won’t see if one of your files compiled incorrectly.

We have also created a task called buildnumbercommand. This task gets the local SVN revision number and inserts it into a BuildNumber.as file. This way we have the build number accessible in ActionScript and we are able to display it automatically in our files. For instance we place ours in the right click menu so our clients can see what version of the build they are looking at.

<target name="version">
	<buildnumbercommand path="${src}" />
</target>

The path parameter is the directory in which the BuildNumber.as file is located. Below is an example of BuildNumber.as

package
{
	public class BuildNumber 
	{
		public static const BUILD_NUMBER : String = "1";
	}
}

Here are some of the other parameters for the Tasks

flash task

path – This is needed on Windows only. This is the path to your Flash IDE executable and is defaulted to the default install location for CS3 and CS4. C:\Program Files\Adobe\Adobe Flash CS3\Flash.exe and C:\Program Files\Adobe\Adobe Flash CS4\Flash.exe. If you have the Flash IDE installed in these locations you can omit this parameter.

version – accepts either “CS3″ or “CS4″. The default is “CS3″. This is used to determine which IDE to compile your files in. “CS3″ is the default and can be omitted if you want to use CS3.

deleteaso – true | false will delete your aso files before compiling any files. The default is false.

closeDocs – true | false will close your fla after it’s compiled. The default is false. This is ignored when compiling a flp project and will always close it afterwards.

quit – true | false will close the Flash IDE after all the files have been compiled.

verbose – true | false has some more output messages during compilation.

fla task

file – the path to your fla file

build – valid values are “export”, “publish”, “test”. The default is “publish”.
publish will simply publish the file at the current settings set for the fla.
test will compile and run the swf in the Flash IDE. This is like hitting cmd-enter/ctrl-enter
export will export the swf. In order to use this mode you must specify a output swf file.

swf – the file path to a swf to be compiled. This is only needed when the build parameter is set to “export” and will be ignored otherwise.

flp task

file – the path to your flp file

build – valid values are “export”, “publish”, “test”. The default is “publish”.
If set the build mode to “test” it will look for the flp project default file and compile that project last and test the default file.

UPDATE : the ANT tasks have been put up on Google code. The source, examples, documentation, and the compiled jar can be found there

http://code.google.com/p/fuelanttasks/

This is a video of me showing how to use them at Flash On The Beach during the speaker throwdown

FOTB09 – Jam Throwdown – Julian Dolce from John Davey on Vimeo.

Continue reading » · Rating: · Written on: 09-23-09 · 23 Comments »

Fix Textfields JSFL

Today Seb was having some issues when dealing with embedded fonts – read his post. He came up with some ActionScript ways to get around it. Well another way would be to use JSFL. A couple of my team members at Fuel Industries wrote the following JSFL script. It goes through your library and searches out any dynamic textfields. Once it finds one it makes sure it’s on a whole pixel, turns the auto kern off, embeds “UpperCase, LowerCase, Numerals, Punctuation” characters, and makes it not selectable. But you could make it do pretty much anything you can through JSFL.

fl.outputPanel.clear();
scanLibrary(fl.getDocumentDOM().library);
 
 
 
function getIsWholeInt(n)
{
	var s = String(n);
	if(s.indexOf(".") != -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}
 
function round(n)
{
	var s = String(n);
	var a = s.split(".");
	var num = parseInt(a[0]);
	var dec = parseInt(a[1].substr(0, 1));
	if(dec >= 5)
	{
		num++;
	}
	return num;
}
 
/**
 * Scans the supplied flash library for linked classes and makes sure the textfields are set up properly
 * @param 	library		A flash library to scan.
 */
function scanLibrary(library)
{
    var items = library.items;
    var item;
	var replaceCount = 0;
 
    for( var i = 0; i < items.length; i++ )
    {
        item = items[i];
		if (item.itemType == 'movie clip') 
		{
			var timeline = item.timeline;
			var h = timeline.layerCount;
 
			library.selectItem(item);
			library.editItem();
 
			while(h--)
			{
				var k = timeline.layers[h].frameCount;
 
				while(k--)
				{
					var j = timeline.layers[h].frames[k].elements.length;
 
					while(j--)
					{
						var elems = timeline.layers[h].frames[k].elements;
						var p = elems.length;
 
						while(p--)
						{
							if(elems[p].elementType == "text" && (elems[p].textType == "dynamic" || elems[p].textType == "input"))
							{
								//Change the Static Text Fields to Dynamic
								if(elems[p].textType == "static") {
									elems[p].textType = "dynamic";
								}
 
								//Handle all Dynamic TextFields
								if(elems[p].textType == "dynamic") {
									//Remove the ability to be selectable
									elems[p].selectable = false;
								}
 
								//Handle all Dynamic or Input Textfields
 
								//Remove the auto kern attribute
								elems[p].setTextAttr('autoKern', false);
								//Embed fonts UpperCase, LowerCase, Numerals, Punctuation
								elems[p].embedRanges = "1|2|3|4";
 
								//Pop onto whole pixel
								var matX = elems[p].matrix;
								var x = matX.tx;
								if(!getIsWholeInt(x))
								{
									matX.tx = round(x);
									elems[p].matrix = matX;
								}
 
								var matY = elems[p].matrix;
								var y = matY.ty;
								if(!getIsWholeInt(y))
								{
									matY.ty = round(y);
									elems[p].matrix = matY;
								}
 
							}
						}
 
					}
 
				}
			}
		}
    }
}
Continue reading » · Rating: · Written on: 08-24-09 · 4 Comments »

AS3 FP10 FileReference.save bug

While playing with FileReference.save today in Flash Player 10 I found a REALLY REALLY BIG BUG. It seems that if you go to overwrite a file it appends it’s contents instead of replacing.

1. Copy and paste the code below into a blank fla in CS4.
2. Compile the swf and save a file.
3. Close the swf
4. repeat step 2
5. Open the test.txt file.

I am on OSX and haven’t tested on a PC.

var str:String = "12345";
var ba:ByteArray = new ByteArray();
ba.writeUTFBytes( str );
 
var fr:FileReference = new FileReference();
fr.save(ba, "test.txt");

I did a quick search on the Adobe bug base and found some related issues from 2008 but they where for downloading files from the net.

Continue reading » · Rating: · Written on: 08-04-09 · 4 Comments »

The race for Social Network integration

There has been some interesting news coming from social networks over the last couple of days. Yesterday MySpace announced a Silverlight API for developing applications on the MySpace Open Platform. As well they announced that MySpace will be available on Windows Mobile. The move will put MySpace on most mobile platforms, which include IPhone, Blackberry, and Android. Fast forward to today and Adobe has announced the official ActionScript 3.0 Client Library for Facebook Platform API, fully supported by Facebook and Adobe. Are these announcements purely coincidental? Maybe. And I don’t want to really get into Flash vs. Silverlight debate at any level. The most interesting thing to me is that Microsoft has made a investment in Facebook, to the tune of $240 million dollars. The investment is based around their Ad Platform and search, but you think that it would put Facebook as their number 1 social network to integrate with. Instead they partner with MySpace, where a $900 million dollar search deal with Google is set to expire in the second quarter of 2010. Is this deal just the beginning of a new and long partnership? Only time will tell. The great news as developers is we are getting API’s and Frameworks that are officially supported by both parties, technology creators and social networks, which provides us with a streamlined process to deploy applications. This couldn’t come at a better time for us as we have 4 really big Facebook applications in the works. And if you want to be a part of the team to work on those we are looking for some talented people. April Fuel’s Day

Reference links

Introducing Silverlight For MySpace

Adobe Flash Platform and Facebook

Continue reading » · Rating: · Written on: 03-31-09 · No Comments »

Pixel Bender Install Location OSX

I was finally able to purchase and download Flash CS3 CS4 yesterday after a couple of days of trying. The adobe store just wouldn’t let me purchase a download. Anyways all is good now. I have been going through all of the new features in order to do a lunch and learn at our offices showing off what’s new. I’ll be posting stuff as I get my examples together as well as some changes that I have found in the Authoring Environment as well.

But the thing that drove me crazy all day today was trying to find the Pixel Bender Toolkit. I searched the docs and everything, but for whatever reason I couldn’t find anything that referenced the location. And Quicksilver didn’t find it either when I tried to open it using that.

Finally I found it by going to the labs page.

/Applications/Utilities/Adobe Utilities/Pixel Bender

There should be like a short cut or something from within the IDE. I guess that’s what JSFL is for.

Continue reading » · Rating: · Written on: 10-18-08 · 2 Comments »

McDonald’s Fairies And Dragons

I have been patiently waiting for the last 6 months to write this post. Back in April of 07 we started on what I think is the coolest project I have ever had the pleasure to work on. Today we launched www.fairiesanddragons.com. This is the accompanying site for the very first Interactive Digital Happy Meal Toy that we created for McDonald’s. The toy launched this month in some markets in Europe, and will continue to roll out from now until June. It is so great to finally see our idea and characters come to life online, on tv, and in stores after working on it for over a year now.

While the developing the toys, our talent and knowledge was tested on a daily basis. It was an emotional roller coaster at times, but we came away learning a lot. I have never been so proud of our Flash team, and entire production team for that matter. I will be giving a talk at FiTC next week on the development process of creating the interactive toy and some of the things we learned along the way. I will be posting some of the content from the presentation here afterwards, so if you can’t make it be sure to come back and check it out.
online pharmacycialislevitrasomaviagra
If you want to read more about the overall process and see screen shots and videos, check out the case study on our site.

If you are having problems installing any of the characters off of the CD you can contact support { at } fairiesanddragons.com. Please include what Operating System you are using and the issue that you are having.

Continue reading » · Rating: · Written on: 04-16-08 · 14 Comments »

Fuel Industries Launches All Girl Arcarde

All Girl Arcade (www.allgirlarcade.com) is a brand new gaming portal for girls aged 8 – 10 developed by Fuel Industries. It’s a completely free site with the goal of helping to fill the void of great kids content online. The site is based around the adventures of Fuel’s own original characters, the All Girl Star Squad, a trio of video game champions who, thanks to their gaming skills, become the unlikely heroes to a group of wacky space creatures trying to stop the evil Raveena from turning the universe into her own personal playground.

In addition to a collection of games based on this story, the site also features console and handheld reviews, a friends network, webisodes, and a ‘mall’ where players can spend the gems they win playing games. The more you play, the more additional content and gifts you can unlock! In a sea of make-up and shopping games for girls, All Girl Arcade stands out with a great story and unique characters which give girls a chance to carve their own space in the gaming world.

Continue reading » · Rating: · Written on: 04-15-08 · No Comments »