Tuesday, September 4, 2007

Road To Flex-3

  • To control focus in a form use FocusManager class.
  • <mx:CheckBox> is a regular ui component. selected property determines if checked.
  • <mx:Script> tag to write AS. functions defined can be called by name in control actions (like click for Button). Script written as is between <![CDATA[]]>
  • To display an image we use an Image control. ID property can be used by actionscript to reference the Image class. Scale content property if set to true scales image to container size. Embed directive embeds the image into the swf. eg: source="@Embed('assets/myPic.jpg')". mouseOver/ mouseOut property can be used to change current state.
  • Label control allows you to display a single line of text
  • Text control allows you to display multiple lines of text
  • <mx:Spacer> tag to add space between two controls. Specify width.
  • <mx:DateField> for date based input
  • All radio buttons must belong to a group. data property helps determine which btn selected in a group.
Questions:
  1. Name some common UI controls in flex.
  2. What can you do to control focus in a form?
  3. How can you ensure that a checkbox componenet is selected on creation?
  4. How can you write an actionscript in an MXML?
  5. How can you prevent an image in an image component from scaling?
  6. What effect will an Embed command have on an Image component?
  7. Which component will you use for a date-based input?
Sample MXML:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

private var categories:ArrayCollection = new ArrayCollection();

private function myFunction():void{
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:LinkButton label="Default State" click="this.currentState=''"/>
<mx:LinkButton label="Change State" click="this.currentState='state1'"/>
<mx:Spacer width="100%"/>
<mx:Label text="Date Field"/>
<mx:DateField id="myDate"/>
<mx:RadioButtonGroup id="radioGrp"/>
<mx:RadioButton id="r1"
groupName="radioGrp"
label="Option 1"
data="1"
selected="true"/>
<mx:RadioButton id="r2"
groupName="radioGrp"
label="Option 2"
data="2"/>
</mx:ApplicationControlBar>
<mx:states>
<mx:State name="state1">
<mx:SetProperty target="{mainPanel}" name="width" value="0"/>
<mx:SetProperty target="{mainPanel}" name="height" value="0"/>
</mx:State>
</mx:states>
<mx:Panel id="mainPanel" title="My Panel" height="100%" width="100%">
</mx:Panel>
</mx:Application>

No comments: