May 30th, 2007

Flex Builder Tip: Fast Folders

Throughout life we have moments that make us feel like complete boneheads…doh! Today’s bonehead moment however was a blessing in disguise.

So in the past I’d create a Flex project. Then I would create my code packages. Creating the code packages would be a pretty tedious task since I’d right click the parent folder, bring up the new folder dialog, and create a folder in the package path…I’d do this over and over again until all the folders in the package path were created…boring!

Well, here’s the bonehead revelation, you can actually type a folder path in the New Folder dialog, and when you click Finish, all the Folders in the path you typed will be created! Yay for efficiency…boo for me not trying it sooner.

Anyway, here’s an illustration of what I’m talking about…

Flex Builder Fast Folders

Now the question is..was I the only one who didn’t know that? ;-)

May 25th, 2007

Memory Management and Flex 2.0.1 Hotfix 2

Flex 2.0.1 Hotfix 2 was released on May 23rd.

Usually I don’t blog just to provide links or ‘me too’ announcements to people. However in the spirit of providing resources on memory management/garbage collection, I figured it would be worthwhile to announce the Hotfix.

The reason is the following two bug fixes that directly affect memory management/garbage collection:

Memory
192015 Memory leak in Accordion.
196570 ViewStack containers are not GC’d – memory leak.

Anyway…here’s a link to the hotfix page where I received this breaking news. We all love ViewStacks…so you better download the hotfix. ;-)

-Jun

May 24th, 2007

Why care about event bubbling?

Event bubbling is one of those Flash Player concepts that has a tendency of stumbling the noob. What makes it worse is that there's not too many readily available examples out there on why you would need it.

So...I have an example that I stumbled across the other day that might help in solidifying the necessity of knowing this concept.

What is event bubbling?

In a nutshell, when the Flash Player dispatches an event, the event starts at the Stage, then it works it's way down a parent-child hierarchy in the display list - called the capture phase - until it reaches the target of the event - called the target phase - and finally it bubbles back up to the Stage - called the bubbling phase - going back up the same path it came down during the capture phase. For more info, here's the livedoc.

Why would I care?

Oftentimes, we'll have an eventListener function where we reference certain properties of a target using the event.target.{propertyName} style syntax. For instance, we need to know which label was moused over based on id. Here's a code example:

XML:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.     layout="vertical">
  4.    
  5.     <mx:Script>
  6.         <![CDATA[
  7.             import mx.controls.Alert;
  8.            
  9.             private function onMouseOver(p_evt:MouseEvent):void
  10.             {
  11.                 Alert.show('You just moused over ' + p_evt.target.id);
  12.             }
  13.         ]]>
  14.     </mx:Script>
  15.    
  16.     <mx:Canvas id="my_canvas"
  17.         backgroundColor="0xFF0000">
  18.        
  19.         <mx:Label id="my_label"
  20.             color="0xFFFFFF"
  21.             fontSize="24"
  22.             text="Roll Over Me"
  23.             width="100%"
  24.             height="100%"
  25.             mouseOver="onMouseOver(event)"/>
  26.        
  27.     </mx:Canvas>
  28.        
  29. </mx:Application>

Basically, we are trying to access the id of the label when someone mouses over it. Problem is, when you test the app and mouse over the label, you receive the following error:

ReferenceError: Error #1069: Property id not found on mx.core.UITextField and there is no default value.
at main/::onMouseOver()
at main/__my_label_mouseOver()

UITextField...huh? I thought I moused over a label? Well, the label is a composite class that has an internal child of type...yes you guessed it UITextField. Based on the error, even though you added the event listener to the Label, the mouseOver event is actually dispatched by the UITextField which unfortunately does not have an id property...but why is that?

Reason being, if you look at the Flex framework code for the Label.as class on line 1233 you'll realize that the UITextField is as large as it's parent Label if you're not using padding. Since I'm not using padding in the example code above, mousing over the Label is immediately mousing over the UITextField, and that is why the dispatch happens from there.

How do I use event bubbling to my advantage?

So, I didn't really care about the UITextField...I care about the Label...namely the id value. The good news is I know that event bubbling will cause an event to propagate from the UITextField to the Label since the Label is it's parent. I also know that an event object has a property called currentTarget in addition to target.

Although the target property will always represent the UITextField no matter where I'm adding the event listener in the display list, the currentTarget property will represent the display list ancestor of the target that I have added the event listener to, in this case, the immediate parent ancestor - the Label.

So, here is the code from above...using currentTarget vs. target. You'll notice that no errors occur during the mouseOver, and I can access the properties of the object where the event listener was added as I was expecting:

XML:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.     layout="vertical">
  4.    
  5.     <mx:Script>
  6.         <![CDATA[
  7.             import mx.controls.Alert;
  8.            
  9.             private function onMouseOver(p_evt:MouseEvent):void
  10.             {
  11.                 Alert.show('You just moused over ' + p_evt.currentTarget.id);
  12.             }
  13.         ]]>
  14.     </mx:Script>
  15.    
  16.     <mx:Canvas id="my_canvas"
  17.         backgroundColor="0xFF0000">
  18.        
  19.         <mx:Label id="my_label"
  20.             color="0xFFFFFF"
  21.             fontSize="24"
  22.             text="Roll Over Me"
  23.             width="100%"
  24.             height="100%"
  25.             mouseOver="onMouseOver(event)"/>
  26.        
  27.     </mx:Canvas>
  28.        
  29. </mx:Application>

May 15th, 2007

360 Flex – Check out who’s gonna be speaking in the land of Grunge

So 360Flex posted a list of the sessions with info on the speakers...check it out! It's gonna be Grungerific, don't forget your plaid shirt and cargo pants...

May 15th, 2007

Resource links – Getting started with Flex Automation and QTP

Today I had to provide an email to my manager providing links to Flex Automation Package and the supporting documentation. I figured it might be helpful to consolidate that information into a blog entry. Anyway, for those of you getting started with Flex Automation and QTP:

  1. Make sure you have a copy of Mercury QuickTest Professional 9.1 (QTP 9.2 is still not compatible with the automation framework (Flexcoders post)
  2. Login to the Adobe site and download the Flex Automation Package (Flex Automation Package download)
  3. After installing Flex Automation Package to the default dir -- C:\Program Files\Adobe\Flex Automation – you can:
    • View the readme file (readme_automation.htm)
    • View the EULA (license_automation.htm)
    • View the usage demo (demo\ testing_demo.swf)
  4. In addition you can:
    • View the PDF on Flex Automation with QTP (Testing with Flex with Mecury QTP)
    • View the chapter Creating Applications for Testing in the "Building and Deploying Flex 2 Applications" doc (Building and deploying Flex apps)
    • Download a zipfile containing QTP Object Type Information (QTP Object Type Reference)
    • View information about the automation classes in the Flex 2 language reference (Flex 2 language reference)
      • mx.automation
      • mx.automation.delegates
      • mx.automation.delegates.charts
      • mx.automation.delegates.containers
      • mx.automation.delegates.controls
      • mx.automation.delegates.core
      • mx.automation.events

May 11th, 2007

Reserved Words…to each their own

As developers we've all heard of reserved words. They're all around us:

ActionScript 3

ActionScript 2

Java

Various Database Platforms

Being that each language and/or environment has a different set, it's hard to keep track of it all...

So the other day I was working on some sample code for some training I was going to offer on ColdFusion CFCs and basic SQL Syntax. I had an MS Access database and was connecting to it through CF MS Access with Unicode driver. Problem was no matter how I wrote it, I was getting a SQL error when trying to run an INSERT query from a CFC to the Login table in my MS Access db...

I had pulled out all my hair and even had another developer double-check to make sure I wasn't just being spacey. (I was hoping that was the case...)

Turns out it was an issue with a reserved word...the word being 'Password'. Even worse it was a reserved word with the MS Jet 4.0 driver used by the MS Access with Unicode driver. (Look at known issue 52372)

So..how did I fix it you ask? Well...the column could be renamed to something not 'Password' but the other way that it was resolved was by recreating the DSN using the standard MS Access driver which does not use Jet 4.0.

Moral of the story...when you run into an issue that is odd and seemingly unexplainable remember: Programming languages...environments...to each their own. Make sure you're not having an issue with reserved words!

May 11th, 2007

Presenting…the survey nazi

Spent a little while working with the Adobe Presenter plugin for MS Powerpoint earlier this week. We had an Connect survey that I was asked to make some mods to...most notably making certain questions optional.

During my task, and after much tweaking and tinkering, I came to the realization that Adobe Presenter is survey nazi when it comes to allowing people to bypass questions. In other words, if you use a survey question the survey taker HAS TO answer the question before proceeding to the next slide!

Anyway, the workaround is to make all your questions graded questions, which do allow you to bypass them. Only caveat is the Likert style question which only comes in survey mode...in that case you just put some text stating that the Likert is required. ;-)

May 2nd, 2007

Cool conferences on the horizon

I've been spending the last couple of days working on some presentations for Flex/Apollo conferences - ApolloRanch, FlexManiacs, 360|Flex - I think it's the perfect time to announce them for those who read my blog.

First off, one of my fellow developers has been very swamped with work the last couple of days, so I've been assisted him with coming up with a slide presentation for a very cool conference coming up - http://apolloranch.eventbrite.com - he'll be speaking on Apollo and third-party swf2exe programs...should be a pretty happenin' presentation!

Second, in June I'll be speaking at the FlexManiacs conference in Washington DC - http://flex2conference.figleaf.com/ - I'll be doing a number on memory management and garbage collection with ample examples...it should also be a good one.

Finally, in August, I'll be heading to the land of grunge, to speak at the 360 Flex conference - http://www.360conferences.com/360flex/ - hopefully I get some constructive feedback from my presentation in DC, because I will be doing v2 of the memory management and GC talk at 360!

Anyway, if you can, come check out any of these events. If not to see me, cruise over to check out all the cool and knowledgeable speakers - Ted Patrick, Ben Forta, Matt Chotin, Matt Boles, Jeff Tapper, just to name a few - all these conferences are chock full of them...heck...the Flex Machine - Doug McCune - will even be speaking at 360! :)

Upcoming Talks





A Book I Helped Write



Community


Ignite Denver Committee

Categories

Credits