Featured Post

CSS & IE7 in One Hand/Wish in the Other – Which gets full f

I am a bit behind in installation of IE7, I don’t enable automatic updates, I don’t install brand new MS products, and I use IE somewhere around 20 percent of the time when I have to as a daily browser.  However, I always test my developments with IE – Why you ask? – because it matters. As of November, 2006 IE7 for a 2006 release already owns 7.1% of the browser market, IE6 holds 49.9%, and IE5 still maintains 2.9%.  This is compared to Firefox’s 29.9%, Mozilla’s suite of Safari, Konqueror, and Gecko’s combined 2.5%, Netscape Navigator’s 0.2%, and Opera 7, 8, and 9 which in the same month held a 1.5% share (W3Schools, 2006). Last month I finally updated to IE7 on one of my days where I had time to perform system maintenance tasks and software updates. I have to say that at first glance I was very happy with the visual appearance. Enhancements, to IE6, such as RSS, tabbed browsing, plugin support, and developer tools brought IE7, albeit tardy, to a much more usable development platform. Microsoft reported early on in the IEBlog just following the beta 1 release that they were being proactive in many areas. Areas such as Security hold top priority to the development team. Following security at a close second, the development team emphasizes the importance of “removing the biggest causes of difficulty for web developers” (Chris Wilson, 2005). Mr Wilson also mentioned “that our intent is to build a platform that fully complies with the appropriate web standards, in particular CSS 2 (2.1, once it’s been Recommended)” (Chris Wilson, 2005). Sadly though, he goes on to state that “it isn’t even intended, in my understanding, as our priority” (Chris Wilson, 2005) in response to will IE7 pass the Acid2 Browser Test.. Basically, we have a long way to go. I have a tendency to share sentiments with Ryan Stewart as he discussed his displeasure with IE7’s CSS support. He stated “It’s a shame because the IE Team really had a chance to step up and make IE a contender” (Ryan Stewart, 2005). Later Mr. Stewart published a follow up after reviewing the IEBlog entry referenced above. Still, I tend to side with Mr. Stewart’s original view that IE could have been more and agree with his follow up that CSS is important to us. On the other side of the coin, I have been reading over at Position is Everything about the new issues developer’s are facing as a result of IE7’s conformity to CSS standards and the effect this has had on legacy developments for IE5 and 6. Now that IE7 has repaired numerous issues developer’s are concerned that their legacy code which was hacked for IE5 and IE6 no longer works in IE7. I just have to ask that maybe we should assess weather or not we should be hacking fixes in the first place? If the development community would have taken a stance and never begun to develop work-a-rounds in the first place, do you think IE would have taken a different path toward W3C standards? Since I have installed and been testing in IE7, I have to say that the intentions of my CSS layout have been better rendered in IE7 than that of Firefox. Don’t get me wrong, I love Firefox! Firefox brings me joy, usability, and an overall good feeling. I just find it interesting that things are looking pretty darn good in IE7. Technorati Tags: CSS, IE7, W3C, Acid2, Firefox Share this on del.icio.us Digg this! Share this on Reddit Buzz up! Stumble upon something good? Share it on StumbleUpon Share this on Technorati Post this to MySpace Share this on Facebook Tweet This! Email this to a friend? Share this on Linkedin Seed this on Newsvine Add this to Google Bookmarks Share this on FriendFeed Submit this to Twittley

Read More

Follow @dougrdotnet on Twitter

Extending Flex Panel With ActionScript

Posted by dougr | Posted in ActionScript, Components, Flex | Posted on 13-06-2008 | 18,226 views

Tags: , , , ,

9

On a current project I had the need to incorporate a button into a Panel title bar which would allow users to launch a new intake form. I also needed to use this panel in four different places. First option was to create a Panel component and absolutely position a button by placing the Panel container within a Canvas container. I really don’t like absolute positioning and before this was considered I had already begun researching extending Panel over on Doug McCune’s Blog. However, related to the problem which I was trying to solve, his really cool example was just a point in the right direction for me. Ultimately, Simeon, reminded me that I had a perfect example available in my Adobe Flex 2 Training from the Source book. So here is how to extend the Panel class and add custom properties to suit your needs, in this case the addition of a button placed in title bar.


package com.douglasReynolds.views.components
{
	import flash.events.Event;
	import mx.containers.Panel;
	import mx.controls.Alert;
	import mx.controls.Button;

	public class NewFormPanel extends Panel
	{
		//declare button var
		private var newFormButton:Button;

		private function doCreateForm(event:Event):void{
			//create an event - just an Alert for testing here
			Alert.show("Button Clicked");
		}
		//override the createChildren method with the properties I need
		protected override function createChildren():void{
			super.createChildren();
			//instantiate new button and assign properties
			newFormButton = new Button();
			newFormButton.label = "New";
			//add event listener for click event and call method
			newFormButton.addEventListener("click", doCreateForm);
			newFormButton.visible = true;
			//add the button to rawChildren
			rawChildren.addChild(newFormButton);
		}
		//update the display and get panel size - dynamic since the form can be resized
		protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			//gap between label and edges of button
			var margin:int = 4;
			//set the button size + margin
			newFormButton.setActualSize(50 + margin, 16 + margin);
			//define vars which determine distance from right and top of Panel
			var pixelsRight:int = 10;
			var pixelsTop:int = 4;
			//define var to width of button
			var buttonWidth:int = newFormButton.width;
			//set x and y properties to be used for positioning of button
			var x:Number = unscaledWidth - buttonWidth - pixelsRight;
			var y:Number = pixelsTop;
			//position the button in the panel
			newFormButton.move(x, y);
		}
		//constructor
		public function NewFormPanel()
		{
			super();
		}

	}
}

Then, all we have to do is use our NewFormPanel in MXML instead of Panel:


<components:NewFormPanel xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:components="com.douglasReynolds.views.components.*">
     //note the addition of components namespace to NewFormPanel properties
     //all of your normal stuff that you want to put in a panel
</components:NewFormPanel> 

Comments (9)

Hi Doug, very interesting read. I don’t have any experience with flex myself. What resource do you suggest for a noob wanting to learn?

Robert, the first place to go is http://livedocs.adobe.com/flex/3/html/ and peruse through the documentation. Once you download and install FlexBuilder 3 then you can work through the included sample projects and Adobe will send you more code examples during your trial. Jeffry Houser just posted about setting up a flex project on The Flex Show site: http://tinyurl.com/3l4ge2. Definitely check out your local user’s group scene http://flex.org/community/ There are a ton of resources out there and if you like to have a book in your hands there are plenty for the taking.

Hi Doug…

I liked your code, helped me learn a lot but for some reason when i try to put an item inside the Panel it goes to x=y=0 no matter what…

:( :(:(

Best

Cool little example. Thanks

Not bad at all. Good time saver before all other customization is done. Thnx, buddy.

Thanks for the great post. I have a related question. I am trying to set the size of the Panel Title text. I am trying to do that using the titleStyleName and some how set the fontsize in there. But I can not get to the titleStyleName in my custom component which extends panel. I am trying to change the text when updateDisplayList() over ride.

I would appreciate any direction on this.

Hi Doug,

used your code to extend the panel with a text area (i want to display a certain revision number in the panel) but when the focus is on the text area component, the – blue – outline is a few pixels off. Don’t know if this happend to the button as well ?

@Shawn, sorry I missed your question and haven’t replied until now…
I would just use CSS to manage the title style. For example:
NewFormPanel {
titleStyleName: “mypanelTitle”;
}

.mypanelTitle {
fontSize: 18;
}

@Guido, I didn’t experience any issue with the focus highlight when using button. If you are simply wanting to display in this case, maybe a text component or label component might be more appropriate??

@Guido, I did see the focus (blue outline) go off a few pixels when working with the same code and switching focus using tab key. Not sure why this happens

Write a comment