Monday, November 16, 2009

image enable

In flex, enable property doesn't work for image and radio button etc..here is the sample code for enable and disable the image events....
in the below code the image automatically disabled due to application complete...
once u click the button the image enabled and the event also occur....

code:
?xml version="1.0" encoding="utf-8"?>
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="disableImages();">
mx:Script>
![CDATA[
import mx.controls.Alert;

private function disableImages():void{

//remove the click listener from image
myImg.alpha=0.2;
myImg.removeEventListener(MouseEvent.CLICK, btnClickHandle);
}
private function enableImages():void{

//remove the click listener from image
myImg.alpha=1;
myImg.addEventListener(MouseEvent.CLICK,btnClickHandle);
}

public function btnClickHandle(e:MouseEvent):void
{
Alert.show("enable");

}
]]>
/mx:Script>
mx:Image source="oscar_dresses.jpg" id="myImg"/>
mx:Button label="click" click="enableImages();"/>
/mx:Application>

Sunday, November 15, 2009

Objecthandler in flex 3

hi,
Object handler is the best way for image handling..inside that you can rotate,resize and flipping the image without any problem..here i  am writing simple code  for object handle using flex 3.i hope it  will help for  somebody...
Below example , i did vertical flip, rotation and resizing the image using object handles ...
and u can write function for resizing or used resize handle..
code:
?xml version="1.0" encoding="utf-8"?>
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:oh="com.roguedevelopment.objecthandles.*">

protected var resize_handle:Class;
 [Embed(source="rotate_handle.png")]
protected var rotate_handle:Class;
public function flip(evt:MouseEvent):void
{
var skewMatrix:Matrix =evt.currentTarget.transform.matrix;
if(skewMatrix.a==1)
{
skewMatrix.a=-1;
 skewMatrix.tx=evt.currentTarget.x+evt.currentTarget.width;
 evt.currentTarget.transform.matrix = skewMatrix;
}
 else{
skewMatrix.a=1;
 skewMatrix.tx=evt.currentTarget.x-evt.currentTarget.width;
 evt.currentTarget.transform.matrix = skewMatrix;
}   } ]]>/mx:Script

mx:Canvas id="genericExamples" label="Generic" backgroundColor="0xffffff" backgroundAlpha="1" width="100%" height="100%" >
 oh:ObjectHandles horizontalScrollPolicy="off" verticalScrollPolicy="off" id="oh12" allowRotate="true" resizeHandleImage="{resize_handle}"  rotateHandleImage="{rotate_handle}"  x="10" y="20" width="240" height="130" minHeight="30" minWidth="100" click="flip(event);" >
mx:Image source="oscar_dresses.jpg" width="100%" height="100%"  x="10"/>  /mx:Canvas>/mx:Application>

reference:http://www.rogue-development.com/objectHandles.html.

Thursday, November 12, 2009

Create dynamic repeater in as3

here i m writing code for create dynamic repeater in as3...
in my code i try to show the images in vbox through the repeater...
in mxml application we directly give data provider and source to the image.. but in as ae should use loop for increment the data provider, otherwise we get first record of the repeater, it wont repeat the all the records....

here is my code, hope this will help to someone

cat.img is my xml

box_v=new VBox();
box_v.height=300;
addChild(box_v);
rep=new Repeater();
rep.setStyle("verticalCenter","0");
rep.setStyle("horizontalCenter","0");
var Y:int=25;
for(var i:int=0;i
{
rep.dataProvider=cat.img[i];
babyactimg=new Image();
babyactimg.source=rep.currentItem.@src;
//Alert.show((rep.currentItem.valueOf()).toString());
babyactimg.height=62;
babyactimg.width=62;

//set position for records
if(i>=0)
{
babyactimg.y=Y;
Y+=babyactimg.height;
}
rep.addChild(babyactimg);
}
box_v.addChild(rep);