Archive for Flex – Andriod

Gestures On Mobile

Zoom Gesture

Pinch to zoom in and zoom out on image or maps.

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM,zoomHandler);

private function zoomHandler(evt:TransformGestureEvent):void{

// previewImage is the container of image/map anything

previewImage.scaleX *= evt.scaleX;

previewImage.scaleY *= evt.scaleY;

}

Will be posting on more Gestures and Touch Events. Feel free for comments / suggestions :)

 

Scroller Spark Component – Flex 4.5

Scroller component is the component which is bydefault configured with horizontal and vertical scrollers. If the content of this component is in more area than that of scroller then the content will be able to scroller up/ down or side wise to have proper look of the content. Lets have a look on the example.

<s:Scroller id=”scroller” x=”0″ y=”45″ width=”320″ height=”410″>
<s:Group>
<s:Image id=”previewImage” x=”0″ y=”0″ width=”620″ height=”810″ source=”bird.png” cacheAsBitmap=”true” />
</s:Group>
</s:Scroller>

Feel free to post queries. :)

ItemRenderer in Flex 4.5

We can say item renderer as custom component, which we can define by our own. We can set it properties , can add image , text, label and all that can be done dynamic too.

Let say we can have a list and its dataprovider will be array collection , its itemRenderer will be our custom item renderer and will be behaving according to our properties.

Eg. Lets consider we have a array collection (_arrayColl) with five elements  which contains objects having a label and an icon image.

Each object have properties like  : -  obj.name = “My computer”; obj.icon =”myComp.png”;

Lets define ItemRenderer  first : – listRenderer.mxml

<?xml version=”1.0″ encoding=”utf-8″?>
<s:ItemRenderer xmlns:fx=”http://ns.adobe.com/mxml/2009″ xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:views=”views.*” width=”295″ height=”44″ >
<s:Label id=”name” x=”3″ y=”13″ enabled=”false” fontFamily=”Arial” text=”{data.name}” />
<s:Image  x=”237″ y=”13″ source=”{data.icon}” />
</s:ItemRenderer>

 

Now above mxml can be called inside list as : -

<s:List id=”dlist” x=”12″ y=”171″ width=”295″ height=”216″ dataProvider=”{_arrayColl}”
itemRenderer=”listRenderer” />

 

Now we are done : You can see your list showing the data correctly with five items.

Feel free to put comments.

Getting color in hexadecimal form from color picker

Suppose you are using color picker in a flex application. You want to get the color selected by the user throught color picker in hexadecimal form so that you can use the same color some where else in that application.

<mx:ColorPicker x=”476″ y=”145″ showTextField=”true” id=”colorPickerID” change=”changed()”/>

changed() is the function called when user changes the color of the color picker .

public function changed():void{

var colorSelected = colorPickerId.selectedColor.toString(16);

}

colorSelected is the color what you wanted

:) njoy………