NEW Adobe Cookbooks is Live

Posted by brandonthedeveloper at September 25th, 2009

Adobe Cookbooks

The new Adobe Cookbooks website is now live.

Adobe Cookbooks is an open program to anyone wanting to contribute code recipes and solutions to common coding tasks and problems associated with Adobe technologies. Recipes from the site are also featured in the O’Reilly Cookbook series. Users can also search and request recipes.

link: http://cookbooks.adobe.com

Posted in AS 3, Adobe, Air, Books, Code| 1 Comment | 

ActionScript Cheat Sheet

Posted by brandonthedeveloper at July 19th, 2009

Well not really what I would call a cheat sheet, more a collection of useful code snippets for common ActionScript tasks. Still, a handy utility for any Flash developer or designer.

Visit Code Cheatsheet.

Posted in ActionScript, Adobe, Cheat Sheet, Code| 2 Comments | 

Removing Duplicates from an ArrayCollection

Posted by brandonthedeveloper at August 8th, 2008

I needed a Filter function to remove duplicate items from an Array Collection so I thought I’d do a quick post to share the code.


< ![CDATA[
import mx.collections.ArrayCollection;

private var tempObj:Object = {};

[Bindable]
private var filterBtnCol:ArrayCollection = new ArrayCollection(
[{label:"Frank Black"}, {label:"NOFX"}
, {label:"Jawbreaker"}, {label:"Frank Black"}, {label:"NOFX"}, {label:"Jawbreaker"}
, {label:"Frank Black"}, {label:"NOFX"}, {label:"Jawbreaker"}]
);

private function filterCollection():void {
// assign the filter function
filterBtnCol.filterFunction = deDupe;
//refresh the collection
filterBtnCol.refresh();
}

private function deDupe(item:Object):Boolean {
// the return value
var retVal:Boolean = false;
// check the items in the itemObj Ojbect to see if it contains the value being tested
if (!tempObj.hasOwnProperty(item.label)) {
// if not found add the item to the object
tempObj[item.label] = item;
retVal = true;
}

return retVal;
// or if you want to feel like a total bad ass and use only one line of code, use a tertiary statement ;)
// return (tempObj.hasOwnProperty(item.label) ? false : tempObj[item.label] = item && true);
}
]]>

Posted in AS 3, Code| 7 Comments | 

FDUG Preso Files for 12/13/2007

Posted by brandonthedeveloper at December 29th, 2007

Sorry It’s taken a while to get these loaded up. :(

The Richmond Flash Developer User Group meeting on 12/13 was great. With only a weeks notice, we had a decent sized crowd show up to see a couple presentations and get up to speed on the happenings in the Adobe community during the last year.

Lou Barber talked about differences between AS2 > AS3 and I did a little presentation on the capabilities of AIR using Flex by creating a ‘Music Finder’ AIR app.

The ‘Music Finder’ allows users to search by artist connecting to an external service (using HTTPService) and returns a result set in the e4x result format. The user could then stream an .mp3 file from the results and download the .mp3 file using URLLoader, File and FileStream objects.

Music Finder project files and the Music Finder AIR app can be found at http://www.brandonellis.org/media/musicfinder.zip.
The project was created using Flexbuilder 3 Beta 3 and requires Adobe AIR Beta 3.

Thanks again to everyone that showed up on such short notice and we’re looking forward to our next meeting on Thursday, January 17, 2008 from 6 – 8 at Plant Zero/Art Space in south Richmond, Va.

Posted in Adobe, Air, Code, FDUG, Flash, Flex, Music| 2 Comments | 

The Code Trip?

Posted by brandonthedeveloper at November 23rd, 2007

[Update : this is not a Microsoft sponsored event. Tim Heuer's reply below explains that this is being put together by Microsoft Evangelists]

Wow. I gotta say. I got caught on the announcement of the Adobe On Air Bus Tour I mean Microsoft’s Code Trip. My mouth full of hot coffee went everywhere.

Everyone that went to the On Air Events knows that Adobe does not skimp on a good party. Great schwag, great talks, great food, great beer (and those ice cream cookies from S.F.) .. heck, everything was great. If Microsoft is going to copy that idea you would think they would be trying to ‘one up’ Adobe from the start and show that their event would kick On Air Bus Tour Event ass but there are subtle differences already that lead me to believe ‘The Code Trip’ is gonna blow.

I’ve been to Microsoft developer events and they were pretty lame. Schwag consisted of a giant plastic bag or a ‘man purse’ with a cheap VS.net shirt inside. Listen Microsoft, if Adobe can afford to hand out nice Hanes Beefy Tees, so can you. No one likes cheap schwag. The talks usually were centered around VB programmers in panic mode asking embarrassing questions. And bowls of M & Ms and soda do not make a catered event.

Second, The Code Trip site. Seriously. That’s the site to kick things off? Code Trip folks, if you are going to copy the tour, atleast try to copy the On Air Bus Tour site. BTW, the javascript popUps on the learn-more page throw errors in Firefox 2.0.0.9 on OS X 10.4 and IE7 on XP. I won’t mention how typical it is to see no form validation on submissions from the front page. Yeah, form validation is hard work these days. I know you all are in planning stages but the On Air Bus Tour site had way more stuff coming out of the gate.

Last, what’s with the RV? And (not to nitpick), that’s barely an RV. That looks like a big camper. I mean if you really wanted to copy the On Air Bus Tour bus, you would get a double decker bus. And what’s with sticking with only one section of the U.S.? [Again, not an MS event so it makes more since after talking to Tim Heuer that they stick to one section of the country]

Last thing. This bit of copy from the ‘learn more page’ (to me) really encapsulates that Microsoft wants these events to be like the On Air events – “One RV, bunch of geeks, lots o’ code. Hop on the bus!“. Oh man… what is it? An RV or a bus?

Anyone want to place bets on someone at Microsoft claiming they had the tour idea first? Or, saying “It’s not like Adobe invented the touring idea”. No they didn’t but once again, Microsoft did it after someone else. Coming in second has become a bad habit for Microsoft.

Maybe it’s not even a real Microsoft promo. Maybe it’s just a satirical commentary on Microsoft ‘pulling up the rear’ for the last few years.

Scratch that, if you ‘view-source’, that’s definitely an MS site.

Posted in Adobe, Air, Code, Microsoft, Silverlight| 3 Comments | 

Simple filterFunction Example

Posted by brandonthedeveloper at November 10th, 2007

I’ve been meaning to knock out a bunch of quick Flex examples based on functions I use quite a bit in my day to day Flex coding.

Using the mx.collections.filterFunction is really easy but seems to throw off a lot of devs new to Flex. It sounds way harder than it is. :)

Here’s an example:

The filterFunction is used to filter an Array Collection to only show the items that match certain criteria. In this example, the user makes a selection from the ‘Radio Button Group’ and that fires off the Event Handler ( bandRBGClickHandler ).

private function bandRBGClickHandler(evt:Event):void {
// call the filter function
bandAryCol.filterFunction = bandFilterFunction;
// refresh the array collection
bandAryCol.refresh();
}

Inside the Event Handler, the Array Collection has a filterFunction property that gets set to the filterFunction we want to use ( bandFilterFunction ). Internally, the bandAryCol.filterFunction is iterating through the objects in the collection to find which object’s ‘band’ property match the radio button’s selected value.

private function bandFilterFunction(obj:Object):Boolean {
// return whether or not the current bandAryCol index meets the filter criteria
return (obj.band == bandRBG.selectedValue);
}

After the filterFunction has run, the refresh() method is called to reset the Array Collection’s current items. This does not actually remove any items from the collection, just does not show the items that did not match the filterFunction conditions.

That’s about it. Not hard at all and very handy. :)

Here’s the source file

Posted in Code, Flex| 7 Comments | 

Do You Love What You Do?

Posted by brandonthedeveloper at July 16th, 2007

I was having lunch the other day the other developer (my buddy Janos) and the company owner. We were talking about the current work load and what we have coming up this fall. We are in the process of trying to hire another designer ( http://www.brandonellis.org/?p=56 ) and thinking about whether (for Janos’ and my sanity) we need to hire another developer.

That was our queue to role our eyes because the thought of hiring another dev always seems like a pain in the ass and he and I are pretty picky about what type of experience we would want this dev to have. Janos and I have always been very passionate about our work. Whether it’s writing code for the frontend, the backend, SQL or Flash, we love what we do but our experiences working at other places has shown us that there are a majority of folks out there where coding is nothing but a job. They don’t get excited about it, do it at home or read up on it any other time.

My boss couldn’t believe it. “Why would people do a job they didn’t love?”, he asked. I didn’t have an answer other than that they need to pay the bills, but I feel exactly the same way. How can you expect to do a good job if you don’t really care about what you do?

How do you all feel? If you didn’t/don’t feel passionate about your work, why would you continue to do it?

Posted in Code, We're Hiring, Work| 2 Comments | 

DataAccess Utility Class

Posted by brandonthedeveloper at June 17th, 2007

I spent this weekend writing a simple ‘Data Access Layer’ utility class to be used with AIR applications and sqlite. If you are not familiar with using a ‘DAL’, data access layers act as transparent layer between your application and the database to handle the data processing. This keeps the view code clean and the sql commands as reusable methods.

You can download everything here. The zip contains the project and the AIR file.

I think I’ve commented the code pretty well. If you have any questions or comments let me know.

This work is licensed under the Creative Commons Attribution 3.0 License

Posted in Adobe, Air, Code, SQL| 8 Comments | 

Apollo File Path Gotcha

Posted by brandonthedeveloper at June 3rd, 2007

Here’s an Apollo gotcha I’ve been meaning to post for a few weeks now.

In a super secret app I am working on in Apollo, I need to allow the user to open files that have been saved to the App-Storage directory of the application. Sounds easy enough and it is easy enough but coming from a .net background I messed it all up.

You would think this would work but it doesn’t:
var file:File = File.appStorageDirectory.resolve(imageLib.selectedItem.name);
// pretend there is an image component on stage
myImage.source = file.nativePath;
// file.nativePath returns something like this on Windows:
C:\Documents and Settings\brandon\Application Data\MyApolloApp\Local Store\hungOverSanta.jpg
and this on Mac:
/Users/brandon/Library/Preferences/MyApolloApp/Local Store/hungOverSanta.jpg

both file paths are correct and if you plug them into an explorer window will pull up the image.

The correct way is like this:
var file:File = File.appStorageDirectory.resolve(imageLib.selectedItem.name);
// pretend there is an image component on stage
myImage.source = “app-storage:/” + file.name;

Huh?

I know there is some internal string association going on there but really, that is different than any type of File System Object I’ve ever seen. I only found one reply about it at the Adobe Forums. Hopefully my post here will save someone else the headache and (if I wasn’t bald already) hair pulling I went through while trying to figure this out.

Posted in Adobe, Apollo, Code, Flex, I'm stupid| 2 Comments | 

Apollo HTML Gotcha

Posted by brandonthedeveloper at March 23rd, 2007

Loading html either from a string or a location to an HTML component, if you have instances of target=”_blank” inside an anchor tag, it will not work. You can use target=”_self” though.

I got rid of them with a little regulare expression replacement (which is great in AS3):

var regex:RegExp = /target="_blank"/gi;
body = body.replace(regex, "");
html.htmlText = body

Posted in Apollo, Code| No Comments |