Friday Humor with Iceman
My wife makes fun of some of my "young boy movies" that I still pay homage to from time to time. Top Gun is one of those movies. It's nice to see Val Kilmer making fun of his old movie and role. It just goes to show that he is a real genius.
...
And for more Iceman/Top Gun humor check out this video:
Creating Modular Applications
A common application type to create is one large application that has many smaller applications in it. With flex builder you can always build a monolithic application that could do that. However, if you ever want to edit, debug or even add more features you are just making modification more difficult. So before Flex 2.0.1 came out I was trying to create the framework for such an application and it took quite some doing to get it to work right. At that time, flex didn't support modular applications directly ( or at least not officially ) and I had to come up with a way that felt very kludgy. When it came time to implement the framework a little while later flex 2.0.1 was out but I still hadn't heard about modules. Now I have and it makes things much easier, especially with a little help from some other info on the web. ...
My application was a simplistic (web)desktop that allows you to open applications. Because Panels and TitleWindows are the most like applications on the normal desktop they were being used along with the PopUpManager. Using Panels in conjunction with PopUpManager allows the dragging of windows and a usable focus management system. This system worked well when the applications were written into the main application but broke down when I loaded an external swf.
To finally make it work ( before I knew about modules ), I had to load in the swf then listen for the creationComplete event of my application before I could use it. Then I had to take my application ( based on Panel/TitleWindow ) out of the display list of the SWFLoader object I was using and place it in the display list of my main application. At this point I could then drag the windows and it worked for the most part. However, I had problems with scrollbars and the file size was bigger because of the added overhead of the SystemManager for my application which got thrown away anyway. I also didn't like having to write so much clean up code. It felt like such a waste of resources.
Luckily during the implementation phase, while trying to figure out how to make the scroll bars work, I came across Modules. This seemed like the way to go, less overhead and made to work with the SystemManager it is loaded into directly. At first all I gained was the lower overhead and working scroll bars. I still had the same load - listen - remove - add - cleanup scenario that was quite kludgy. But it worked effectively so I left it at that.
Recently, while reading a flex coders mailing list digest I found a link to a blog posting titled "Popup Dialogs as Modules". It explained how to turn a TitleWindow into a loadable module directly. Following Alex's example I was able to do a little refactoring and clean up my code considerably. Not to mention, it seems to run a bit snappier now ( though I have no benchmarks to prove it ). Unlike some of the comments to his post, I was able to use my modules in their own namespace within my larger project.
The final minor annoyance was debugging. I kept having to copy the debug file and rename it to use debugging on my modules. Then I remembered another posting I came across during my module research. It was entitled "How I Debug with Flex Modules" and this simple fix worked to remove this minor annoyance quite well. All you end up doing is loading the module based on whether or not your main application url has the word debug in it. I went a slightly different route for my case that looked like this:
var modulePath:String = APP_DIRECTORY + this.fileLink;// Check to see if the application is the debug version, and if
// so then use the debug module...
if ( Application( Application.application ).url.indexOf( "debug" ) >= 0 )
{
var debugFileLink:String = this.fileLink.replace( ".swf", "-debug.swf" );
modulePath = APP_DIRECTORY + debugFileLink;
}
I am very excited about using modules in many other ways as well. Some things that I have thought of, as well as read are:
- More Object Oriented design of large applications, allowing for easier updates and debugging ( I am doing this now )
- Creating new style sheets loaded at runtime
- Updating and adding complex algorithms to an application similar to dynamic link libraries
- Modules as config files for larger apps so deployment is quicker and easier.
----
Daryl "Deacon" Ducharme is currently Director of Application Development for the Interactive Agency Provis Media Group, LLC which helps organizations enhance identity, connect with customers and increase productivity.
Adding a ControlBar via Actionscript
For a project I am working on I was using a panel component that had a controlBar. Throughout the project I used something similar several times I decided to make a component that I could extend. Being a glutton for punishment( in this situation at least ), I decided to do it in actionscript instead of MXML. All of the sudden it became very difficult to figure out how to add a ControlBar component to the bottom of a panel. ...
Once the difficulty became apparent and I could not find any other successes online I had 2 choices to make it work quickly. My first choice would be to revert to using MXML for the basis of the component and embed the necessary actionscript in a script tag. My other choice was to not use a ControlBar at all. I chose the third option, be stubborn and figure it out.
The thought kept running through my head that it must be possible, it is ultimately done through actionscript. I tried several things, starting with adding -keep to my compile options and viewing the generated actionscript. In the end the generated actionscript helped me because a comment in the Panel.createComponentsFromDescriptors function didn't jive with it.
The Panel.createComponentsFromDescriptors comment was:
Restore the original document. Otherwise, when we re-add the child when the Panel is a custom component, the child will use the custom component as the document instead of using the document in which the child was declared.
However, the generated actionscript had this line:
mx_internal::_document = this;
So maybe, the CustomPanel.controlBar.document property should be the CustomPanel object itself. So I added that to my control bar initalization function and it worked.
private function initControlBar( ):void
{
var cBar:ControlBar = new ControlBar();
cBar.enabled = true;
cBar.document = this;// Add stuff to the ControlBar
...this.addChild( cBar );
}
Just make sure this is the last child in your custom panel when it gets initialized. The Panel code checks the last child to see if it is a ControlBar during initialization.
----
Daryl "Deacon" Ducharme is currently Director of Application Development for the Interactive Agency Provis Media Group, LLC which helps organizations enhance identity, connect with customers and increase productivity.
A little friday humor with Flight of the Conchords
I have posted in the past about how I am drawn to things that are french. I've also made several posts about language. That is why I find this Flight of the Conchords bit to be hilarious. It makes fun of trying to learn french, or at least the way in which many people are taught it.
...
For those of you who would like a little more, there is plenty to find if you do a google video search. However, here is one I found today that just makes me laugh again and again the more I watch it.
Self edited rap. I especially like the "hydraulics" on the bikes.
I edited the top part of the post so that it would show the video. I used to use the official version from the HBO site, but it has expired. So here is the nice way they show it:)
Garbage Collection in AVM2
Just passing along a post to an adobe blog entry regarding garbage collection and memory leaks in the new Actionscript Virtual Machine. I highly recommend following along with the powerpoint file that is linked in the blog.
Silverlight license
Working for a company that creates content playable in the flash player, I've been interested in seeing what comes of Microsoft's competing Silverlight. As of yet I haven't found any reason to install it. Nothing I have looked at requires silverlight. However today, lifehacker.com had a posting about Tafiti. Tafiti is a new search engine from Microsoft based on Silverlight. Once I went to the website it said
By clicking Get Microsoft Silverlight you accept the Silverlight license agreement.
Since the license was so prominent I decided to click on it. ...
The first thing I noticed as I read was this statement:
INSTALLATION AND USE RIGHTS. You may install and use any number of copies of the software only with the browser and operating system software named above.
If you look, Opera is not one of the software named above. Neither is Safari, yet safari is listed in the Mac license agreement which also doesn't have Opera listed.
The next thing I saw that was pretty humorous, even though it is probably standard, was:
You may not work around any technical limitations in the software;
So when it has limitations ( which all software does ) we should just sit tight and wait for Microsoft to improve it. Somehow I don't think people will follow this, they don't seem to do it anywhere else.
Then in the license came their difference on updating their player.
This software contains an Automatic Update feature that is on by default. Microsoft may change or cancel it at any time. For more information about this feature, see http://go.microsoft.com/fwlink/?LinkId=87026. You may turn off this feature while the software is running (“opt-out”).
Classic Microsoft automatic update type of mechanism. Probably a good thing for many lay people out there who don't want to interact any way with there computer but I find it annoying. I prefer the Flash express update method better, as I can choose to install the update as needed if necessary ( of course I always have the latest player because of work ).
Even though this software is as-is and really doesn't have any sort of guarantee or warranty they let you know that you do have some recourse
You can recover from Microsoft and its suppliers only direct damages up to U.S. $5.00. You cannot recover any other damages, including consequential, lost profits, special, indirect or incidental damages.
That's right, you can get $5.00 in direct damages. That's awesome. You can buy your lawyer a value meal, but you can't super size it.
Anyway, this is the first license agreement I have actually read through in its entirety ( it is pretty short ), and I thought other people might find these things interesting. I'm just wondering if I should live on the edge and attempt to install silverlight in Opera or on a linux system. That's about all the sticking it to the man I think I can come up with ( other than not installing it at all ).
Silverlight Windows license agreement
Silverlight Mac License agreement
Since silverlight does not run on linux there is no linux license.
htaccess ForceType
I ran into a problem today that I did not think about. For an application I built, the user could upload pictures that would then get uploaded to a certain folder. For a couple of reasons, the filename used was not the original and it no longer contained the filename extension ( in this case jpg ). As I was testing the front end I ran into the problem doing things this way. When you pointed to the file on the server, it was treated like a text document and no image was seen. ...
There are usually many ways to deal with a problem and this one had a couple:
- I could rewrite the backend so that it put the extension on the end of the filename. But then I would have to change all the currently uploaded files.
- I could write a PHP script to parse the data and output the proper image type.
- I could check and see if there was something to be done with htaccess.
The last idea on the list seemed the best. All the images ended up in their very own folder so I could set the rules for anything pulled from that folder. Also, it would require the least amount of changes to my previous code.
In fact it only took one line:
ForceType image/jpeg
And now all the files are processed as jpegs. I have tried this on Opera, Firefox and IE7 on windows and it works. I'll do some more checking tonight on linux but it seems to work quite well.
Bowling Shoes and Babies
Last month our oldest son went to a birthday party at a bowling alley. Well, actually we all went and our youngest got a kick out of wearing the bowling shoes. Because of the width of his feet we needed them to be a couple sizes larger than the smallest pair available, which were already a bit big. Video of him enjoying his big bowling shoes below. ...
Flex Builder in Linux
No, Adobe didn't finally port Flex Builder to the Linux platform. However, I did find a post on how to get Flex Builder working in linux. I followed the post and guess what. It worked! Well, it mostly worked. ...
As stated in the post, MXML design view does not work. But the code completion in MXML and Actionscript work great. As the article says, load it into Eclipse 3.2.2, not the current 3.3 ( Europa ). I first tried it with Europa and it would crash, whenever I would try to make a Flex Project. You also need to make sure you are using the Sun JDK. Since Fedora doesn't use it natively I had to download it and set up the eclipse.ini file with the proper path to the Sun JDK. I also had to use the Sun JRE for getting the charting components installed.
Right now it seems to work well enough. It likes to crash when I compile Flex project MXML files but does okay with a basic actionscript project file. I'll have to try it with a larger actionscript project and see if it chokes, or maybe it is just choking on converting the MXML to actionscript.
Hopefully, Adobe will make a linux version of Flex Builder but until then you have to make it work in ways such as this. Now that they have open sourced Flex 3 ( not builder ), perhaps that will make it easier to have a linux native flex builder or a similar open source project. I know that ASDT is planning on having AS3 support and using the Flex 3 SDK, maybe someone can take what they are doing a bit further and make it work with the MXML and a design view.
Link: A follow up post about Flex Buildr on Linux
Just for fun, I changed the Eclipse splash screen as well :)
Top This TV Challenge Entry
A friend of mine put an entry into the next top this TV challenge. Their entry is below. ...
Voting starts August 27th. Make sure to help them out.