Subscribe to RSS
get email updates
polyGeek.com
polyGeek.com polyGeek.com

My 360|Flex Super Bowl commercial

February 7th, 2010 . by polygeek

What does any good Superbowl commercial need?

  • Animals – check
  • Classic Rock song – check
  • Science fiction mashup – check
  • Surprise celebrity appearance . . . darn, I knew I forgot something. :)

Note: Sorry for the amateurishness video editing but I’m an amateur at this.  And MS MovieMaker is a piece of crud but it’s all I have.

I couldn’t resist making another one in honor of the HTML5 vs Flash debates that have been going on since the iPOS came out. And the comparison is made all the more appropriate by the fact that the graphics on the bridge of the Enterprise in Star Trek 2009 were done with Flash.

Get Adobe Flash player

In closing
If the preceding upset any HTML developers then I offer my most humble . . . I don’t give a shit. I’m a Flash Platform developer. My platform is better than yours and my community is way better than yours! So why don’t you go sit-and-spin on your precious standards while we Flash developers push the bleeding edge.

http://polygeek.com/2261_flex_my-360flex-super-bowl-commercial

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

Cause of the ‘css type selectors not supported’ error

February 4th, 2010 . by polygeek

Flash 10 ErrorIf you are dynamically instantiating custom components in Flex 4 you may have run into a strange runtime error:

ArgumentError: Undefined state ‘closed’.
at mx.core::UIComponent/getState()

You’re state name may be different but it’s still caused by the same issue. Basically you have no skinClass assigned to your component. So your component has no idea what to do with it’s current state. It’s no problem if you declare the component in MXML because there you can assign the skinClass. But if you are creating it dynamically you would think something like the following might work:

var myComponent:CustomComponent = new CustomComponent();
myComponent.skinClass = 'skins.CustomComponentSkin';

But you cannot do that. The only way that I know of to assign the skin is via CSS like this:

comps|CustomComponent {
	skinClass:  ClassReference( 'skins.CustomComponentSkin' );
}

That is a Type selector and so will work but only in the Application root. If you try that from inside another component then you’ll see a warning: CSS type selectors are not supported in components: ‘whateverComponentYouAreIn’.

You will have to take the above CSS and place it in the <s:Application> or in a CSS file that is declared in the <s:Application>

Upon further review
After doing a little research I’ve discovered that this is nothing new. The same situation applied in the MX days. I think I only noticed this problem recently because I always placed my CSS in a file declared in the <mx:Application>. However with a custom component it just seems natural to declare it’s CSS in the hostComponent. But I guess we’ll have none of that.

The only problem I find with this is what If I want to use different skins in different parts of my application? If anyone has a suggestion as to how to make that happen for dynamically created components then please comment.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

Flash: not dead yet. But HTML5 is still-born

February 4th, 2010 . by polygeek

Every time I read articles and comments to the effect that Flash is dead I think of the Monty Python scene Bring out your dead.

If you’re reading this blog then I don’t need to convince you of the gloriousness of Flash. But I have had a few thoughts that I haven’t seen anyone else explore that I’d like to bring up.

Influencing the young
After all the recent Flash-bashing the only lasting effect it will have is on those who are new to the field of web development or experienced developers thinking about picking up Flex. When they read all this news about Flash being dead it is likely that they will be a little more reluctant to dive in. It’s a huge investment of time to learn something like Flash. It takes years to master. If they perceive, wrongly, that Flash will be a minor player in 3-5 years then they may focus their learning elsewhere.

The upshot to that is there will be slightly less competition for jobs and freelance gigs. However this doesn’t do Adobe any good at all. It reduces their base of users and therefor their profits. And I want Adobe to be flush with money so that they can continue to pour money into improving the Flash player and Flash development tools.

Hopefully Adobe will make up the difference with CS5 – and eventually Flash Builder – being able to port Actionscript projects to Apple mobile devices.

Just who is bashing Flash?
We all know who it is that is bashing Flash. The stereo-typical web standards fanatic. I understand that this is an ideological battle for them that they are passionate about. I feel exactly the same way, if not more-so, about Apple: a company I hate with every fiber of my being and will do them harm in any way I can think. And I’m sure that most everyone has something that they get all worked up about. It’s good to be passionate about things. Gets the blood pumping.

But what good are these people in influencing the direction of web development? Not much. They may play around with HTML5 in their spare time but little of it is going to make it into public websites for 3-5 years. We all know that until Microsoft IE fully supports it HTML5 is still-born.

I can see the conversation a HTML5 fan might have with his department manager:

fanatic: We should embrace HTML5 and use the <video> tag for our corporate videos.

manager: Why would we want to do that? Will it save us money? Will it provide a better user experience? From what I hear support for the <video> tag is limited. So we’ll still need to have Flash video as a fallback, right?

fanatic: Yes, I suppose so.

manager: let me get this straight. You want to complicate matters while simultaneously spending more money?

fanatic: Well, ummmm, I didn’t think about it that way. But…

manager: Shut up and get back in your cubical. For your punishment I want you to whip at 5 Flash banner ads before lunch.

HTML5 in the long term
What is the long term outlook for HTML5? According to the recent news it seems like it is destined to kill Flash. But HTML5 just barely catches up with Flash 6 capabilities. And HTML5 has years to go before it is even fully baked. In the meantime Flash just keeps revving up faster and faster. It seems that many in the HTML5 field see the world of web development as heading to some plateau and at that point they will be able to catch up. But that’s not going to happen. Changes aren’t just coming. They’re coming faster and faster. There is absolutely no hope that HTML can stay on the cutting edge. That’s because in many instances Flash defines the cutting edge. And a new Flash Player comes out every 18 months or so. Plus we all know that new player penetration just keeps coming faster and faster and should continue to do so. Whereas with HTML it is only going to get more and more difficult to push out new features because of the fragmentation of the browser market.

I really feel sorry for the HTML5 fanatics. Like I said, I understand their passion. And I’m sure they will have lots of fun playing around with it just like we have fun playing around with Flash. But in the long run their entire approach is antiquated and inferior. It is a simple matter of evolution: Flash evolves faster than HTML. The things people are doing to push the envelope with HTML5, that is getting to the front page of Digg, is the same material that we use to make beginner tutorials for Flash newbies.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

Display HTML text in the Spark TextArea

February 3rd, 2010 . by polygeek

It isn’t immediately obvious how to display HTML text in a Spark TextArea. Back in the MX days we had textArea.htmlText which is pretty easy to use. But no such beast on the Spark version.

With a Spark text component you have to run your HTML text through a multi-dimensional phase-inducer which is handily provided through spark.utils.TextFlowUtil.importFromString( myHTMLtext );

But you don’t send the output of the importFromString method to the textArea.text. No, no, no. That would be toooo easy. With Spark there’s a new thingy called textFlow. That’s what gets the output of the importFromString() method.

Here’s a very simple example

myTextArea.textFlow = spark.utils.TextFlowUtil.importFromString(
		'some <span fontWeight="bold">bold</span> text.' );

You can use the app below if you want to play around with this and see what’s possible.

view source

There are a few issues that I’ve found with the new Spark Text components. First, I cannot get embeded <span> tags to render. For instance I can’t change the fontWeight to bold and also change the fontSize to, say, 16 on the same text. I’m not sure what’s up with that.

Also, I cannot get unordered-lists to display at all. Perhaps these are just issues that will be resolved when Flex4 is ready for primetime. If you know anything about this I’d love to read about it in the comments.

One interesting bonus I found is that creating a link automatically turns the text blue and underlines it. I’m not sure how you would override that but it’s nice that it doesn’t show up as just regular un-formatted text.

What’s funny is that starting out this was just going to be a simple example with two text fields where you could type in your HTML and then see it rendered below. Then I thought I’d add a button to make the selected text bold. And then italic. And on and on. Sometimes I just don’t know when to quit.

More examples at  Setting text in a Spark RichText control in Flex 4 at blog.FlexExamples.com.

Setting text in a Spark RichText control in Flex 4

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

Actionscript date/time conversion utilities

February 2nd, 2010 . by polygeek

RunPee.com has many places that deal with time, for instance when a peetime begins, and dates such as the day a movie comes out. So I’ve had to create a handful of simple conversion methods that I thought others might find handy. [ download source code ]

Translate minutes into an English phrase
Input -> integer number of minutes
Output -> readable string
Example: 81 -> 1 hour and 21 minutes

public static function convertTime_minutesToHoursMin( minutes:int ):String {
	var _hours:int = Math.floor( minutes / 60 );
	var _min:int = minutes % 60;
	if( minutes == 0 ) {
		return "less than a minute";
	}
	var _time:String;
	if( _hours > 0 ) { // get hours and mintutes
		_time = ( _hours > 1 ) ? _hours + " hours " : _hours + " hour ";
		if( _min > 0 ) {
			_time += ( _min > 1 ) ? "and " + _min + " minutes" : "and 1 minute";
		}
	} else { // just get minutes
		_time = ( _min > 1 ) ? _min + " minutes" : "1 minute";
	}
	return _time;
}

Convert Date Object to MySQL date format
Input -> Date Object
Output -> String, corresponding to MySQL date format
Example: Date corresponding to: March 15, 2010 returns: 2010-03-15

public static function getMySQLDate( date:Date ):String {
	var s:String = date.fullYear + '-';

	// add the month
	if( date.month < 10 ) {
		s += '0' + ( date.month + 1 ) + '-';
	} else {
		s += ( date.month + 1 ) + '-';
	}

	// add the day
	if( date.date < 10 ) {
		s += '0' + date.date;
	} else {
		s += date.date;
	}

	return s;
}

Convert MySQL date to Actionscript Date object
Input -> String, corresponding to MySQL date format
Output -> Date Object
Example: String of 2010-03-15 returns Date Object corresponding to: March 15, 2010

public static function convertMySQLDateToActionscript( s:String ):Date {
	var a:Array = s.split( '-' );
	return new Date( a[0], a[1] - 1, a[2] );
}

Remember that MySQL dates use a 1-index for the month and Actionscript uses a 0-index for the month. That’s why the second term has: a[1] – 1;

Get Day name from Date
Input -> Date Object
Output -> String
Example: Date corresponding to March 15, 2010 returns Monday

public static function getDayNameFromDate( date:Date ):String {
	switch( date.day ) {
		case 0 :
			return 'Sunday';
		case 1 :
			return 'Monday';
		case 2 :
			return 'Tuesday';
		case 3 :
			return 'Wednesday';
		case 4 :
			return 'Thursday';
		case 5 :
			return 'Friday';
		case 6 :
			return 'Saturday';
		default :
			return '';
	}
}

Get name of Month from a Date Object
Input -> Date Object
Output -> String
Example: Date corresponding to March 15, 2010 returns March

public static function getMonthNameFromDate( date:Date ):String {
	switch( date.month ) {
		case 0 :
			return 'January';
		case 1 :
			return 'February';
		case 2 :
			return 'March';
		case 3 :
			return 'April';
		case 4 :
			return 'May';
		case 5 :
			return 'June';
		case 6 :
			return 'July';
		case 7 :
			return 'August';
		case 8 :
			return 'September';
		case 9 :
			return 'October';
		case 10 :
			return 'November';
		case 11 :
			return 'December';
		default :
			return '';
	}
}

Convert a MySQL timestamp to an Actionscript Date: via Pascal Brewing

public static function convertMySQLTimeStampToASDate( time:String ):Date{
	var pattern:RegExp = /[: -]/g;
	time = time.replace( pattern, ',' );
	var timeArray:Array = time.split( ',' );
	var date:Date = new Date( 	timeArray[0], timeArray[1]-1, timeArray[2],
						timeArray[3], timeArray[4], timeArray[5] );
	return date as Date;
}

Convert an Actionscript Date Object to a MySQL timestamp: via Pascal Brewing

public static function convertASDateToMySQLTimestamp( d:Date ):String {
	var s:String = d.fullYear + '-';
	s += prependZero( d.month + 1 ) + '-';
	s += prependZero( d.day ) + ' ';

	s += prependZero( d.hours ) + ':';
	s += prependZero( d.minutes ) + ':';
	s += prependZero( d.seconds );			

	return s;
}

private static function prependZero( n:Number ):String {
	var s:String = ( n < 10 ) ? '0' + n : n.toString();
	return s;
}

Here are a few methods that are useful for the time displays in a video player

Input the seconds and return a string of the form: hours:mins:secs

public static function convertSecondsTo_HoursMinsSec( seconds:int ):String {
	var timeOut:String;
	var hours:int = int( seconds / 3600 );
	var mins:int = int( ( seconds - ( hours * 3600 ) ) / 60 )
	var secs:int = seconds % 60;

	if( isNaN( hours ) || isNaN( mins ) || isNaN( secs ) ) {
		return "--:--:--";
	}

	var minS:String = ( mins < 10 ) ? "0" + mins : String( mins );

	var secS:String = ( secs < 10 ) ? "0" + secs : String( secs );

	var hourS:String = String( hours );
	timeOut = hourS + ":" + minS + ":" + secS;
	return timeOut;
}

Input the seconds and return a string of the form: mins:sec

public static function convertSecondsTo_MinsSec( seconds:int ):String {
	var timeOut:String;
	var mins:int = int( seconds / 60 )
	var secs:int = seconds % 60;

	if( isNaN( mins ) || isNaN( secs ) ) {
		return "--:--";
	}

	var minS:String = ( mins < 10 ) ? "0" + mins : String( mins );
	var secS:String = ( secs < 10 ) ? "0" + secs : String( secs );

	timeOut = minS + ":" + secS;
	return timeOut;
}

Input seconds and return a string of the form: hours:min

public static function getHoursMinutes( seconds:int ):String {
	var timeOut:String;
	var hours:int = int( seconds / 3600 );
	var mins:int = int( ( seconds - ( hours * 3600 ) ) / 60 )
	var secs:int = seconds % 60;

	if( isNaN( hours ) || isNaN( mins ) || isNaN( secs ) ) {
		return "--:--";
	}

	var minS:String = ( mins < 10 ) ? "0" + mins : String( mins );

	var hourS:String = String( hours );
	timeOut = hourS + ":" + minS;
	return timeOut;
}

Why TronTime? Because I’m a geek and I name, some, of my classes after things from science fiction. The Tron class is where I keep most of my static utilities. I just pulled out the date/time methods into TronTime for organizational purposes.

[ download source code ]

Pascal Brewing

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

« Previous Entries    



polyGeek.com

© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites
Local Directory for Los Angeles, CA

Better Tag Cloud