Dragging Datas From List To Datagrid

•June 18, 2009 • Leave a Comment

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
creationComplete=”initApp();”>
<mx:Script>
<![CDATA[
import mx.events.DragEvent;
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.collections.IList;
import mx.collections.ArrayCollection;
private function initApp():void {
srcList.dataProvider = new ArrayCollection([
{label:"First", data:"1"},
{label:"Second", data:"2"},
{label:"Third", data:"3"},
{label:"Fourth", data:"4"},
]);

destDG.dataProvider = new ArrayCollection([]);
}

private function dragDropHandler(event:DragEvent):void {
if (event.dragSource.hasFormat(“items”))
{
// Explicitly handle the dragDrop event.
event.preventDefault();

// Since you are explicitly handling the dragDrop event,
// call hideDropFeedback(event) to have the drop target
// hide the drop indicator.
// The drop indicator is created
// automatically for the list controls by the built-in
// event handler for the dragOver event.
event.currentTarget.hideDropFeedback(event);

// Get drop target.
var dropTarget:DataGrid =
DataGrid(event.currentTarget);

var itemsArray:Array =
event.dragSource.dataForFormat(‘items’) as Array;
var tempItem:Object =
{ label: itemsArray[0].label,
data: itemsArray[0].data,
date: new Date()
};

// Get the drop location in the destination.
var dropLoc:int = dropTarget.calculateDropIndex(event);

IList(dropTarget.dataProvider).addItemAt(tempItem, dropLoc);
}
}
]]>
</mx:Script>

<mx:HBox>
<mx:List  id=”srcList”
dragEnabled=”true”
dragMoveEnabled=”true”/>

<mx:DataGrid  id=”destDG”
dropEnabled=”true”
dragDrop=”dragDropHandler(event);”>
<mx:columns>
<mx:DataGridColumn dataField=”label”/>
<mx:DataGridColumn dataField=”data”/>
<mx:DataGridColumn dataField=”date”/>
</mx:columns>
</mx:DataGrid>
</mx:HBox>

<mx:Button id=”b1″
label=”Reset”
click=”initApp()”
/>

</mx:Application>

Dragging datas Within The List

•June 18, 2009 • Leave a Comment

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”
creationComplete=”init();”>
<mx:Script>
<![CDATA[
import mx.events.DragEvent;
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.collections.IList;
import mx.collections.ArrayCollection;

private function init():void{
firstList.dataProvider= new ArrayCollection([
{label:"Devi", data:"one"},
{label:"Suganya", data:"two"},
{label:"Priya", data:"three"},
{label:"Amutha", data:"four"},
]);
secondList.dataProvider = new ArrayCollection([]);
}
private function dragDropHandler(event:DragEvent):void {
if (event.dragSource.hasFormat(“items”))
{

event.preventDefault();

event.currentTarget.hideDropFeedback(event);

var dropTarget:List=List(event.currentTarget);

var itemsArray:Array =
event.dragSource.dataForFormat(“items”) as Array;
var tempItem:Object =
{label: itemsArray[0].label, data: itemsArray[0].data};

var dropLoc:int = dropTarget.calculateDropIndex(event);

IList(dropTarget.dataProvider).addItemAt(tempItem, dropLoc);
}
}
]]>
</mx:Script>
<mx:HBox>
<mx:List  id=”firstList”
dragEnabled=”true”/>
<mx:List  id=”secondList”
dropEnabled=”true”
dragDrop=”dragDropHandler(event);”/>
</mx:HBox>
<mx:Button id=”b1″
label=”Reset”
click=”init()”
x=”174″ y=”161″/>
</mx:Application>

Images In TitleWindow using events

•June 18, 2009 • Leave a Comment

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application
xmlns:mx=”http://www.adobe.com/2006/mxml”
layout=”absolute”
width=”100%” height=”100%”
creationComplete=”init()”
horizontalScrollPolicy=”off”
verticalScrollPolicy=”off”>
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.*;
import flash.events.Event;
[Bindable]
public var a:int;
[Bindable]
private var im:Array=["../hi/i1.jpg","../hi/i2.jpg","../hi/i3.jpg","../hi/i4.jpg","../hi/jenny_s_rose.jpg"];

private var addNoteScreen:AddNote;

private function init():void
{
addNoteScreen = new AddNote();
}
private function addNote(event:Event):void
{
//var obj:Object=new Object;
PopUpManager.addPopUp(addNoteScreen, this, true);
PopUpManager.centerPopUp(addNoteScreen);
var obj:Object=event.currentTarget.instanceIndex;
a= int(obj);
addNoteScreen.i2.source=im[a];
}
]]>
</mx:Script>
<mx:Panel id=”p2″ layout=”absolute” width=”100%” height=”100%” visible=”true” x=”0″ y=”0″>
<mx:HBox>
<mx:Repeater id=”r1″ dataProvider=”{im}”>
<mx:Image id=”i1″ source=”{r1.currentItem}”  width=”245″ height=”150″
buttonMode=”true” maintainAspectRatio=”false”
click=”addNote(event)” x=”10″ y=”74″/>
</mx:Repeater>
</mx:HBox>
</mx:Panel>
</mx:Application>

——————————-

component:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:TitleWindow xmlns:mx=”http://www.adobe.com/2006/mxml”
layout=”absolute” width=”245″ height=”150″
showCloseButton=”true” close=”close()”>

<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;

private function close():void
{
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:Image id=”i2″ width=”100%” height=”100%”
maintainAspectRatio=”false”/>
</mx:TitleWindow>

Advanced Datagrid

•June 18, 2009 • Leave a Comment

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”vertical” verticalAlign=”top”
horizontalAlign=”center” backgroundGradientColors=”[0x000000,0x323232]” paddingTop=”0″ viewSourceURL=”srcview/index.html”>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
private var dpFlat:ArrayCollection = new ArrayCollection([
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},
{Region:"Southwest", Territory:"Central California",
Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},
{Region:"Southwest", Territory:"Nevada",
Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},
{Region:"Southwest", Territory:"Northern California",
Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
{Region:"Southwest", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},
{Region:"Southwest", Territory:"Southern California",
Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
{Region:"Southwest", Territory:"Southern California",
Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},
{Region:"NorthEast", Territory:"New York",
Territory_Rep:"Jose Rodriguez", Actual:26992, Estimate:30000},
{Region:"NorthEast", Territory:"New York",
Territory_Rep:"lisa Sims", Actual:47885, Estimate:50000},
{Region:"NorthEast", Territory:"Massachusetts",
Territory_Rep:"kelly o'connell", Actual:172911, Estimate:20000},
{Region:"NorthEast", Territory:"Pennsylvania",
Territory_Rep:"John Barnes", Actual:32105, Estimate:30000},
{Region:"MidWest", Territory:"Illinois",
Territory_Rep:"Seth Brown", Actual:42511, Estimate:40000}
]);
]]>
</mx:Script>
<mx:Panel title=”AdvancedDataGrid Control” layout=”vertical” color=”0xffffff” borderAlpha=”0.15″ width=”500″
paddingTop=”5″ paddingRight=”10″ paddingBottom=”10″ paddingLeft=”10″ horizontalAlign=”center”>
<mx:AdvancedDataGrid id=”myADG” width=”100%” height=”100%” color=”0×323232″ initialize=”gc.refresh();”>
<mx:dataProvider>
<mx:GroupingCollection id=”gc” source=”{dpFlat}”>
<mx:grouping>
<mx:Grouping>
<mx:GroupingField name=”Region”/>
<mx:GroupingField name=”Territory”/>
</mx:Grouping>
</mx:grouping>
</mx:GroupingCollection>
</mx:dataProvider>

<mx:columns>
<mx:AdvancedDataGridColumn dataField=”Region”/>
<mx:AdvancedDataGridColumn dataField=”Territory”/>
<mx:AdvancedDataGridColumn dataField=”Territory_Rep”
headerText=”Territory Rep”/>
<mx:AdvancedDataGridColumn dataField=”Actual”/>
<mx:AdvancedDataGridColumn dataField=”Estimate”/>
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Panel>
</mx:Application>

Flex Technical Questions:

•June 18, 2009 • Leave a Comment

Is it possible to make httpService Requests synchronous?
I need to load an image from flickr into my application. Do I need a crossdomain.xml file on flickr?
What is the difference between httpService and Data Service?
How do you generate random numbers within a given limit with actionscript?
Have you built any components with actionscript? If so explain how you did it?
How do you implement push on a flex applications?
I am going to add images into a tag. How will it resize itself?
What is a resource Manager?
What are the similarities between java and flex
What is the dynamic keyword used for?
How do you implement push with flex data services?
What are the methods called when a UI component is intialized?
How do you implement drag and drop on components that do not support ondrag and ondrop?
Can you write to the file system from flex?
What is a drag manager?
How do you call javascript from Flex?
How do you use a repeater?
What are three ways to skin a component in flex?
How do you use css styles in flex?
What is the difference between sealed class and dynamic classes?
What is MVC and how do you relate it to flex apps?
What is state? what is the difference between states and ViewStack?
How does item renderer work? How do I add item renderer at runtime?
What keyword allows you to refer to private variables of a class?
How polymorphism works on actionscript?
How do you overload functions in action script?
What is dynamic keyword used for?
What are sealed classes ?
What are runtime shared libraries?
What is caringhorm ? how do you use it? Have you worked with Cairnghorn?
What keyword allows you to implement abstraction better?
What design patterns have you used? in Actionscript and java?
What’s the difference between Java and AS3 getters and setters?
Explain how binding works in mxml components.
What’s the difference between ChangeWatcher.watch, and BindingUtils.bindProperty?
Why would you want to keep a reference to a ChangeWatcher and call unwatch()?
How do you add event listeners in mxml components. Now AS3 components?
What does calling preventDefault() on an event do? How is this enforced?
Explain the lifecycle of a Cairngorm action.
What is the problem with calling setStyle()
Explain the difference between creating an effect and setting the target as opposed to adding an effectListener
How do you identify a component created in a repeater?

????????

•June 18, 2009 • Leave a Comment

What is Flex? Adobe Flex?
What kind of applications you can create from Flex?
What is the output of Flex applications?
What development environment you need to create Flex applications?
Can you manipulate images using Flex programs?
Does Flex support creating workflow based applications?
What kind of data grids you can create through Flex applications?
How do you connect to a database via a Flex program?
What kind of source code integration tools are available with Flex?
What third party development tools are available to program in Flex?
Can you develop web based applications in Flex?
Is Flex OS specific or operating system independent?
Can we run Flex applications in MAC?
Do we need any plugins to run Flex applications?

RichTextEditor

•June 18, 2009 • Leave a Comment

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function showMsg(msg:String):void{
mx.controls.Alert.show(msg);
}
]]>
</mx:Script>
<mx:Panel title=”Profile” height=”400″ width=”400″>
<mx:Label text=”Enter your namr” fontWeight=”bold”/>
<mx:TextInput id=”yourName” width=”250″ valueCommit=”showMsg(yourName.text)”/>
<mx:Text text=”ProfileSummary”/>
<mx:TextInput id=”aboutYou” textAlign=”center” width=”250″ valueCommit=”showMsg(yourName.text)”/>
<mx:Label text=”Enter your profile” fontWeight=”bold” color=”#ff0000″/>
<mx:RichTextEditor id=”rte” height=”150″ />
</mx:Panel>
</mx:Application>

Datagrid using Events

•June 18, 2009 • Leave a Comment

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”add()” backgroundImage=”darkaurora.jpg”>
<mx:XML id=”cusapp” source=”cusxml.xml”/>
<mx:Script source=”XMLINAS1.as”/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.events.MouseEvent;
import mx.events.ListEvent;

protected function functionName(event:ListEvent):void
{
ta1.visible=true;
ta1.text="";
var selectedRow:Object = event.currentTarget.selectedItem;
ta1.text+=selectedRow.cno+"\n";
ta1.text+=selectedRow.cname+"\n";
ta1.text+=selectedRow.plist+"\n";
ta1.text+=selectedRow.wlistt+"\n";
ta1.text+=selectedRow.lsales+"\n";
ta1.text+=selectedRow.rorder+"\n";
ta1.text+=selectedRow.ship;
}
public function detail():void{
}
public function dataadd():void
{

dg2.dataProvider=arrc;

}
public function doZoom(event:MouseEvent):void {
if (zoomAll.isPlaying) {

}
else {

zoomAll.play([event.target], event.type == MouseEvent.ROLL_OUT ? true : false);
}
}
]]>
</mx:Script>
<mx:Style>
.mybuttonBarLastButtonStyle {
highlightAlphas: 0.2, 0.4;
fillAlphas: .4, .4, 1, 1;
fillColors: #000000, #000000, #000000, #000000;
color: #cccccc;
textRollOverColor: #ffffff;
themeColor: #333333;
borderColor: #333333;
fontSize: 12;
cornerRadius: 4;
}

</mx:Style>
<mx:Zoom id=”zoomAll” zoomWidthTo=”1″ zoomHeightTo=”1″ zoomWidthFrom=”.5″ zoomHeightFrom=”.5″  />
<mx:DataGrid doubleClickEnabled=”true” rollOver=”doZoom(event)” width=”919″ id=”dg2″ sortableColumns=”true” x=”10″ y=”62″ height=”176″ itemDoubleClick=”functionName(event);”>
<mx:columns>
<mx:DataGridColumn dataField=”cno” headerText=”Customer No” textAlign=”center” fontFamily=”TimesNewRoman” fontSize=”18″/>
<mx:DataGridColumn dataField=”cname” headerText=”Customer Name” textAlign=”center” fontFamily=”TimesNewRoman” fontSize=”18″/>
<mx:DataGridColumn dataField=”plist” headerText=”Purchase List” textAlign=”center” fontFamily=”TimesNewRoman” fontSize=”18″/>
<mx:DataGridColumn dataField=”wlist” headerText=”WishList” textAlign=”center” fontFamily=”TimesNewRoman” fontSize=”18″/>
<mx:DataGridColumn dataField=”lsales” headerText=”Last Sales” textAlign=”center” fontFamily=”TimesNewRoman” fontSize=”18″/>
<mx:DataGridColumn dataField=”rorder” headerText=”Recent Order” textAlign=”center” fontFamily=”TimesNewRoman” fontSize=”18″/>
<mx:DataGridColumn dataField=”ship” headerText=”Shipping” textAlign=”center” fontFamily=”TimesNewRoman” fontSize=”18″/>
</mx:columns>
</mx:DataGrid>
<mx:Button  styleName=”mybuttonBarLastButtonStyle” id=”b1″ label=”Click To Load Details” click=”dataadd();detail()” fontSize=”20″ cornerRadius=”5″ fontStyle=”italic”/>
<mx:TextArea x=”10″ y=”246″ width=”123″ id=”ta1″ height=”153″ fontStyle=”italic” fontFamily=”TimesNewRoman” fontSize=”15″ backgroundColor=”0xccff99″ fontThickness=”15″ visible=”false”/>
</mx:Application>

————————–

// ActionScript file
import mx.collections.ArrayCollection;
public var ASXML:XML=new XML();
public var arrc:ArrayCollection;
public function add():void
{
ASXML=cusapp;
fetch1();
}
public function fetch1():void
{
arrc=new ArrayCollection();
for(var i:uint=0; i<ASXML.customer.length();i++)
{
arrc.addItem({cno:ASXML.customer.cno[i],cname:ASXML.customer.cname[i],plist:ASXML.customer.plist[i],wlist:ASXML.customer.wlist[i],lsales:ASXML.customer.lsales[i],rorder:ASXML.customer.rorder[i],ship:ASXML.customer.ship[i]});
}
}

———–

XML file:

<root>
<customer>
<cno>1</cno>
<cname>Alex</cname>
<plist>Fertilizer</plist>
<wlist>Green Rose seeds</wlist>
<lsales>Fertilizer</lsales>
<rorder>Fertilizer</rorder>
<ship>Sipped</ship>
</customer>
<customer>
<cno>2</cno>
<cname>Babu</cname>
<plist>Cutter</plist>
<wlist>Lily seeds</wlist>
<lsales>Cutter</lsales>
<rorder>Cutter</rorder>
<ship>unshipped</ship>
</customer>
<customer>
<cno>3</cno>
<cname>Saravanan</cname>
<plist>Mud</plist>
<wlist>Hybrid seeds</wlist>
<lsales>Hybrid seeds</lsales>
<rorder>Hybrid seeds</rorder>
<ship>shipped</ship>
</customer><customer>
<cno>4</cno>
<cname>Kumar</cname>
<plist>Pot</plist>
<wlist>Daffodils</wlist>
<lsales>Pot</lsales>
<rorder>Pot</rorder>
<ship>Shipped</ship>
</customer>
</root>

Creating Title Window

•June 18, 2009 • Leave a Comment

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>

<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
private function showtitle():void
{
var helpWindow:IFlexDisplayObject =
PopUpManager.createPopUp(this,titlewin, false);
}
]]>
</mx:Script>
<mx:Button id=”btn” label=”Show Title Window” click=”showtitle()” >
</mx:Button>
</mx:Application>

—————————–

Creating Title Window as a component:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:TitleWindow xmlns:mx=”http://www.adobe.com/2006/mxml”
layout=”absolute”
close=”removeForm()” showCloseButton=”true”
width=”400″ height=”300″>
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
private function removeForm():void
{
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>

<mx:Label text=”Name” x=”66″ y=”65″ width=”57″/>
<mx:Label text=”Password” x=”66″ y=”118″/>
<mx:Button id=”closebtn” label=”CLOSE” click=”{removeForm()}”  x=”121″ y=”176″/>
<mx:TextInput x=”148″ y=”63″/>
<mx:TextInput x=”148″ y=”115″/>
</mx:TitleWindow>

ADOBE FLEX BUILDER 3

•June 18, 2009 • Leave a Comment

Adobe Flex Builder 3 accelerates Flex application development.

It is an Eclipse based development tool enabling intelligent coding, interactive step-through debugging, and visual design of the user interface layout, appearance, and behavior of RIAs.

Flex Builder 3 includes the complete Flex framework, including compilers, a component library, and debuggers.

Flex Builder 3 is available in Standard and Professional editions. Both editions allow import of assets from Adobe Creative Suite® 3 software, making it easy for designers and developers to work together.

Flex Builder 3 Professional further adds powerful data visualization capabilities, the new Advanced Datagrid, memory and performance profilers, and support for automated functional testing for developing business-critical applications.

 
Follow

Get every new post delivered to your Inbox.