The Gulf Oil Spill

July 17th, 2010

Put this short Ted Talk video on in the background.
http://www.ted.com/talks/lang/eng/carl_safina_the_oil_spill_s_unseen_culprits_victims.html

About this talk

The Gulf oil spill dwarfs comprehension, but we know this much: it’s bad. Carl Safina scrapes out the facts in this blood-boiling cross-examination, arguing that the consequences will stretch far beyond the Gulf — and many so-called solutions are making the situation worse.
About Carl Safina

Carl Safina’s writing explores the scientific, moral and social dimensions of our relationship with nature.

Flash Builder 4 and Flex 4 Bible and Flex 4 Fun

June 24th, 2010

I normally don’t pimp out books but I’d like to mention these since I’ve read them recently. The first is Flash Builder 4 and Flex 4 Bible by David Gassner. I was migrating an app from Flex 3 to Flex 4 and ran into numerous hurdles. About 90% of our design had to be reskinned. I found this chapter in his book on skinning, http://media.wiley.com/product_data/excerpt/56/04704889/0470488956-4.pdf from this page, http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470488956.html. It contained details that the official documentation lacked. To be fair Flex 4 came out around March so I think in time, it too will have the same details.

The second book is Flex 4 Fun by Chet Haase. This book covers the graphical and animation side of Flex 4. There are a lot of books that cover the basics. This contains the kind of details an advanced developer is looking for. Take a look at a sample chapter, http://www.artima.com/samples/flex4funCh2.pdf.

I’d like to see more books by these guys so support them!

Disclaimer: I don’t receive any money or free things for this post or any post. Though I should… probably… because I would give you an accurate review either way…but i wont… but could… but won’t….

Flash Catalyst CS5 – How to make it work for you

June 24th, 2010

Update: If you are familiar with Flash Catalyst the first section describes the pros and cons. If you just want to get to the main topic of the post you can skip down to the first header.

third party observerSpeaking as a completely objective third party observer with absolutely no personal relation to the matter... Frontpage was an interesting programs. It had a great design view, properties panel, code hinting, snippets code and more. All the features were great. All these features worked for you. The horrifying thing was that it would rewrite your code sometimes reverting your work and in a many cases counter productive. When you're trying to get your site to work with both Internet Explorer 4, Internet Explorer 3 and Netscape 4 this "helpful" assistance would ruin all the work you had just done. This was before SVN so saving multiple versions of your HTML files was a constant procedure. They eventually added a "don't rewrite my code" option and it became relevant and useful. They realized that the people using their products needed more than the cookie cutter shaped designs they provided. Anyway, that is completely unrelated to this post...

Flash Catalyst

Flash Catalyst! What a neat program. :) It's been helpful in taking artwork from Photoshop and Illustrator and creating accurate hi-fidelity FXG (Flex/Flash XML Graphics tags) skins for Flex. At least as high fidelity as I've seen on the web. Since the art can remain as vector shapes and paths they don't lose there sharp edge as you zoom in or resize. Cool!

Flash Catalyst has also been valuable in learning transitions, FXG and component skinning. The goal of FC was for the designer to import the design, convert art to components or component skins, create transitions and then package it up and hand it off to the developer to add coding logic. This approach is obvious in theory but it hasn't been the case. In reality, on Flex projects it's the developer NOT the designer who is using Flash Catalyst to integrate the artwork correctly into the project.

For example, some text inputs that were in the design next to each other were in the code in completely separate Groups. So what, you say, just copy and paste them into the right Groups in the code. This had disastrous results. Since FC doesn't yet support positioning using constraints or automatic layout containers every element in the design is hard coded to an x and y position. Flash Builder could not open the design so I was stuck in code. Many buttons and inputs had no name or id so there was no way to tell what is what and where. The automatic tab order was also out of order because of this issue. So anyway, the quickest solution was to go back into FC move all the form controls under the same group layer, add names in the layers to help identify each component in code and set the tab order in the properties panel because some controls were in sub groups and would not cycle correctly.

Another example, when the skins were created for Buttons or TextInputs there was a lot of redundancy. So what one person, says, it works right? Yes and no. I don't know how much performance is affected by multiple instances of a filter but file size and memory size are important. For example, one image had three instances of the same filter:

XML:
  1. <s:GlowFilter color="#FFFFFF" alpha="1.0" blurX="10" blurY="10" includeIn="upAndSelected" inner="false" knockout="false" quality="2" strength="1"/>
  2. <s:GlowFilter color="#FFFFFF" alpha="1.0" blurX="10" blurY="10" includeIn="overAndSelected" inner="false" knockout="false" quality="2" strength="1"/>
  3. <s:GlowFilter color="#FFFFFF" alpha="1.0" blurX="10" blurY="10" includeIn="down" inner="false" knockout="false" quality="2" strength="1"/>

When it could have been rewritten like so:

XML:
  1. <s:GlowFilter color="#FFFFFF" alpha="1.0" blurX="10" blurY="10" includeIn="upAndSelected,overAndSelected,down" inner="false" knockout="false" quality="2" strength="1"/>

This redundancy was also evident in multiple image files for the same graphic. So going into FC was quickest solution to find each instance and point them to just one image file.

An important note: There isn't a place to set the ID on Flash Catalyst components. When a designer converts artwork to a component and then exports a custom component with multiple text inputs, say a registration form, none of those text inputs contain ID's. The ID is important for validation, formatting and form submission. So when the developer gets any updated designs, which he does, he has to manually find and add the ID to each text input, radio button, button, each time etc. He has to "wire" the controls back up again adding focusIn, focusOut, change, keyDown and keyUp handlers. Also adding in Place the controls back into VGroups etc.

Another amazing feature is the ability to swap out or replace images with other images or symbols. So lets say your designer has a specific graphic used throughout the design. Instead of having 10 identical images of the same image you can go to each of the images in the Design View and select one specific instance of that graphic from the library and delete the 9 extra images. Now you are only loading one image instead of 10.

Display Object Properties Panel

You can also swap out skins for components*. So say the designer creates one button skin and has 20 buttons (or graphics of buttons) total. You can reuse that same button skin in your 20 other button instances by setting the skin class in the properties panel. *Unfortunately there is a bug that prevents you from selecting a different skin. This same bug also prevents you from replacing a graphic with a component. So if you have those 20 same buttons that are originally vector art from illustrator you have to convert each one to buttons and then create new skins for each. You cannot reuse a skin. When this bug is fixed you will only have to convert the art to a button and select the previous created skin.

Summary
Flash Catalyst is version 1. Don't expect everything at once. In the meantime if we want to get the most out of FC now we have to work around these issues. The next section will tell you just that.

Editing MXML Documents
To edit your projects MXML documents we first need to find the path to the Flash Catalyst workspace. To do this publish your Flash Catalyst project (CMD / CTRL + ENTER). Now, the browsers URL shows the path to the project workspace. So in this URL, "file:///Users/judah/Library/Application Support/Adobe/Flash Catalyst/workspace/Project/bin-debug/Main.html", the project MXML documents are located at, "file:///Users/monkeypunch/Library/Application Support/Adobe/Flash Catalyst/workspace/Project/" when on a Mac.

Flash Catalyst project files

Flash Catalyst project files


Project Files Description
/src - location of the application source files
/bin - the location of any additional flex libraries
/bin-debug - location of testing swf
/html-template - location of the html template that wraps around your application
/src/Main.mxml - the main application file. make your application changes here
/src/Main.css - the css stylesheet of the main application
/src/components - the location of custom components and component skins
/src/assets/graphics - location of optimized FXG graphic symbols
/src/assets/images - location of images

You can edit these XML documents in any text editor. To apply the changes you need to save the file and refresh the Flash Catalyst project. You can do this by opening the changed document in Flash Catalyst code view. When we do this it will recognize the document has changed and prompt you to use the newer version of the file. Select Yes. If the project does not rebuild immediately publish it using CMD + Enter.

Although you can use any text editor you will want to use an editor that supports the Flex SDK. I recommend you use Flash Builder 4 or FDT. Both have debuggers, code completion and more. Now at this point, you may be saying I'm not a developer. That's ok. There are a few tips and tricks further on that will really make your project shine.

Using Flash Builder to modify, run or debug the Flash Catalyst Project
Open Flash Builder and go to File > Import > Flash Builder Project > Project Folder and select the Flash Catalyst "Project" folder that is located in the FC workspace. On Mac it is located here:
/Users/[USERNAME_HERE]/Library/Application Support/Adobe/Flash Catalyst/workspace/Project/

Once you've imported it you can run and debug it like any other Flex 4 project. You can update the component skin code and consolidate skins and graphics.

You can even round trip the changes back into FC. The important thing to remember is you must convince FC to notice and reload the updated documents if you want to see the changes reflected in the Design View.

Making the first change - Converting the group layout
The first thing we'll do is modify a layer or "Group" as it's called in code to stack its content vertically or horizontally instead of the contents positioning themselves absolutely. To do this we only need to modify a few lines of code. If you're starting with a new FC project drag 3 different components or shapes to the Design View, select them all and select Group.

Now open the MXML document that contains that Group. You can find the document and location of the Group by selecting it in FC Design View and then switching to code view. It will be selected. In your Flex editor replace "Group" with "VGroup" or "HGroup". Add the property gap to the tag to set the space between each item. For example,

XML:
  1. <s:VGroup gap="10">
  2. ...your content here...
  3. </s:VGroup>

Save the file. Next, save the file. Run the application in Flash Builder or switch back to Flash Catalyst and check for newer files (using the method described above). The content inside that Group should now be stacked horizontally or vertically one after another. You can rearrange their order by moving their position above or below the other in the FC Layers panel.

Copy and paste documents to & from Flash Catalyst Code View
You also can copy and paste documents between your editor and Flash Catalyst, thus enabling round tripping. To do this create a separate Flex project instance. Go into FC code view. In the Package Explorer you can select files and directories and then copy them via CMD + C or Edit > Copy from the title menu. You can go back to Flash Builder and paste these files into your separate project folder. After you have modified or upgraded them you can reverse the procedure and copy back to FC. Select the files in Flash Builder Package Explorer and copy them. In FC Code View select the directory where you want to copy the files to and paste them into that directory using CMD + V or Edit > Paste from the title menu. You know where the MXML documents are.

Note: If you use the first method of importing the Flash Catalyst project into Flash Builder the copying and pasting method above won't allow it. It will say that you are trying to paste the same file to the location it is already at.

Note: Save in Flash Catalyst often. When you close FC it will remove the project directory. It will recreate it when you open the FC project again. Keep that in mind.

Oh and one more thing...
You can gain a couple of rich features such as deep linking, image viewer, context menus and more using another simple modification. Stay tuned...

Enjoy and post your questions here...

Screens, keys and mice ->

June 15th, 2009

imagine walking into a coffee shop and seeing a few booths with thin lcd screens, keyboards and mice. you notice the screen is attached to the wall with a flexible monitor arm. it looks like the screen can swivel around in all directions. the lcd is plugged into the wall but oddly there is no computer connected to it. on the screen is only the logo of the coffee shop. as you are pondering the scenario a man walks in, orders a drink and sits at one of these booths. as he sits down the screen changes, the keyboard and the mouse briefly light up. the man pulls out an cell phone and sets it on the table. a message on the lcd screen says, "device detected. connect to device?". the man grabs the mouse and clicks the "yes" button shown on the screen. just then a message appears on his cell phone, "connect to screen at sbs2012?". he clicks yes and the lcd screen goes blank briefly and then fades in and shows what looks like the mac os desktop. using the mouse he opens his email program. in he receives a message with an excel spreadsheet attached. he double clicks it and it opens up in microsoft excel. he clicks on a link in the excel spread sheet and firefox is opened. a few minutes later he opens photoshop and starts editing a photo. after a few more interactions, it is becoming apparent that he is running a full version of mac os.

just then a lady walks up to another table nearby that also has a lcd monitor on it. she sets her purse down and pulls out her iphone. this table doesn't have a mouse or keyboard. are they out of stock? she reaches out and grabs the monitor in front of her, bends it back, pushes it down and pulls it toward her. it is nearly flat on the table but the back is tilted up to face her. like at the first table, it also asks her if she wants to connect her device to it. she touchs the "yes" button on the screen. ah, the lcd is a touchscreen! a message appears on her iphone and she confirms the connection. the lcd touchscreen goes black briefly and then her iphone screen displays on the monitor in high resolution. you can't really see the screen so you sit up a bit. it doesn't look like the full version of the mac os. it just looks like her iphone screen but a lot larger and much more space.

she then opens a white board program. as it opens she pulls out a fancy stylus pen from her purse. the white board program loads up. it looks like there is a chat module with some people already chatting in it. she clicks on the chat window and up pops a virtual keyboard. she types, "hi" and clicks send. the keyboard disappears. another person mentions they should get started. she types, "i'm ready". just then a floor plan appears in the main area of the screen. with her stylus she circles some areas on the floor plan and makes some notes. she then clicks a button on the screen and she says out loud, "here is where i want the new room".

another man walks in and he looks around the room. all the booths with lcd monitors are taken. he sits at a table with out either. he puts down his brief case and pulls out what looks like a laptop. it looks super light. he opens it up and the screen comes on instantly with just a logo on it. he pulls out a phone as well and pushes a few buttons on it. the screen on the laptop dims briefly and then the screen lights up with the windows operating system. he loads up a couple programs and then walks up to the counter to get a napkin. when he sits down he accidently bumps his coffee and it spills on his laptop. "ah crap" he says, "there's another $60 down the drain."

you look over at the first man. he is saving an excel file. it looks like he made some changes to it. in the lower corner of the screen he clicks the a button called "disconnect". the screen dims and then displays the logo of the coffee shop. he puts his phone in his pocket and starts to head out. as he does he turns to the second man and says walmart has a sale on virtual laptops with oled screens and 1 month battery life for only $50.

so what's this all about? it's about having a larger interactive screen for portable or small devices. for example, a toaster, a refrigerator, a watch, a remote, etc. basically any electronic device that has options can connect to a remote screen and send a application to it. so for a toaster, you'd have a toaster app that lets you set the toast time. for a refriderator app you'd set the temperature. for a microwave you'd be able to save custom microwave settings. for a watch you'd be able to set the alarm or synchronize it to atomic time clocks. the thermostat would have a nice interface to set the temperature, etc. when phone or pda's get powerful enough to run full software applications, i'd like to have the option to send the screen to a larger interactive screen and get input from it through a standards based protocol.

Cache busting your Flex SWF and the SWF Compilation Date

March 25th, 2009

So you're working on a project and you go to check it in the browser and hit refresh. You test it again and the same problem exists. But wait! Are you looking at the SWF you just compiled or a cached SWF!??!?! There have been so many times I've been working on a problem and didn't realize the SWF was cached in the browser. What if there was a way to tell if you are looking at a cached SWF or a newly compiled SWF? Well NOW YOU CAN!

Taking Igor and Paul's work a bit further I created a class you can drop into your project with one line of code, that will tell you the compilation date of your swf, if the swf is being viewed for the first time or if it is cached and a version number you can use for testing. It also provides a reload button handler.

Here is a live demo.

Here is the project download. You must go to https://www.assembla.com/wiki/show/flexcapacitor and follow the online getting started guide to pull the class into your project.