HTML5 is the Future, Don’t Try and Stop It!

Flash runs great on my laptop. I’ve created apps with complex trig, physics, and 3D engines. Never with a crash on a live site. My goal was to determine how much better HTML5 might perform. I didn’t get very far in my attempts to learn HTML5 before realizing that someone else had already done the research! Not just one person but a whole bunch of people.

http://tinyurl.com/yayu7tp

I naively thought that the increase of Flash bashing was due to the lack of statistical information. Knowing that Flash performs as well or better than HTML5 leaves us with some interesting points.

Flash crashes my computer
First off, Flash has never crashed my browser or computer. Second, if Halo crashed my PC I wouldn’t call Microsoft. Wait, Microsoft made Halo, scratch that. If Left for Dead crashed my PC I wouldn’t call Microsoft. For some reason when a browser crashes due to a Flash app, Apple is responsible? No wait, Adobe is responsible? We aren’t attacking the root problem: Bad Development. Bad code will crash anything. Look at half the OS’s that Microsoft made. Wait, I have a solution! We could all adopt the approval system. It only makes sense the government should do that. I think the government should censor all of the Internet and remove the stuff that crashes anybodies computer. YES!

Flash has viruses
Really… really? I don’t even have virus scan software on my PC. Four years with no viruses (I install it and scan my system once a year for kicks). I’m sorry but viruses are caused by users. Let’s see… Flash is used heavily on gaming sites and adult sites. Which sites have the most likely hood for virus attack? Hmm… Switching the content provider to HTML5 isn’t going to stop them. It’s like telling a monkey not to eat a poisonous banana. Walking away. And being pissed the monkey is dead when you get back. Monkey! I told you not to eat the damn banana!

HTML5 is the future, don’t try and stop it!
Wow. That’s depressing. Sounds like a religious cult. HTML5 is the future and no body is trying to stop it. I for one, want options. PC vs MAC. Coffee vs Tea. Blackberry vs iPhone. I want both HTML5 and Flash. Both of them on all devices. Scratch that. It’s a free world. Anybody has the right to ban Flash or HTML5 on any device. 9 of the top 10 cell manufacturers will be supporting Flash 10.1. I have choices. We can all buy the device that supports the technologies that we prefer to use. Just don’t complain when the entire internet doesn’t conform to your little touchy thing.

Silverlight is obviously the future. HTML5 and Flash are long dead.

:)

Simple TextFlow Example

Talk about under-documented and over-complicated. The new Text Layout Framework has been a headache to use. It took far too long to get underlined, padded, editable text. Hopefully this example will save someone else the pain.

After downloading Flash Builder I thought it would be fun to check out the new Text Layout Framework. While the end result is really cool, almost all of the documentation available is already outdated. Here is an example using an ActionScript only project in Flash Builder to create underlined, padded, editable text. I threw in the undo manager for fun.

TextFlow Example:

Example of an editable TextFlow that has underline and padding.

Get Adobe Flash player

(click in the text field above, type in text than hit ctrl-z to undo.)

Full source code can be found here.

// Create a sprite that the text will put itself into
var inputTextContainer:Sprite = new Sprite();
this.addChild(inputTextContainer);

// Create a TextFlow component that will process the text
var textFlow:TextFlow = new TextFlow();
textFlow.textAlign = TextAlign.LEFT;

// Create a controller given your sprite and bounding box.
var containerController:ContainerController = new ContainerController(inputTextContainer,240,80);
containerController.verticalAlign = flashx.textLayout.formats.VerticalAlign.TOP;
textFlow.flowComposer.addController(containerController);

var paragraphElement:ParagraphElement = new ParagraphElement();  
paragraphElement.fontSize = 22;
paragraphElement.textDecoration = TextDecoration.UNDERLINE;

var spanElementTarget:SpanElement = new SpanElement();
spanElementTarget.text = "Editable text with undo capabilities.";
paragraphElement.addChild(spanElementTarget);

// Padding for p and span tags doesn't work but setting it here does
var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
textLayoutFormat.paddingTop = 10;
textLayoutFormat.paddingLeft = 20;

// Really? All this for just some underlined, padded, editable text?
textFlow.hostFormat = textLayoutFormat;
textFlow.interactionManager = new EditManager(new UndoManager());
textFlow.addChild(paragraphElement)
textFlow.flowComposer.updateAllControllers();

Next Steps
Wrap all this mess into a class that I can actually use. 15 imports and 30 lines of code is far to cumbersome to use on a regular basis. Stay tuned for an encapsulated class that takes advantage of the key features.

http://forums.adobe.com/thread/458116
http://labs.adobe.com/technologies/textlayout/demos/
http://opensource.adobe.com/wiki/display/tlf/Using+TLF+with+Flash+CS4
http://corlan.org/2009/01/19/how-to-use-text-layout-framework-in-flex-32-or-air-15/
http://forums.adobe.com/message/2646565

The Full Conference Experience

Getting the most value for your cash. With both MN.swf Camp and Flashbelt on the horizon here are some tips on how to get the most from your conference experience.

Talk to strangers
Don’t sit next to your co-worker, friend or even anyone that looks remotely familiar to you. It can be hard to walk up to random people, so sit next to them. I’ve meet some of the coolest people in the five minutes before and after a conference. Don’t worry about getting their entire life story, that’s for the after parties, just say hi and ask them about what they do. Exchange cards and remember their face.

Write on the business cards
Are you going to remember who these people are after three days? Will you remember who you intended to get in touch with? Turn that stack of useless business cards into valuable information. Write down a quick remark on the back that you will remember them by. For example “yellow shirt, flash for tv, startup.” You’ll get back home and remember that crazy guy in a yellow t-shirt who wanted to start a business with Flash for televisions. Much better than John Doe, Coder at ABC corp. This is the technique used by HR managers when they are at career fairs taking resumes. It works really well.

Attend the after parties
Most conferences include free drinks and often times appetizers at the after parties. You paid for the ticket so take advantage of this. Find that person you sat next to at the conference or the crazy guy in the yellow t-shirt. Debate with them, ask them questions. Did I mention that almost all the speakers attend these parties? How often do you get the chance to talk with the person who helped make Papervision, Flash, or the YouTube video player?

Talk to the speakers
Most of the speakers are down to earth, easy going, fun people. They want to talk with you. That’s why they flew half way across the world to speak. Pick their brains about politics, hobbies and maybe even about ActionScript.

Spread the love
Don’t talk to the same person for to long. The benefit to conferences is that everyone is in the same place. If you have enough to talk about for more than 5 or 10 minutes exchange cards and grab lunch. Don’t be afraid to break off the conversation and talk to more strangers.

Bring business cards
Or at least something that has your name on it. If your at a conference just to tunnel vision to the rooms, watch the speakers and go home than something is very wrong. Everyone at a conference has a common interest. If there is ever a time to be social, this is it.

Attend the sessions
Don’t expect the speakers to teach you a full college course in one hour. Be inspired. Ask for sample code. Ask questions. Find out who will be talking to your interests. If nothing interest you during a particular time slot than go for a walk. Take a breather. If your actively engaged in the conference skipping a few sessions isn’t going to be the end of the world. This is especially true if you are in another city / country. Take in the culture for an hour and enjoy the day.

Most importantly have fun!

Define Popup Window Size in HTML Text

Executing JavaScript in a Flash HTML TextField is both cool and a little scary. You can throw some inline JavaScript in your htmlText to dynamically specify a pop up window size when using target=”_blank.” This works in both ActionScript 2.0 and ActionScript 3.0.

Pop up Window Example:

Example of Inline Java Script

Get Adobe Flash player

(click on the link above to open a 200 x 300 pop up window)

// myTextField is a dynamic text field instance on the stage
var link:String = "http://www.blackcj.com/"
var jsText:String = "window.open('" + link + "','win','height=200,width=300,toolbar=no,scrollbars=yes'); void(0);"
myTextField.htmlText = "<a href=\"javascript:" + jsText + "\"><u>blackcj.com</u></a>";

Any JavaScript tag can be run this way. Try adding an alert right after the window.open script. Notice how they both execute. Yet another reason to ALWAYS validate your input fields when displaying htmlText. Nothing worse than somebody adding some inline JavaScript to your Flash form.

Resources
http://www.webmasterworld.com/html/3429895.htm
http://kb2.adobe.com/cps/141/tn_14192.html