We love choice

Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://fxr.groups.adobe.com.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, Flex 4 SDK, How to, MXML, Skin, Spark

How to transfer values from a Spark component to a skin part in Flex SDK 4

Stelian Crisan | 25.08.10 | 3 Comments

Table of contents

  1. How to skin a container with padding in Flex 4 SDK – Spark
  2. How to skin a button with icon in Flex 4 SDK – spark
  3. How to transfer values from a Spark component to a skin part in Flex SDK 4
Google Buzz

Sometimes you need to pass values from components to skin, for example having a dynamic layout. Using Flex sdk 4 you can transfer values using content property of the hostComponent ({hostComponent.content}).

I made a small example that use hostComponent.content, changing the values of HSliders the colors of the component will be changed.



So in mxml file you have to set the value for content property, that is an Object:

<fx:Script>
	<![CDATA[
		import com.flexer.skin.ContentButtonSkin;
		import mx.utils.ObjectProxy;
 
		[Bindable]
		public var colors:ObjectProxy = new ObjectProxy();
	]]>
</fx:Script>
 
<s:Button width="380" height="40" label="my custom button" 
              skinClass="com.flexer.skin.ContentButtonSkin" content="{colors}" />

Into skin file you can use it like this:

<s:HGroup left="1" right="1" top="1" bottom="1" gap="0">
	<s:Rect width="33%" height="100%">
		<s:fill>
			<s:SolidColor color="{hostComponent.content.leftColor}"/>
		</s:fill>
	</s:Rect>
	<s:Rect width="34%" height="100%">
		<s:fill>
			<s:SolidColor color="{hostComponent.content.centerColor}"/>
		</s:fill>
	</s:Rect>
	<s:Rect width="33%" height="100%">
		<s:fill>
			<s:SolidColor color="{hostComponent.content.rightColor}"/>
		</s:fill>
	</s:Rect>
</s:HGroup>

Please see attached project for a closer look.

Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites
HostComponentContentFxr
HostComponentContentFxr (1)




Tags: , , , ,

This post was written by Stelian Crisan

Views: 11927

related

3 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


«
»