CustomEvent Class
=================
package com
{
import flash.events.Event;
public class MyButtonEvent extends Event
{
public static const MY_EVENT:String = "myevent";
public var myBtnId:String;
// create static cosnst for evetn name
// and add public property to store button id
// and finally override the clone method
public function MyButtonEvent(type:String, myBtnId:String)
{
super(type);
this.myBtnId = myBtnId;
}
override public function clone():Event {
return new MyButtonEvent(type, myBtnId);
}
}
}
Component
===============
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="166" height="80">
<mx:Metadata>
[Event(name="myevent",type="com.MyButtonEvent")]
</mx:Metadata>
<mx:Script>
<![CDATA[
private function clickHandler(e:MouseEvent):void
{
var objEve:MyButtonEvent = new MyButtonEvent("myevent",e.currentTarget.id)
dispatchEvent(objEve);
}
]]>
</mx:Script>
<mx:Button id="btn" x="47.5" y="30" label="Click Me" click="clickHandler(event)"/>
</mx:Canvas>
And the Application
=================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:com="com.*">
<mx:Script>
<![CDATA[
import com.MyButtonEvent;
import mx.controls.Alert;
private function myeventHandler(e:MyButtonEvent):void
{
Alert.show(e.myBtnId)
}
]]>
</mx:Script>
<com:MyComp myevent="myeventHandler(event)" x="373" y="61"/>
</mx:Application>
Showing posts with label AIR. Show all posts
Showing posts with label AIR. Show all posts
Tuesday, April 28, 2009
Custom Events in Flex Part II
In the following example the component is loosely coupled with the Application. The communication (and data transfer) happening through the custom events.
Wednesday, April 22, 2009
DataGrid Itemrenderer Issues
After fighting with ItemRenderers in Flex ListBased Controls, I have finally figured out how they really work.
Issues:
1. When you scorll a datagrid it duplicates the itemrenderer's value. This is because datagrid create itemrenderer instances for visible rows only and it reuses these renderers for other rows when u scroll.
2. When you change the dataprovider same problem occurs. This is again because of reuse of itemrenderers.
Solution for first issue is just add an extra container like canvas and put your datagrid into it. Now set the datagrids height, so that no scroll will come
(datagrid.height = dataprovider.lenght * rowheight)
You will get the scroll on parent container.
Solution for second issue: Just reassign your itemRenderer everytime you change the dataprovider.
datagridcolumid.itemRenderer = new ClassFactory(itemRenderer)
datagrid.dataprovider = dataprovider_new
Issues:
1. When you scorll a datagrid it duplicates the itemrenderer's value. This is because datagrid create itemrenderer instances for visible rows only and it reuses these renderers for other rows when u scroll.
2. When you change the dataprovider same problem occurs. This is again because of reuse of itemrenderers.
Solution for first issue is just add an extra container like canvas and put your datagrid into it. Now set the datagrids height, so that no scroll will come
(datagrid.height = dataprovider.lenght * rowheight)
You will get the scroll on parent container.
Solution for second issue: Just reassign your itemRenderer everytime you change the dataprovider.
datagridcolumid.itemRenderer = new ClassFactory(itemRenderer)
datagrid.dataprovider = dataprovider_new
Labels:
AIR,
Datagrid,
Flex 3,
ItemRenderer Issue,
ItemRenderer Problem
Wednesday, April 15, 2009
Text Layout Framework in Flex 3
* Bidirectional text, vertical text and over 30 languages, like arabic, chinese, devnagari etc............
* Selection, editing and flowing text across multiple columns and linked containers, and around inline images
* Vertical text, Tate-Chu-Yoko (horizontal within vertical text) and justifier for East Asian typography
* Rich typographical controls, including kerning, ligatures, typographic case, digit case, digit width and discretionary hyphens
* Cut, copy, paste, undo and standard keyboard and mouse gestures for editing
* Rich developer APIs to manipulate text content, layout, markup and create custom text components.
To use TLF you need to install Adobe AIR 1.5 or Flex 3.2
More Links:
http://corlan.org/2009/01/19/how-to-use-text-layout-framework-in-flex-32-or-air-15/
* Selection, editing and flowing text across multiple columns and linked containers, and around inline images
* Vertical text, Tate-Chu-Yoko (horizontal within vertical text) and justifier for East Asian typography
* Rich typographical controls, including kerning, ligatures, typographic case, digit case, digit width and discretionary hyphens
* Cut, copy, paste, undo and standard keyboard and mouse gestures for editing
* Rich developer APIs to manipulate text content, layout, markup and create custom text components.
To use TLF you need to install Adobe AIR 1.5 or Flex 3.2
More Links:
http://corlan.org/2009/01/19/how-to-use-text-layout-framework-in-flex-32-or-air-15/
Labels:
AIR,
Devnagri,
Flex 3,
Hindi,
Inline Images,
Rahimoddin,
Tekno Point,
Text Layout Framework,
TLF,
Vertical Text
Subscribe to:
Posts (Atom)

