<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Seth&apos;s Blog</title>
			<link>http://www.fulgen.com/blog/seth/index.cfm</link>
			<description>The Dev Blog</description>
			<language>en-us</language>
			<pubDate>Wed, 22 May 2013 08:36:13 -0400</pubDate>
			<lastBuildDate>Thu, 22 Jun 2006 22:42:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>seth@fulgen.com</managingEditor>
			<webMaster>seth@fulgen.com</webMaster>
			
			<item>
				<title>Rebuild the Flash V2 Components?!</title>
				<link>http://www.fulgen.com/blog/seth/index.cfm/2006/6/22/Rebuild-the-Flash-V2-Components</link>
				<description>
				
				&lt;p&gt;Eep! 20 days... no entries!&lt;/p&gt;

&lt;p&gt;&lt;i&gt;Disclaimer: This is a really flash specific entry.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;I&apos;ve been working with the flash components for about 3 years now (and I&apos;ve been working on this blog for 3 weeks now ;) both with the v1 components, then later the v2 components.
&lt;/p&gt;

&lt;p&gt;After beating my head against walls night after night trying to get these things to work for me, I think I can tentatively say I&apos;ve got a grasp on them. But, it&apos;s been a long uphill battle. After all the confusion and hair tearing, I gotta say it, I love these friggin&apos; things. We&apos;ve been building applications in flash that interface with .NET or Cold Fusion web services and in this scenario, for this they simply kick ass. Despite my acquired affection, however, it started to become more apparent that for me to use these with complete confidence, I&apos;ve got to fix the things that trip me up time and again.&lt;/p&gt;

&lt;p&gt;I set off in a pursuit to recompile them with my own custom &quot;fixes&quot; that would help me love them better. I read articles on their structure and looked through the classes, but it seemed like anything I did to them didn&apos;t fix some of the basic problems I was having. They are very well integrated into each other, and I simply couldn&apos;t tell what to cut out. I&apos;ve grown to use the &quot;throw out everything and start brand new&quot; method of programming sparingly these days. You can burn many more hours redoing something and rethinking decisions that were previously made and still end up with only moderate improvements if you aren&apos;t completely sure what you&apos;re building or understand why the existing codebase is in the state it&apos;s in. So I figured this might be the perfect opportunity to get my hands dirty developing components. So I decided to rewrite the whole codebase.&lt;/p&gt;

&lt;p&gt;The problems I hope to fix are: &lt;/p&gt;

&lt;p&gt;
&lt;div class=&quot;blogsubheadgreen&quot;&gt;&quot;Adding a list box makes my movie 65k?! What the @&amp;&amp;$$?!&quot;?? ?&lt;/div&gt;
BIG AS HELL. My basic belief is that if people are going to be using flash in applications, it should be as light and small as possible. Flash is built to be lightweight! Unfortunately in it&apos;s early days it developed this reputation for &quot;Loading 30KB/10MB for the Intro&quot; and I think it&apos;s a reputation we need to forcibly overcome. It&apos;s always bothered me that simple vectors, code, and text take so long just to load. It is really disheartening to us filesize misers to add a combo box to a movie and have it jump up to 65k or add a simple button and have it jump up to 25k without even adding one sweet alpha graphic.&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;blogsubheadgreen&quot;&gt;&quot;LOOOOOADDDD DAMN YOU!&quot;&lt;/div&gt;
Loooooooooongg load times. I can watch a component draw itself. I can understand this happening with components that have several thousand pieces of information in their dataProviders, but not on the load of the actual component itself.
&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;blogsubheadgreen&quot;&gt;&quot;Hmmm, I wonder if it&apos;s done compiling ... nope, not yet.&quot;&lt;/div&gt;
When I use that import statement on the component class, the compile times become so long that my easily distractable mind is already working on something else by the time my movie compiles.&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;blogsubheadgreen&quot;&gt;&quot;I like the listbox, but the look needs to change ...&quot;&lt;/div&gt;
Skinning. It would seem to me that skinning should be as simple as saying &quot;here&apos;s a theme in my library or an swf in an accessible folder that I want to use for my button but retain all of the methods and properties of my button. Currently to skin, you have to open up an fla file copy the correct skin, change it, and put it on the first frame of your project so that you import it, then you... it&apos;s just not easy. It should be easier than it is. &lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;blogsubheadgreen&quot;&gt;For the LOVE OF MARY... can I just remove that component?!&lt;/div&gt;
Ignoring the MovieClip Object. The movie clip object is a great object! It does everything! It seems like the components are trying to reinvent the movieclip object in favor of component object, which can be a bit confusing for everyone who&apos;s familiar with the beautiful movieClip. Why can&apos;t I remove the component with removeMovieClip?&lt;/p&gt;
&lt;p&gt;
I&apos;m sure that the developers who made these components faced every single one of these problems and have continued to face them on a regular basis based on the comments that I&apos;ve read in newsgroups about them. I really love these components. I love them because of all of the data goodness that they give me access to. However, I think the process can be refined and tightened up a bit to alleviate my stress and give me a few more years back to the end of my life.&lt;/p&gt;

&lt;p&gt;It seems like every developer I&apos;ve talked to who is using these components has their own fix for them (they came out 3 years ago fer chrissake), but nobody has posted a real, live, actual, solid, realistic replacement for them. Those that are public usually have a price tag associated with them, and have their own set of incompetencies to learn and deal with. So, feeling totally frustrated, I set out to create a set of UI components that would be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Easy to Skin ... I mean REALLY easy.&lt;/b&gt; Every part of the component should be easily changed and not just with code, but with your mouse too. I&apos;m really into tactile touch. I want to put a label where I want to put it and see that I&apos;m putting it there.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Lightweight. small small small.&lt;/b&gt; These codechunks should be so small that html navigation graphics load slower than they do.&lt;/li&gt;
&lt;li&gt;Usable as a MovieClip. I love that movieclip!&lt;/li&gt;
&lt;li&gt;&lt;b&gt;V2 Architecture.&lt;/b&gt; I really dig with the listener broadcaster event model. Plus I&apos;m already using v2 components in my current clips, so if I build new components, I want to very easily be able to switch them in without having to rewrite code for existing method calls. So all the methods and properties have to mirror the V2 components.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;FREE.&lt;/b&gt; I really like the *concept* of open source. I don&apos;t like the idea of having to pay for something that already comes free with flash. If you purchase a compiled component that has a bug in it, or should work in a slightly different way than it&apos;s meant to, and you don&apos;t have the source code then you have to rely on the company for the fix (which I&apos;ve had to do). Release your components! Make &apos;em FREE!&lt;/li&gt;
&lt;/ul&gt;
Definitely pretty lofty goals, I must admit. The problem with components is the same that you have with most software, they work great until they don&apos;t. The smallest thing can stop you from using your nifty little V2 Replacements. Scenario:

&lt;p&gt;&lt;b&gt;A:&lt;/b&gt; I have my button that I&apos;ve just created as a component that I&apos;m extremely proud of! I want to use it in an application that I&apos;m building that is using existing V2 components, however, when my component is on the stage with the other components, it breaks both of them, and they both just sit there as empty boxes when compiled.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;B:&lt;/b&gt; I have my button that I&apos;ve just created as a component that I&apos;m extremely proud of! I want to use it in an application that I&apos;m building that is using existing V2 components, however, it won&apos;t focus like the other components focus.&lt;/p&gt;

&lt;p&gt;The moment you run into either of these scenarios, you can either a) not use your component, or b)rebuild all of the V2 components that you&apos;re using before you can use a single one of them. If you find yourself in that scenario, you&apos;ve just dropped into the world of building crapware. Custom components should work with everything in flash, including V2 components. I&apos;ve run into all kinds of stupid problems like these with previous components that I&apos;ve built or bought.&lt;/p&gt;

&lt;p&gt;I&apos;ve been working on it all for the past couple months between projects, and with the help of some very good component resources ( &lt;a href=&quot;http://www.person13.com/articles/components/creatingcomponents.html&quot; target=&quot;_blank&quot;&gt;person13.com&lt;/a&gt;, &lt;a href=&quot;http://www.actionscript.org&quot; target=&quot;_blank&quot;&gt;actionscript.org&lt;/a&gt;, and &lt;a href=&quot;http://www.ultrashock.com&quot; target=&quot;_blank&quot;&gt;www.ultrashock.com&lt;/a&gt;), I&apos;ve built the keystones of our new component set that will be available for public download,  source code and all.&lt;/p&gt;

&lt;p&gt;They aren&apos;t posted yet because they haven&apos;t been fully tested so I&apos;ll post a code example for you to check out and see where we&apos;re headed. Click the button in this flash movie:&lt;/p&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.fulgen.com//scripts/swfobject.js&quot;&gt;&lt;/script&gt;
&lt;div id=&quot;flashcontent&quot; align=&quot;center&quot;&gt;&lt;/div&gt;
&lt;script&gt;var so = new SWFObject(&quot;http://www.fulgen.com//blogFiles/skinningTest_1.swf&quot;, &quot;skinningTest&quot;, &quot;300&quot;, &quot;150&quot;, &quot;7&quot;, &quot;##FFFFFF&quot;);
so.addParam(&quot;wmode&quot;, &quot;transparent&quot;);
so.addParam(&quot;align&quot;,&quot;right&quot;);
so.addVariable(&quot;flashVarText&quot;, &quot;this is passed in via FlashVars for example only&quot;);
so.write(&quot;flashcontent&quot;);&lt;/script&gt;
 
&lt;p&gt;Ok, so why is this even remotely cool? It doesn&apos;t actually DO anything! Well, actually it does. It does quite a bit with only a small amount of code:&lt;/p&gt; 

&lt;code&gt;
var displayedTheme = &quot;ThemeMM&quot;;

myButton.click = function(){
	
	if(displayedTheme == &quot;ThemeMM&quot;){
		
		myButton.template = &quot;ThemeXPButton&quot;;
		myCheckBox.template = &quot;ThemeXPCheckBox&quot;;
		myRadioButton1.template = &quot;ThemeXPRadioButton&quot;;
		myRadioButton2.template = &quot;ThemeXPRadioButton&quot;;
		myRadioButton3.template = &quot;ThemeXPRadioButton&quot;;
		MC_Back.attachMovie(&quot;MC_XPBack&quot;,&quot;MC_Back&quot;, 1);
		
		displayedTheme = &quot;ThemeXP&quot;;
		
	}else{
		myButton.template = &quot;ThemeMMButton&quot;;
		myCheckBox.template = &quot;ThemeMMCheckBox&quot;;
		myRadioButton1.template = &quot;ThemeMMRadioButton&quot;;
		myRadioButton2.template = &quot;ThemeMMRadioButton&quot;;
		myRadioButton3.template = &quot;ThemeMMRadioButton&quot;;
		MC_Back.attachMovie(&quot;MC_MMBack&quot;,&quot;MC_Back&quot;, 1);
		
		displayedTheme = &quot;ThemeMM&quot;;
	}
	
}

myButton.addEventListener(&quot;click&quot;, myButtonLO);
&lt;/code&gt;

&lt;p&gt;What are you looking at? First things first, the filesize for this movie is 12.8K. This means, that I&apos;ve added three components to my flash document AND added an XP skin for each of the components and I&apos;m still at 12.8 K. If you add the V2 button, checkbox, and radiobutton to a typical flash movie, you&apos;re looking at a movie of 30K. If you add skins, then you&apos;ll add at least 5K more. so we&apos;ve basically cut our file size down to almost a third of it&apos;s size. If we keep doing this  with all the components, we&apos;re looking at drastically dropping the filesize of your flash movies that use components without losing functionality or changing your code at all.&lt;/p&gt;

&lt;p&gt;Runtime Skinning? Yep, they do that. You can skin a component at runtime with nothing more than this code:&lt;/p&gt;
&lt;code&gt;myComponent.template = &quot;somemovieinmylibrary&quot;&lt;/code&gt;

&lt;p&gt;OR this code:&lt;/p&gt;

&lt;code&gt;myComponent.template = &quot;someswfmovieinafolder.swf&quot;&lt;/code&gt;


So what&apos;s a template? It&apos;s a 14 frame Movieclip that you can slap on the component codebase. The fourteen frames represent the possible states of a button component. They are:

&lt;ul&gt;
	&lt;li&gt;&lt;span&gt;up&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;over&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;down&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;selectedUp&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;selectedOver&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;selectedDown&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;focusUp&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;focusOver&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;focusDown&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;focusSelectedUp&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;focusSelectedOver&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;focusSelectedDown&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;disabledUp&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span&gt;disabledSelected&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is the XP button Skin:&lt;/p&gt;

&lt;img src=&quot;http://www.fulgen.com//blogFiles/06222006_skinexample.gif&quot; /&gt;

&lt;p&gt;That&apos;s a pretty neat trick, but why would I want runtime skinning? Well, runtime skinning allows for you to better adjust the appearence of your apps without losing any of the methods that are associated with the component. Say if you are creating a calendar application, and you would like to signify a date as being different from the other dates, but you would like it to *behave* the same way as the other dates, skinning that particular date with a custom skin in your library would be easy to do. just build the date skin with it&apos;s states, apply it to the calendar, and you&apos;re done.&lt;/p&gt;

&lt;p&gt;What if you would like to create an application that detects whether a person is on OSX or XP and show the components in the specific style of the operating system? Wouldn&apos;t it be nice to have a folder of skins on your site that you could simply open up and change the look without having to worry about the functionality or touching your main flash file? Ahh that would be soooo nice...&lt;/p&gt;

&lt;p&gt;Or, how about the fact that skinning is suddenly really easy to do :) ?&lt;/p&gt;

&lt;p&gt;This style of skinning works very well for button type components, but how would you skin a list box, or a combo box or ... &lt;burstmybubble&gt;the DATAGRID&lt;/burstmybubble&gt;?&lt;/p&gt;

&lt;p&gt;Eeverything that you interact with is simply either, a) a button, or b) a collection of buttons. A list box consists of the following buttons:

&lt;ul&gt;
	&lt;li&gt;ListItem&lt;/li&gt;
	&lt;li&gt;scrollBar component - which consists of increaseArrow, decreaseArrow, barBackground, thumbScroll (wich consists of top, bottom, back)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See where I&apos;m going with this? The simplebutton is really the psuedo base class of everything you interact with.&lt;/p&gt;

&lt;p&gt;This is not a novel concept and I didn&apos;t make this up. The methodology is already there in flash, I&apos;m just reinterpretting it to make it easier to skin components without having to get bound up in the drawing API, and using flash the way I&apos;m used to using flash: build a movieclip, give it functionality. Anyway, this is all I&apos;m going to post for right now. I&apos;ll keep posting updates, and hopefully soon, I&apos;ll have a releasable component set for you to test out on your own.&lt;/p&gt; 
				</description>
				
				<category>Flash</category>
				
				<pubDate>Thu, 22 Jun 2006 22:42:00 -0400</pubDate>
				<guid>http://www.fulgen.com/blog/seth/index.cfm/2006/6/22/Rebuild-the-Flash-V2-Components</guid>
				
			</item>
			</channel></rss> 