Archive for the ‘Adobe Certifications’ Category

External style sheets in Flex4 or FlashBuilder 4

January 28th, 2011 by aabhaanjan

style_css

In flex we can use external style sheet. We can choose a CSS file and set the properties of components in it by calling the  style sheet into the main application.

Example:

Test.mxml

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx”

minWidth=”955″ minHeight=”600″>

<fx:Style source=”MyCSS.css”/>

<s:Button id=”btn”  label=”Example of External Skinning”

styleName=”button”

x=”103″ y=”28″ width=”483″ height=”89″/>

</s:Application>

[/xml]

MyCSS.css

[xml]

/* CSS file */

@namespace s “library://ns.adobe.com/flex/spark”;

@namespace mx “library://ns.adobe.com/flex/mx”;

.button{

font-family:”Verdana”;

font-size:14px;

text-align:center;

color:#FF3300;

font-weight:bold;

}

[/xml]

Tags: , , ,

IMPORTANT POINTS ABOUT STYLE IN Flex 4 or Flash Builder

January 28th, 2011 by aabhaanjan

1. The default style sheets

Flex includes defaults.css style sheets in the following SWC files:

a.) flex4.swc (Spark theme style sheet)

b.)  frameworks.swc (default framework style sheet)

By default  all applications use these style sheets. These style sheets apply consistent styles across all components.

2. Local style definitions

We Use the <fx:Style> tag to define styles that apply to the current document and its children. The <fx:Style> tag contains style sheet definitions that adhere to the CSS syntax.

The <fx:Style> tag uses the following syntax to define local styles:

[xml]

<fx:Style>

@namespace namespace_identifiernamespace_string;

selector_name {

style_property: value;

[…]

}

</fx:Style>

[/xml]


3. StyleManager class

Using the StyleManager, we  can define new CSS style declarations and apply them to controls in the applications.

Setting styles with the StyleManager

To set a value using the StyleManager, use the following syntax:

styleManager.getStyleDeclaration(style_name).setStyle(“property”, value);

4. getStyle() and setStyle() methods

we use the setStyle() and getStyle() methods to manipulate style properties on instances of controls. The following example sets the fontSize to 15 and the color to 0x9933FF on only the myButton instance:

[xml]

<?xml version=”1.0″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”

creationComplete=”initApp()”>

<fx:Script><![CDATA[

public function initApp():void {

myButton.setStyle(“fontSize”,15);

myButton.setStyle(“color”,0x9933FF);

}

]]></fx:Script>

<s:Button id=”myButton” label=”Sample of setStyle”/>

</s:Application >

[/xml]

5. Inline styles

Use attributes of MXML tags to apply style properties. These properties apply only to the instance of the control.

The following example sets the fontSize to 15 and the color to 0x9933FF on the myButton instance:

[xml]

<?xml version=”1.0″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”>

<s:Button id=”myButton” color=”0xFF0033″ fontSize=”15″ label=”Sample of InlineStyle”/>

</s:Application>

[/xml]

6. Setting global styles

To set a global style that is inheritable, we set its value on the container.

All children of that container, including other containers, inherit the value of that style property.

By using global styles, we can apply noninheritable styles to all controls that do not explicitly override that style.

Flex provides the following ways to apply styles globally:

a.) StyleManager global style

b.) CSS global selector

Tags: , , , , , , , , , ,

Using styles in Flex 4

January 27th, 2011 by aabhaanjan

We can modify the appearance of components through style properties.

Important points :

  1. The style properties that we can set on a component depend on the component’s architecture.
  2. The components in the MX component set (mx.controls.* and mx.containers.* packages) take one set of styles. Components in the Spark component set (spark.components.* package) allow an entirely different set of styles.
  3. Flex does not support controlling all aspects of component layout with CSS.
  4. Properties such    as xywidth, and height are properties, not styles, of the UIComponent class, and therefore cannot be set in CSS.
  1. For MX components to use CSS it should  implement the IStyleClient interface.

Example :

[xml]

<?xml version=”1.0″?>

<!– modules/StyleModLoaderApp.mxml –>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx”>

<s:layout>

<s:VerticalLayout/>

</s:layout>

<fx:Style>

@namespace s “library://ns.adobe.com/flex/spark”;

s|Button {

color:blue;

cornerRadius:10;

}

</fx:Style>

<s:Button id=”myButton” label=”Sample Styling”/>

</s:Application>

[/xml]

Tags: , , , ,

How to create a component skin using FXG

January 24th, 2011 by aabhaanjan

In this tutorial, we  will  create a component skin using FXG.

Step 1: Create a new Button skin file.

Create new MXML file for skin. Choose name and host component type. Your code

Will appear like Step2.

Step 2: Review the skin class.

You will get the states as you have selected host component type button.

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Skin xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx”>

<!– host component –>

<fx:Metadata>

[/xml]

[HostComponent(“spark.components.Button”)]

[xml]

</fx:Metadata>

<!– states –>

<s:states>

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>disabled” />

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>down” />

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>over” />

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>up” />

</s:states>

<!– SkinParts

name=labelDisplay, type=spark.components.supportClasses.TextBase, required=false

–>

</s:Skin>

[/xml]

Step 3: Review the graphics code.

This file was created by drawing in Fireworks and then selecting Commands > Export to FXG. You can also create FXG files using Illustrator or Photoshop.

Paste this FXG file into your src folder. It will look like this.

[xml]

<?xml version=”1.0″ encoding=”UTF-8″?>

<Graphic version=”1.0″ xmlns=”http://ns.adobe.com/fxg/2008″ xmlns:fw=”http://ns.adobe.com/fxg/2008/fireworks”  viewHeight= “25” viewWidth= “25”>

<Library>

</Library>

<Group fw:type=”page”>

<Group fw:type=”state”>

<Group fw:type=”layer”>

<Path winding=”evenOdd” data=”M 2 13 C 2 7 7 2 13 2 C 18 2 23 7 23 13 C 23 18 18 23 13 23 C 7 23 2 18 2 13 Z ” blendMode=”normal” alpha=”1″>

<fill>

<SolidColor color=”#000000″ alpha=”1″/>

</fill>

<stroke>

<SolidColorStroke color=”#FF3300″ weight=”3″/>

</stroke>

</Path>

<Path winding=”evenOdd” data=”M 13 6 L 13 18″ blendMode=”normal” alpha=”1″>

<stroke>

<SolidColorStroke color=”#FF3300″ weight=”2″/>

</stroke>

</Path>

<Path winding=”evenOdd” data=”M 7 12 L 19 12″ blendMode=”normal” alpha=”1″>

<stroke>

<SolidColorStroke color=”#FF3300″ weight=”2″/>

</stroke>

</Path>

</Group>

</Group>

</Group>

</Graphic>

[/xml]

Step 4: Add the graphics to the skin.

In buttonSkin.mxml add xmlns:local and <local:BiggerButton/> This tells the compiler where to find this class.

Now your code will look like this :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Skin xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx” xmlns:local = “*”>

<!– host component –>

<fx:Metadata>

[/xml]

[HostComponent(“spark.components.Button”)]

[xml]

</fx:Metadata>

<!– states –>

<s:states>

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>disabled” />

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>down” />

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>over” />

<s:Statefont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>up” />

</s:states>

<local:BiggerButton/>

<!– SkinParts

name=labelDisplay, type=spark.components.supportClasses.TextBase, required=false

–>

</s:Skin>

[/xml]

Step 5: Add the skin to the button.

Here I have added the skinClass to my  button in the testSkin.mxml file.

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark” xmlns:local=”*”>

<s:Buttonfont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>biggerBtn” skinClass=”buttonSkin” x=”38″ y=”28″/>

</s:Application>

[/xml]

Tags: , , , , , , , , , ,

Creating a User Interface (UI) – Spark skins

January 24th, 2011 by aabhaanjan

Lets move to the other points of section Creating a User Interface (UI). There will be some question from Change the look and feel of a design by using API styles, style sheets, Spark skins, filters and blends, and visual customizations by using Halo.

Lets start with Spark skins first.

Spark skins :

The new features of Flex 4 SDK separates developer and designers by separating a component’s visual appearance from component’s coding or logic part. The new feature Spark provides  a design-oriented subset of MXML, and separates design-oriented component features into a component’s companion “skin” file.

FGX :

1. It is new MXML subset for skins,

2. is valid XML code, and can be specified either inside an MXML file defining a component or, more often, in a separate file.

3. FGX files can declare any visual aspect of a component.

4. An FGX file, for instance, can define runtime graphics classes that draw shapes, specify containment of sub-components, define component effects, transitions, and even specify layout inside the component

5. In Flex 4, the runtime graphics primitives directly map to graphics classes in Flash Player 10

6. Default look and feel is known as Halo

7. Catalyst :Adobe provided a specialized designer tool, Catalyst, for the purpose of working with FGX content. Using this tool, a designer can create pixel-perfect application shells complete with behaviors, transitions, and even data placeholders that are ready for integration and implementation by a developer using Flash Builder 4.

8. the term Halo components refers to components originally included in Flex 3. The term Spark components refers to the new set of components in Flex 4.

Writing a simple button skin

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”>

<s:Group verticalCenter=”0″ horizontalCenter=”0″>

<s:Rectfont-size:10.0pt;font-family:”Courier New”; mso-fareast-font-family:”Times New Roman”;color:#990000;mso-font-kerning:0pt; mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>rect” radiusX=”4″ radiusY=”4″ top=”0″ right=”0″ bottom=”0″ left=”0″>

<s:fill>

<s:SolidColor color=”0xFF3300″ />

</s:fill>

<s:stroke>

<s:SolidColorStroke color=”0x131313″ weight=”1″/>

</s:stroke>

</s:Rect>

<s:Label text=”Skinned Button!” color=”0x121212″ textAlign=”center” verticalAlign=”middle”

horizontalCenter=”3″ verticalCenter=”1″

left=”23″ right=”17″ top=”7″ bottom=”5″

/>

</s:Group>

</s:Application>

[/xml]

Tags: , , , , , , , , , , , , ,

Flash Builder 4- Navigators

January 7th, 2011 by aabhaanjan

navigators_flash_builderflex_cert3

Accordion

Component Type : mx.containers

important points :

1. An MX Accordion navigator container has a collection of child MX containers or Spark NavigatorContent containers, but only one of them at a time is visible.

2. There is one navigator button associated with each child container, and each navigator button belongs to the Accordion container, not to the child.

3. The direct children of an MX navigator container must be MX containers, either MX layout or MX navigator containers, or the Spark NavigatorContent container.

4. The Accordion container does not extend the ViewStack container, but it implements all the properties, methods, styles, and events of the ViewStack container, such as selectedIndex and selectedChild.

Default sizing characteristics:

Characteristic Description
Default size According to the currently active child.
Container resizing rules Using resizeToContent property
Child sizing rules Children are sized to their default size.
Default padding -1 pixel for the top, bottom, left, and right values.

Example :

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”>

<mx:Accordioncolor: rgb(153, 0, 0);”>accordion1″ height=”250″>

<mx:Formcolor: rgb(153, 0, 0);”>UserDetail” label=”UserDetail”>

<mx:FormItemcolor: rgb(153, 0, 0);”>sfirstNameItem” label=”First Name”>

<mx:TextInputcolor: rgb(153, 0, 0);”>sfirstName”/>

</mx:FormItem>

<!– Additional contents goes here. –>

</mx:Form>

<mx:Formcolor: rgb(153, 0, 0);”>submitOrder” label=”Submit Order”>

<!– Form contents goes here. –>

</mx:Form>

</mx:Accordion>

</s:Application>

[/xml]

ButtonBar

Component Type : spark.components

important points :

1. The typical use for a button bar is for grouping a set of related buttons together, which gives them a common look and navigation, and handling the logic for the change event in a single place.

2. The Spark list-based controls (the Spark ListBase class and its subclasses such as ButtonBar, ComboBox, DropDownList, List, and TabBar) do not support the BasicLayout class as the value of the layout property. Do not use BasicLayout with the Spark list-based controls.

Default characteristics:

Characteristic Description
Default size Large enough to display all buttons
Minimum size 0 pixels
Maximum size No limit
Default skin class spark.skins.spark.ButtonBarSkin

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx”>

<s:layout>

<s:VerticalLayout paddingLeft=”20″ paddingTop=”20″/>

</s:layout>

<s:ButtonBar>

<mx:ArrayCollection>

<fx:String>Name</fx:String>

<fx:String>Age</fx:String>

<fx:String>Department</fx:String>

</mx:ArrayCollection>

</s:ButtonBar>

</s:Application>

[/xml]

LinkBar

Component Type : mx.controls

important points :

1. we typically use a LinkBar control to control the active child container of a ViewStack container, or to create a stand-alone set of links.

Default characteristics:

Characteristic Description
Preferred size A width wide enough to contain all.
Control resizing rules LinkBar controls do not resize by default.
Padding 2 pixels for the top, bottom, left, and right properties.

Example ;

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx”>

<mx:LinkBar borderStyle=”solid”

itemClick=”navigateToURL(new URLRequest(‘http://www.dremsus.com/’ +

String(event.label).toLowerCase()), ‘_blank’);”>

<mx:dataProvider>

<fx:String>Name</fx:String>

<fx:String>Age</fx:String>

<fx:String>Department</fx:String>

</mx:dataProvider>

</mx:LinkBar>

</s:Application>

[/xml]

MenuBar

Component Type : mx.controls

important points :

1. Clicking on a top-level menu item opens a pop-up submenu that is an instance of the Menu control.

The MenuBar control has the following sizing characteristics:

Characteristic Description
Default size Minimum value of 27 pixels for the width. The default value for the height is 22 pixels.

Example :

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx” >

<mx:MenuBarcolor: rgb(153, 0, 0);”>myMenuBar” labelField=”@label”>

<fx:XMLList>

<menuitem label=”MenuItem A”>

<menuitem label=”SubMenuItem 1-1″ enabled=”false”/>

<menuitem label=”SubMenuItem 1-2″/>

</menuitem>

<menuitem label=”MenuItem1 “/>

<menuitem label=”MenuItem2 “/>

<menuitem label=”MenuItem3 “>

<menuitem label=”SubMenuItem 3-1″

type=”radio” groupName=”one”/>

<menuitem label=”SubMenuItem 3-2″

type=”radio” groupName=”one”

selected=”true”/>

<menuitem label=”SubMenuItem 3-3″

type=”radio” groupName=”one”/>

</menuitem>

</fx:XMLList>

</mx:MenuBar>

</s:Application>

[/xml]

TabBar

Component Type : spark.components

important points :

1. The TabBarSkin class arranges the tabs in a single row.

2. Use the TabBar cornerRadius style to configure the corner radius of the tabs.

Default characteristics:

Characteristic Description
Default size Large enough to display the tabs
Minimum size 0 pixels
Maximum size 10000 pixels X10000 pixels

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx”>

<mx:TabBar>

<mx:dataProvider>

<fx:String>item1</fx:String>

<fx:String>item2</fx:String>

<fx:String>item3</fx:String>

</mx:dataProvider>

</mx:TabBar>

</s:Application>

[/xml]

TabNavigator

Component Type : mx.containers

important points :

1. The MX TabNavigator container extends the MX ViewStack container by including a TabBar container for navigating between its child containers.

2 .Note: The direct children of an MX navigator container must be MX containers,

Default sizing characteristics:

Characteristic Description
Default size The default or explicit width and height of the first active child plus the tab.
Container resizing rules By default, TabNavigator containers are only sized once to fit the size of the first child container.
Child layout rules If the child is larger than the TabNavigator container, it is clipped. If the child is smaller than the TabNavigator container, it is aligned to the upper-left corner of the TabNavigator container.
Default padding 0 pixels for the top, bottom, left, and right values.

Example :

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”>

<mx:TabNavigator borderStyle=”solid” >

<mx:VBox label=”item1″

width=”300″

height=”150″>

</mx:VBox>

<mx:VBox label=”item2″

width=”300″

height=”150″>

</mx:VBox>

</mx:TabNavigator>

</s:Application>

[/xml]

ToggleButtonBar

Component Type : mx.controls

important points :

.

1. spark.components.ButtonBar class as an alternative to this class.

2. You can use the ButtonBar control to define a group of push buttons.

3. The typical use for a toggle button is for maintaining selection among a set of options, such as switching between views in a ViewStack container.

Default characteristics:

Characteristic Description
Preferred size Wide enough to contain all buttons
Control resizing rules The controls do not resize by default.
selectedIndex The default value is “0” and selects the leftmost button in the bar.
Padding 0 pixels for the top, bottom, left, and right properties.

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx”>

<s:Panel title=”ToggleButtonBar Control ”

width=”75%” height=”75%”

horizontalCenter=”0″ verticalCenter=”0″>

<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>

<mx:ToggleButtonBar >

<mx:dataProvider>

<fx:Array>

<fx:String>item1</fx:String>

<fx:String>item2</fx:String>

<fx:String>item3</fx:String>

</fx:Array>

</mx:dataProvider>

</mx:ToggleButtonBar>

</s:VGroup>

</s:Panel>

</s:Application>

[/xml]

ViewStack

Component Type : mx.containers

important points :

1. An MX ViewStack navigator container consists of a collection of child containers stacked on top of each other, where only one child at a time is visible.

2. The direct children of an MX navigator container must be MX containers, either MX layout or MX navigator containers, or the Spark NavigatorContent container.

Default sizing characteristics:

Characteristic Description
Default size The width and height of the initial active child.
Container resizing rules By default, ViewStack containers are sized only once to fit the size of the first child container.
Child sizing rules Children are sized to their default size.
Default padding 0 pixels for top, bottom, left, and right values.

Example :

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”>

<s:VGroup>

<mx:HBox borderStyle=”solid”>

<s:Buttoncolor: rgb(153, 0, 0);”>searchButton”

label=”Search Screen”

click=”myViewStack.selectedChild=search;”/>

<s:Buttoncolor: rgb(153, 0, 0);”>cInfoButton”

label=”Customer Info Screen”

click=”myViewStack.selectedChild=custInfo;”/>

<s:Buttoncolor: rgb(153, 0, 0);”>aInfoButton”

label=”Account Info Screen”

click=”myViewStack.selectedChild=accountInfo;”/>

</mx:HBox>

<!– Define the ViewStack and the three child containers and have it

resize up to the size of the container for the buttons. –>

<mx:ViewStackcolor: rgb(153, 0, 0);”>myViewStack”

borderStyle=”solid” width=”100%”>

<mx:Canvascolor: rgb(153, 0, 0);”>search” label=”Search”>

<mx:Label text=”Search Screen”/>

</mx:Canvas>

<mx:Canvascolor: rgb(153, 0, 0);”>custInfo” label=”Customer Info”>

<mx:Label text=”Customer Info”/>

</mx:Canvas>

<mx:Canvascolor: rgb(153, 0, 0);”>accountInfo” label=”Account Info”>

<mx:Label text=”Account Info”/>

</mx:Canvas>

</mx:ViewStack>

</s:VGroup>

</s:Application>

[/xml]

Tags: , , , , , , , , , , , , , , , , , , ,

Flash Builder 4- Controls-Part 2

January 7th, 2011 by aabhaanjan

flex_cert3

OLAPDataGrid

Component Type : spark.components

Important points :

1. Its support for the display of the results of OLAP queries.

2. differences with AdvancedDataGrid control:

  • Column dragging is not allowed in the OLAPDataGrid control.
  • You cannot edit cells in the OLAPDataGrid control because cell data is a result of a query and does not correspond to a single data value in the OLAP cube.
  • You cannot sort columns by clicking on header in the OLAPDataGrid control. Sorting is supported at the dimension level so that you can change the order of members of that dimension.

PopUpButton

Component Type : mx.control

important points :

1. It contains a main button and a secondary button, called the pop-up button, which pops up any UIComponent object when a user clicks the pop-up button.

2 It can have a text label, an icon, or both on its face.

3. One common use for the PopUpButton control is to have the pop-up button open a List control or a Menu control that changes the function and label of the main button.

Default Characteristics:

Characteristic Description
Default size Sufficient width
Minimum size 0 pixels
Maximum size Undefined

Example :

PopUpMenuButton

Component Type : mx.control

important points :

1.The PopUpMenuButton control creates a PopUpButton control with a main sub-button and a secondary sub-button.

  1. Clicking on the secondary (right) sub-button drops down a menu that can be popluated through a dataProvider property.
  2. Difference with Menu and MenuBar controls : the PopUpMenuButton control supports only a single-level menu.
  3. It cannot contain cascading submenus.

Default characteristics:

Characteristic Description
Default size Sufficient
Minimum size 0 pixels.
Maximum size 10000 by 10000.

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.MenuEvent;

public function itemClickHandler(evt:MenuEvent):void {
}
]]>
</fx:Script>
<fx:Declarations>

<fx:XMLList>
<node label=”Inbox”/>
</fx:XMLList>
</fx:Declarations>
<s:Panel title=”PopUpMenuButton ”
width=”75%” height=”75%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:Label width=”100%” color=”blue”
text=”Click the down arrow to open the menu.”/>
<mx:PopUpMenuButton
dataProvider=”{treeDP2}”
labelField=”@label”
itemClick=”itemClickHandler(event);”/>
</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

ProgressBar

Component Type : mx.control

important points :

1. There are two types of ProgressBar controls: determinate and indeterminate.

  1. A determinate ProgressBar control is a linear representation of the progress of a task over time.
  2. Used determinate ProgressBar when the scope of the task is known. It displays when the user has to wait for an extended amount of time.

4. An indeterminate ProgressBar control represents time-based processes for which the scope is not yet known.

Default characteristics:

Characteristic Description
default size 150 pixels X 4 pixels
Minimum size 0 pixels
Maximum size Undefined

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”>
<fx:Script>
<![CDATA[
private var j:uint = 0;

private function runit():void
{
if (j < 100) {
j += 10;
} else if (j >= 100) {
j = 0;
}
bar.setProgress(j, 100);
bar.label = “Current Progress: ” + j + “%”;
}
]]>
</fx:Script>
<s:Panel title=”Halo ProgressBar Control Example”
width=”75%” height=”75%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:Label width=”100%” color=”blue”
text=”Click the button to increment the progress bar.” />
<s:Button label=”Run” click=”runit();”/>
<mx:ProgressBar labelPlacement=”bottom” chromeColor=”red”
minimum=”0″ visible=”true” maximum=”100″ label=”CurrentProgress 0%”
direction=”right” mode=”manual” width=”100%”/>
</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

RadioButton

Component Type : spark.components

important points :

1. Difference with RadioButtonGroup

A RadioButtonGroup is composed of two or more RadioButton components with the same groupName property.

2

The RadioButton group can refer to the a group created by the <s:RadioButtonGroup> tag.

3. The user selects only one member of the group at a time. Selecting an unselected group member deselects the currently selected RadioButton component within that group.

Default characteristics:

Characteristic Description
Default size Wide enough
Minimum size 18 pixels X 18 pixels
Maximum size 10000 pixels X 10000 pixels
Default skin class spark.skins.spark.RadioButtonSkin

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”>
<fx:Script>
import mx.controls.Alert;
</fx:Script>
<s:Panel title=”Halo RadioButton Control Example”
width=”75%” height=”75%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:Label width=”100%” color=”blue”
text=”What year were women first allowed to compete in the Boston Marathon?”/>
<mx:RadioButton groupName=”year” label=”1942″/>
<mx:RadioButton groupName=”year” label=”1952″/>

<s:Button label=”Check Answer”
click=”Alert.show(option4.selected ? ‘Correct Answer!’:’Wrong Answer’, ‘Result’);”/>
</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

RadioButton

Component Type : spark.components

Default characteristics:

Characteristic Description
Default size Wide enough
Minimum size 18 pixels X18 pixels
Maximum size 10000 X 10000 pixels
Default skin class spark.skins.spark.RadioButtonSkin

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import  mx.events.ItemClickEvent;

private function handleItem(evt:ItemClickEvent):void {
switch (evt.currentTarget.selectedValue) {
case “one”:
Alert.show(“You selected one”);
break;
case “two”:
Alert.show(“You selected Two”);
break;

}
}
]]>
</fx:Script>
<fx:Declarations>
<mx:RadioButtonGroup itemClick=”handleItem(event);”/>
</fx:Declarations>
<s:Panel title=”Halo RadioButtonGroup ”
width=”75%” height=”75%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:Label width=”100%” color=”blue”
text=”Select a type of credit card.”/>
<mx:RadioButton groupName=”type” value=”one”
label=”oneExpress” width=”150″ />
<mx:RadioButton groupName=”type” value=”two”
label=”two” width=”150″ />

</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

RichEditableText

Component Type : spark.components

important points :

1. The rich text can contain clickable hyperlinks and inline graphics .

  1. RichEditableText does not have scrollbars,
  2. It implements the IViewport interface for programmatic scrolling .
    1. RichEditableText uses the Text Layout Framework (TLF) library.
    2. The Spark architecture provides three text “primitives” — Label, RichText, and RichEditableText.
    1. Label is the fastest and most lightweight because it uses only FTE, not TLF.

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application
xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”>
<fx:Script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
]]>
</fx:Script>
<fx:Declarations>
<fx:XML source=”externalTextFlow.xml” />
</fx:Declarations>
<s:Panel title=”RichText textFlow test”
width=”90%” height=”90%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:Scroller width=”100%” height=”100%”>
<s:VGroup paddingLeft=”20″ paddingRight=”20″ paddingTop=”20″ paddingBottom=”20″>
<s:RichEditableText textAlign=”justify” percentWidth=”100″>
<s:textFlow>
<s:TextFlow>
<s:p fontSize=”24″>Inline TextFlow</s:p>
<s:p>1) text-text </s:p>

</s:TextFlow>
</s:textFlow>
</s:RichEditableText>
<s:RichEditableText textAlign=”justify” width=”100%”
textFlow=”{TextConverter.importToFlow(extTxtFlow, TextConverter.TEXT_LAYOUT_FORMAT)}” />
</s:VGroup>
</s:Scroller>
</s:Panel>
</s:Application>

[/xml]

RichText

Component Type : spark.components

important points :

1. RichText is a low-level UIComponent that can display one or more lines of richly-formatted text and embedded images.

2 It does not support scrolling, selection, editing, clickable hyperlinks, or images loaded from URLs.

  1. RichText uses the Text Layout Framework (TLF) library
  2. Difference with Text :
  • RichText offers better typography, better support for international languages, and better text layout than Text.
  • RichText has an object-oriented model of what it displays, while Text does not.
  • Text is selectable, while RichText does not support selection.

Default MXML property: content

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″ xmlns:s=”library://ns.adobe.com/flex/spark”>
<s:Panel title=”Spark RichText ”
width=”75%” height=”75%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:Group left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:RichText x=”0″ y=”0″ width=”75″ fontFamily=”Times” fontSize=”15″ textRotation=”rotate90″>
<s:content>Hello World!</s:content>
</s:RichText>
<s:Group x=”100″ y=”0″>
<s:RichText width=”100″ textAlign=”justify” paddingTop=”5″ paddingLeft=”5″ paddingRight=”5″ paddingBottom=”5″>
<s:content>Text-text-text</s:content>
</s:RichText>
<s:Rect width=”100%” height=”100%”>
<s:stroke>
<s:SolidColorStroke color=”red”/>
</s:stroke>
</s:Rect>
</s:Group>
<s:Group x=”225″ y=”0″>
<s:RichText width=”140″ height=”120″ columnCount=”2″ columnGap=”10″>
<s:content><s:span fontWeight=”bold”>Hello World!</s:span> Text-text-text</s:content>
</s:RichText>
<s:Rect width=”100%” height=”100%”>
<s:stroke>
<s:SolidColorStroke color=”red”/>
</s:stroke>
</s:Rect>
</s:Group>
</s:Group>
</s:Panel>
</s:Application>

[/xml]

Spinner

Component Type : spark.components

important points :

  1. A Spinner component selects a value from an ordered set.
  2. It uses two buttons that increase or decrease the current value .

Default characteristics:

Characteristic Description
Default size 19 pixels X 23 pixels
Minimum size 12 pixels X 12 pixels
Maximum size 10000 pixels X 10000 pixels
Default skin class spark.skins.spark.SpinnerSkin

Example :

[xml]

<?xml version=’1.0′ encoding=’UTF-8′?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″ xmlns:s=”library://ns.adobe.com/flex/spark” xmlns:mx=”library://ns.adobe.com/flex/mx”>

<mx:Panel title=”Spinner Control ” height=”75%” width=”75%” paddingTop=”10″
paddingLeft=”10″ horizontalCenter=”0″ verticalCenter=”0″>
<s:Group>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<mx:Text text=”Use the arrows to change tabs”/>
<s:Spinner maximum=”3″/>
</s:Group>

<mx:TabNavigator width=”75%” height=”75%” selectedIndex=”@{mySpinner.value}” >
<mx:HBox label=”Tab 1″>
<mx:Text text=”Text on Tab 1″ fontSize=”14″ color=”red”/>
</mx:HBox>
<mx:HBox label=”Tab 2″>
<mx:Text text=”Text on Tab 2″ fontSize=”16″ color=”blue”/>
</mx:HBox>

</mx:TabNavigator>

<mx:Label color=”purple” text=”Current Tab = {mySpinner.value+1}”/>
</mx:Panel>
</s:Application>

[/xml]

SWFLoader

Component Type : mx.controls

important points :

  1. The SWFLoader control loads and displays a specified SWF file.
  2. It is used for loading one Flex application into a host Flex application.

3. we can use the SWFLoader control to load a GIF, JPEG, or PNG image file at runtime, to load a ByteArray representing a SWF, GIF, JPEG, or PNG image at runtime, or load an embedded version of any of these file types, and SVG files, at compile time by using @Embed(source=’filename’).

4. The SWFLoader control lets you scale its content and set its size.

5. A SWFLoader control cannot receive focus. However, the contents of a SWFLoader control can accept focus and have its own focus interactions.

Default characteristics:

Characteristic Description
Default size enough for the loaded content
Minimum size 0 pixels
Maximum size Undefined

Example :

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”>
<s:VGroup>
<mx:SWFLoader source=”FlexApp.swf”/>
</s:VGroup>
</s:Application>

[/xml]

TextArea

Component Type : spark.components

important points :

1. The Spark version of TextArea uses the Text Layout Framework (TLF) library,

  • Spark TextArea offers better typography, better support for international languages, and better text layout.
  • Spark TextArea has an object-oriented model of rich text, while the MX version does not.
  • Spark TextArea has better support for displaying large amounts of text.
  • Spark TextArea requires that fonts be embedded differently than the MX version. To learn how to use the embedAsCFF attribute when you embed a font, see the font documentation.

The Spark TextArea control uses the TLF object-oriented model of rich text.

Default characteristics:

Characteristic Description
Default size 188 pixels X149 pixels
Minimum size 36 pixels X 36 pixels
Maximum size 10000 pixels X 10000 pixels
Default skin class spark.skins.spark.TextAreaSkin

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”>
<s:layout>
<s:BasicLayout />
</s:layout>
<s:Panel title=”Spark TextArea Control ”
horizontalCenter=”0″
verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:TextArea width=”400″ height=”100″>
<s:text>Text-Text-Text.</s:text>
</s:TextArea>

</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

TextInput

Component Type : spark.components

important points :

1. This Spark version of TextInput makes use of the Text Layout Framework (TLF) library.

2.The widthInChars property provides a convenient way to specify the width in a way that scales with the font size.

  1. This control dispatches a FlexEvent.ENTER event when the user pressed the Enter key .
  2. rather than inserting a line break, because this control does not support entering multiple lines of text.
  3. By default, this control has explicit line breaks.

6. As a result of RichEditableText using TLF, the Spark TextInput control supports displaying left-to-right (LTR) text.

Default characteristics:

Characteristic Description
Default size 128 pixels X 22 pixels
Maximum size 10000 pixels X 10000 pixels
Default skin class spark.skins.spark.TextInputSkin

Example :

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″ xmlns:s=”library://ns.adobe.com/flex/spark”>
<s:layout>
<s:BasicLayout />
</s:layout>
<s:Panel title=”Spark TextInput Control ”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:TextInput text=”Hello World!” />
<s:Button label=”Copy Text” click=”dest.text = src.text” />
<s:TextInput />
</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

ToggleButton

Component Type : spark.components

Default characteristics:

Characteristic Description
Default size Wide enough
Minimum size 21 pixels X 21 pixels
Maximum size 10000 pixels X 10000 pixels
Default skin class spark.skins.spark.ToggleButtonSkin

Example :

[xml]

<?xml version=”1.0″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″ xmlns:s=”library://ns.adobe.com/flex/spark” xmlns:mx=”library://ns.adobe.com/flex/mx”>
<fx:Script>
<![CDATA[

private function printMessage(evt:Event):void  {
if (evt.target.selected){
message.text += “fontWeight: bold” + “\n”;
lbl.setStyle(“fontWeight”, “bold”);
togBtn.label = “Bold”;
} else{
message.text += “fontWeight: normal” + “\n”;
lbl.setStyle(“fontWeight”, “normal”);
togBtn.label = “Normal”;
}
}
]]>
</fx:Script>
<s:Panel title=”Spark ToggleButton Control ”
width=”75%” height=”75%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:ToggleButton label=”Normal” click=”printMessage(event);” />
<s:Label text=”Label” />
<s:TextArea height=”100%” width=”100%” color=”#0000FF” />
</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

Tree

Component Type : mx.controls

important points :

1 The Tree class uses an ITreeDataDescriptor or ITreeDataDescriptor2 object to parse and manipulate the data provider.

2. The default tree data descriptor, an object of the DefaultDataDescriptor class, supports XML and Object classes; an Object class data provider must have all children in children fields.

Default sizing characteristics:

Characteristic Description
Default size Wide enough to accommodate the icon, label, and expansion triangle, if any, of the widest node in the first 7 displayed (uncollapsed) rows, and seven rows high, where each row is 20 pixels in height. If a scroll bar is required, the width of the scroll bar is not included in the width calculations.
Minimum size 0 pixels.
Maximum size 5000 by 5000.

Example :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”>
<fx:Script>
<![CDATA[
[Bindable]
public var selectedNode:XML;

public function treeChanged(evt:Event):void {
selectedNode = Tree(evt.target).selectedItem as XML;
}
]]>
</fx:Script>
<fx:Declarations>
<fx:XMLList>
<node label=”Mail Box”>
<node label=”Inbox”>
<node label=”XYZ”/>

</node>

</node>
</fx:XMLList>
</fx:Declarations>
<s:Panel title=”Halo Tree Control Example”
width=”75%” height=”75%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:Label width=”100%” color=”blue”
text=”Select a node in the Tree control.”/>
<mx:HDividedBox width=”100%” height=”100%”>
<mx:Tree width=”50%” height=”100%” labelField=”@label”
showRoot=”false” dataProvider=”{treeData}” change=”treeChanged(event);”/>
<s:TextArea height=”100%” width=”50%”
text=”Selected Item: {selectedNode.@label}”/>
</mx:HDividedBox>
</s:VGroup>
</s:Panel>
</s:Application>

[/xml]

VideoDisplay

Component Type : spark.components

important points :

1. The VideoDisplay class is chromeless video player that supports progressive download, multi-bitrate, and streaming video.

  1. It does not support skinning.

Default characteristics:

Characteristic Description
Default size 0 pixels wide by 0 pixels high with no content, and the width and height of the video with content
Minimum size 0
Maximum size 10000 pixels X 10000 pixels

VideoPlayer

Component Type : spark.components

important points :

  1. The VideoPlayer control is a skinnable video player that supports progressive download, multi-bitrate streaming, and streaming video.
  2. It supports playback of FLV and F4v files. The VideoPlayer control contains a full-featured UI for controlling video playback..

Default characteristics:

Characteristic Description
Default size 263 pixels X 184 pixels
Minimum size 0
Maximum size 10000 pixels X 10000 pixels high
Default skin class spark.skins.spark.VideoPlayerSkin

VScrollBar

Component Type : spark.components

important points :

1. we can use the VScrollBar control as a stand-alone control, we usually combine it as part of another group of components to provide scrolling functionality.

Default characteristics:

Characteristic Description
Default size 15 pixels X 85 pixels
Minimum size 15 pixels X 15 pixels
Maximum size 10000 pixels X 10000 pixels
Default skin classes spark.skins.spark.VScrollBarSkin

spark.skins.spark.VScrollBarThumbSkin

spark.skins.spark.VScrollBarTrackSkin

VSlider

Component Type : spark.components

important points :

1. The slider can allow a continuous range of values between its minimum and maximum values

Default characteristics:

Characteristic Description
Default size 11 pixels X 100 pixels
Minimum size 11 pixels X 11 pixels
Maximum size 10000 pixels X 10000 pixels high
Default skin classes spark.skins.spark.VSliderSkin

spark.skins.spark.VSliderThumbSkin

spark.skins.spark.VSliderTrackSkin

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,