<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>Comments on: Hacking width and height properties into Flex&#8217;s CSS model</title>
	<atom:link href="https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/</link>
	<description>Hacking away at UI development</description>
	<lastBuildDate>Tue, 14 Oct 2014 06:31:19 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>By: Properties in Mohali</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-23765</link>
		<dc:creator><![CDATA[Properties in Mohali]]></dc:creator>
		<pubDate>Fri, 25 May 2012 10:29:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-23765</guid>
		<description><![CDATA[Nice one. Thanks for this nice posting. Keep giving this type of knowledge in future.]]></description>
		<content:encoded><![CDATA[<p>Nice one. Thanks for this nice posting. Keep giving this type of knowledge in future.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sly</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-22846</link>
		<dc:creator><![CDATA[Sly]]></dc:creator>
		<pubDate>Mon, 02 May 2011 08:42:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-22846</guid>
		<description><![CDATA[Hi, 

for existing components i do this:

	&lt;mx:Button label=&quot;...&quot; click=&quot;action()&quot;  styleName=&quot;myStyle&quot;  
		height=&quot;{StyleManager.getStyleDeclaration(&#039;.myStyle&#039;).getStyle(&#039;height&#039;)}&quot;

styleName - attribute is for other css properties
:)]]></description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>for existing components i do this:</p>
<p>	&lt;mx:Button label=&quot;&#8230;&quot; click=&quot;action()&quot;  styleName=&quot;myStyle&quot;<br />
		height=&quot;{StyleManager.getStyleDeclaration(&#039;.myStyle&#039;).getStyle(&#039;height&#039;)}&quot;</p>
<p>styleName &#8211; attribute is for other css properties<br />
<img src="https://www.craftymind.com/wordpress/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kingschnulli</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-18254</link>
		<dc:creator><![CDATA[Kingschnulli]]></dc:creator>
		<pubDate>Sun, 20 Dec 2009 17:25:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-18254</guid>
		<description><![CDATA[Using your tips in here I have build a little class that takes out the overriding of all the classes, you only need to override the top most container of you application and you are done. Check it out here:

http://myflex.wordpress.com/2009/12/20/adding-width-height-x-and-y-into-the-css-model-of-flex/]]></description>
		<content:encoded><![CDATA[<p>Using your tips in here I have build a little class that takes out the overriding of all the classes, you only need to override the top most container of you application and you are done. Check it out here:</p>
<p><a href="http://myflex.wordpress.com/2009/12/20/adding-width-height-x-and-y-into-the-css-model-of-flex/" rel="nofollow">http://myflex.wordpress.com/2009/12/20/adding-width-height-x-and-y-into-the-css-model-of-flex/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-14946</link>
		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Fri, 31 Jul 2009 18:50:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-14946</guid>
		<description><![CDATA[I&#039;m using exactly the code you provide above.  I&#039;m loading different compiled CSS at runtime to change the size of the button.  When I load a CSS without any width and height properties, the width and height do not revert to the default values.  That is, the button does not automatically resize to fit the text of the label and they retain the width and height of the last CSS loaded.  I tried changing the IF statement in applyProperties to

if (prop != null)
    this[item] = prop;
else
    this[item] = 0; 

but my button becomes invisible when I don&#039;t specify width and height in the CSS.  Any suggestion?]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m using exactly the code you provide above.  I&#8217;m loading different compiled CSS at runtime to change the size of the button.  When I load a CSS without any width and height properties, the width and height do not revert to the default values.  That is, the button does not automatically resize to fit the text of the label and they retain the width and height of the last CSS loaded.  I tried changing the IF statement in applyProperties to</p>
<p>if (prop != null)<br />
    this[item] = prop;<br />
else<br />
    this[item] = 0; </p>
<p>but my button becomes invisible when I don&#8217;t specify width and height in the CSS.  Any suggestion?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: justme123</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-12935</link>
		<dc:creator><![CDATA[justme123]]></dc:creator>
		<pubDate>Mon, 08 Jun 2009 14:15:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-12935</guid>
		<description><![CDATA[I&#039;m a bit late on the table, but someone might be interested in a solution that uses include to avoid code duplication for adding this approach to multiple classes.

http://www.actionscript.org/forums/showthread.php3?t=208349]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m a bit late on the table, but someone might be interested in a solution that uses include to avoid code duplication for adding this approach to multiple classes.</p>
<p><a href="http://www.actionscript.org/forums/showthread.php3?t=208349" rel="nofollow">http://www.actionscript.org/forums/showthread.php3?t=208349</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark van den Bergh - Blog &#187; Blog Archive &#187; Setting width and height in Flex using CSS</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-11593</link>
		<dc:creator><![CDATA[Mark van den Bergh - Blog &#187; Blog Archive &#187; Setting width and height in Flex using CSS]]></dc:creator>
		<pubDate>Sat, 09 May 2009 16:47:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-11593</guid>
		<description><![CDATA[[...] Sean Christmann has a nice solution for this. He uses HBox, I&#8217;ll use TextInput as an example: [...]]]></description>
		<content:encoded><![CDATA[<p>[&#8230;] Sean Christmann has a nice solution for this. He uses HBox, I&#8217;ll use TextInput as an example: [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alejandro Madrigal</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-5837</link>
		<dc:creator><![CDATA[Alejandro Madrigal]]></dc:creator>
		<pubDate>Mon, 01 Dec 2008 02:09:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-5837</guid>
		<description><![CDATA[Hi, I read your post because I was looking info on how to change width, height and other properties trough css.

I came with a solution to modify the CSS when you change the properties.

I spent a few hours trying to do so, and I&#039;ll be gladly if you tell me of a way to improve the code.

Basically what I did was overriding the setters for those properties. Pretty much like this:

class .... extends Box{

  private var _RealizarModificacionAPropiedadInternaPublica:Boolean;

  override public function set width( value:Number ):void{
		
    if( this._RealizarModificacionAPropiedadInternaPublica ){
		
      super.width = value;	
     this._RealizarModificacionAPropiedadInternaPublica = false;

     }else{

      this.setStyle( CineticaContenedorCorredizo.ESTILO_ANCHO_PRINCIPAL, value );
				
    }
					
  }

override public function styleChanged( styleProp:String ):void{

  switch( styleProp ){
	
	case CineticaContenedorCorredizo.ESTILO_ANCHO_PRINCIPAL:
			
	  this._RealizarModificacionAPropiedadInternaPublica = true;
	  this.width = this.getStyle( &#039;width&#039; );
	  this.invalidateDisplayList( );
	  break;

	default:
	   super.styleChanged( styleProp );
		break;
	
	}

  }  

}

Let me know what you think.]]></description>
		<content:encoded><![CDATA[<p>Hi, I read your post because I was looking info on how to change width, height and other properties trough css.</p>
<p>I came with a solution to modify the CSS when you change the properties.</p>
<p>I spent a few hours trying to do so, and I&#8217;ll be gladly if you tell me of a way to improve the code.</p>
<p>Basically what I did was overriding the setters for those properties. Pretty much like this:</p>
<p>class &#8230;. extends Box{</p>
<p>  private var _RealizarModificacionAPropiedadInternaPublica:Boolean;</p>
<p>  override public function set width( value:Number ):void{</p>
<p>    if( this._RealizarModificacionAPropiedadInternaPublica ){</p>
<p>      super.width = value;<br />
     this._RealizarModificacionAPropiedadInternaPublica = false;</p>
<p>     }else{</p>
<p>      this.setStyle( CineticaContenedorCorredizo.ESTILO_ANCHO_PRINCIPAL, value );</p>
<p>    }</p>
<p>  }</p>
<p>override public function styleChanged( styleProp:String ):void{</p>
<p>  switch( styleProp ){</p>
<p>	case CineticaContenedorCorredizo.ESTILO_ANCHO_PRINCIPAL:</p>
<p>	  this._RealizarModificacionAPropiedadInternaPublica = true;<br />
	  this.width = this.getStyle( &#8216;width&#8217; );<br />
	  this.invalidateDisplayList( );<br />
	  break;</p>
<p>	default:<br />
	   super.styleChanged( styleProp );<br />
		break;</p>
<p>	}</p>
<p>  }  </p>
<p>}</p>
<p>Let me know what you think.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Schafer</title>
		<link>https://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/comment-page-1/#comment-5490</link>
		<dc:creator><![CDATA[Scott Schafer]]></dc:creator>
		<pubDate>Mon, 10 Nov 2008 17:48:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model/#comment-5490</guid>
		<description><![CDATA[This is very cool and useful - thanks for posting it. However, it seems to have a limitation: if you want to specify the position or dimensions of a component through CSS, you have to put it in an extHBox. What I really wanted is to be able to specify dimensions for, say, a text label directly in that text label&#039;s CSS declaration.

So here&#039;s what I came up with. This is a Canvas that not only gets its position and dimension properties from its CSS declaration, but gives the same flexibility to its children.

package view.containers
{
	/* inspired by http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model
		
		This is a canvas that allows for the properties width, height, etc (see the properties array) to be set
		through the component&#039;s CSS file.  
	*/
	
	import mx.containers.Canvas;
	import mx.core.IUIComponent;
	import mx.core.UIComponent;

	public class CanvasExt extends Canvas
	{
		private static const properties : Array = [&quot;width&quot;, &quot;height&quot;, &quot;percentWidth&quot;, &quot;percentHeight&quot;, &quot;x&quot;, &quot;y&quot;, &quot;visible&quot;];
	
		public function CanvasExt()
		{
			super();
		}

		override public function styleChanged(styleProp:String):void
		{
			super.styleChanged(styleProp);
			if(!styleProp &#124;&#124; styleProp == &quot;styleName&quot;)
			{ 
				//if runtime css swap or direct change of stylename
				updateProperties(this);
				for ( var i : int = 0; i &lt; numChildren; i++ )
				{
					var child : UIComponent = UIComponent ( getChildAt ( i ) );
					updateProperties ( child );
				}				
			}
		}
		
		private function updateProperties(obj:UIComponent):void
		{
			for each (var item:String in properties)
			{
				var prop:Object = obj.getStyle(item);
				if(prop != null)
					obj[item] = prop;
			}
		}
	}
}]]></description>
		<content:encoded><![CDATA[<p>This is very cool and useful &#8211; thanks for posting it. However, it seems to have a limitation: if you want to specify the position or dimensions of a component through CSS, you have to put it in an extHBox. What I really wanted is to be able to specify dimensions for, say, a text label directly in that text label&#8217;s CSS declaration.</p>
<p>So here&#8217;s what I came up with. This is a Canvas that not only gets its position and dimension properties from its CSS declaration, but gives the same flexibility to its children.</p>
<p>package view.containers<br />
{<br />
	/* inspired by <a href="http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model" rel="nofollow">http://www.craftymind.com/2008/03/31/hacking-width-and-height-properties-into-flexs-css-model</a></p>
<p>		This is a canvas that allows for the properties width, height, etc (see the properties array) to be set<br />
		through the component&#8217;s CSS file.<br />
	*/</p>
<p>	import mx.containers.Canvas;<br />
	import mx.core.IUIComponent;<br />
	import mx.core.UIComponent;</p>
<p>	public class CanvasExt extends Canvas<br />
	{<br />
		private static const properties : Array = [&#8220;width&#8221;, &#8220;height&#8221;, &#8220;percentWidth&#8221;, &#8220;percentHeight&#8221;, &#8220;x&#8221;, &#8220;y&#8221;, &#8220;visible&#8221;];</p>
<p>		public function CanvasExt()<br />
		{<br />
			super();<br />
		}</p>
<p>		override public function styleChanged(styleProp:String):void<br />
		{<br />
			super.styleChanged(styleProp);<br />
			if(!styleProp || styleProp == &#8220;styleName&#8221;)<br />
			{<br />
				//if runtime css swap or direct change of stylename<br />
				updateProperties(this);<br />
				for ( var i : int = 0; i &lt; numChildren; i++ )<br />
				{<br />
					var child : UIComponent = UIComponent ( getChildAt ( i ) );<br />
					updateProperties ( child );<br />
				}<br />
			}<br />
		}</p>
<p>		private function updateProperties(obj:UIComponent):void<br />
		{<br />
			for each (var item:String in properties)<br />
			{<br />
				var prop:Object = obj.getStyle(item);<br />
				if(prop != null)<br />
					obj[item] = prop;<br />
			}<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
