Using StageWebView as background for your app in Flex.

January 23, 2013

Basic thing about StageWebView class is that it is used to display html content in your app. To be more clear on that it is ‘rendered above all display list content’. Now having said that you cannot place/put other content like flex controls/components like a Button or List on above it.

Read the rest of this entry »


Packaging a native extension (Example batch file with all the options necessary to make one)

January 5, 2013

There has been a lot of questions and confusion on actually writing your batch file to compile/package your ANE file. Well i have decided to create a prototype of the batch file and share it here on my blog.

Your .bat file contents are as below.

set adt_directory=C:Program FilesAdobeAdobe Flash Builder 4.6sdks4.6.0bin
set root_directory=C:Projects
set library_directory=%root_directory%NativeExtLibrary
set native_directory=%root_directory%NativeExt
set signing_options=-storetype pkcs12 -keystore "C:Projectsp12key.p12" -tsa none
set dest_ANE=%root_directory%nativeExtPackagingANE.ane
set extension_XML=%library_directory%srcextension.xml
set library_SWC=%library_directory%binNativeExtLibrary.swc
set SWF_directory=%library_directory%binNativeExtLibrary
"%adt_directory%"/adt -package %signing_options% -target ane "%dest_ANE%" "%extension_XML%" -swc "%library_SWC%" -platform Android-ARM -C "%SWF_directory%" library.swf -C "%native_directory%" NativeExt.jar

Below explaining the variables in your bat file.

root_directory – root folder of your flex projects.
library_directory – location of your Native extension wrapper Flex library project.
native_directory – location of your native extension project(for Android-ARM it will be android project location).
signing_options – signed certificate for your extension and its options (-tsa none option to discard timestamp).
dest_ANE – location to create your ane file.
extension_XML – location of Native extension wrapper Flex library project extension descriptor file.
library_SWC – location of your Native extension wrapper Flex library project compilation file.
SWF_directory – location of your library.swf file.
Android-ARM – packaging ane for Android

Read the rest of this entry »


Interaction Mode in Flex

December 28, 2012

Interaction mode defines how you allow your app to interact with an app user. Interaction mode is again based on Theme you choose for your app, namely Halo, Spark, Modile. Default Interaction mode for Halo, Spark is mouse and for Mobile its touch.

But what if you want a different interaction mode rather than the default one, well its simple to change by using ‘interactionMode’ property and its usage is given below.

Read the rest of this entry »


Load schema and access the loaded schema of database in SQLite, AIR.

December 21, 2012

As always lets do things in steps.

  1. Create necessary variables.
  2. Open connection to database file already created.
  3. Read schema from opened connection to database.

1. Create necessary variables

private var sqlConnection:SQLConnection;
private var dbFile:File;
private var sqlStatement:SQLStatement;

2. Open connection to database file already created

dbFile=new File();
dbFile=File.applicationStorageDirectory.resolvePath("myDatabase.db");

sqlConnection = new SQLConnection();
sqlConnection.addEventListener(SQLEvent.OPEN, onDBOpened);
sqlConnection.addEventListener(SQLErrorEvent.ERROR, onDBError);
sqlConnection.open(dbFile);

3. Read schema from opened connection to database
Read the rest of this entry »


December 13, 2012

Hi All,

I have moved my blog from www.flexonblog.wordpress.com to www.99thoughts.com/flex_blog.

Sorry for any inconvenience, please update your links and such.

Hope to look forward to your support.


Tips on Spark List control and Spark DataGrid control

May 30, 2011

In Halo DataGrid control and Halo List control you would use the property scrollToIndex(index:int)  to specify to make the item at that index visible.But in Spark List control and Spark DataGrid control you should use different properties like below.

For Spark List

ensureIndexIsVisible(index:int);

For Spark DataGrid (version 4.5)

ensureCellIsVisible(index:int); 

and then there’s also setSelectedIndex(index:int); for Spark DataGrid

Enjoy the tip.


Image Cropping in Flex

January 31, 2011

Even though there are many posts on this particular topic still there are many ???, then i thought may be i can write about it, so lets get started.

Lets do things in steps.

  1. Load Image in to Flex App
  2. Convert it to Bitmap and BitmapData objects.
  3. Crop Image using BitmapData object

1.Load Image in to Flex App

private var imageLoader:Loader = new Loader();

private function fnInit():void
{
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadImageComplete);
imageLoader.load(new URLRequest(“assets/flower.png”));
}

2.Convert it to Bitmap and BitmapData objects

private var bitmapImage:Bitmap;
private var bitmapDataImage:BitmapData;

//Event.COMPLETE eventHandler for Loader

private function loadImageComplete(e:Event):void
{
bitmapImage = Bitmap(e.target.loader.content);
bitmapDataImage = Bitmap(bitmapImage).bitmapData.clone();
}

3.Crop Image using BitmapData object
Read the rest of this entry »


Tip on LinkBar control in Flex

December 20, 2010

LinkBar control defines the style name “linkButtonStyleName” to specify styles for link buttons, but does not define a style name for a selected link button.For example if you want to apply a specific style for a selected link button in the row of link buttons, you would think for a while, make some try outs, look in to the code, scratch your head for a while,curse flex and may be finnally give up.The real thing is it isn’t defined.But there is a way.

LinkBar control defines a row of LinkButtons, meaning we can access and apply styles to any of these individual Buttons at run time using setStyle method.

Example: Button(lnkBr.getChildAt(0)).setStyle(“fontWeight”,”normal”);

In the above line lnkBr is id of the LinkBar and getChildAt method gets that particular button and then we can apply style to that button using the setStyle method.

Demo

Code

 


Display ToolTips for Combobox List items in Flex4

July 13, 2010

Few months back i made this post in Flex3, it was buggy and i figured later it may not be possible here with my logic.Then comes the Flex4, did anyone tell you Flex4 is awesome, yes it is.The same requirement where you want to show tooltips on comboBox List items on roolover can be achieved easily in Flex4.You may have to read about the new ItemRenderer Class and its architecture for better understanding the code and you can go figure your own requirement then.

Download code below.

Read the rest of this entry »


Flash,Steve Jobs,Adobe: what do you think?.

April 30, 2010

If you haven’t read it, please do so.

So after reading the longggggggg page, i just thought a few too.

1.Did he just pull a fast one?.
2.Why is he directly blaming Flash(Adobe)?, I smell something fishy.
3.What does the Microsoft think about this?,  The enemy of my enemy is my friend.
4.I find only two thoughts reasonable,
 -Third, there’s reliability, security and performance.
 -Fourth, there’s battery life.
5.Repetitive thought, we follow all open standards [HTML5, CSS and JavaScript …], yeah like they create them and we should follow them.:-)
6.How come Flash works on Android phones?.May be Apple needs to enhance their products.
7.What’s Adobe reaction?.
8.There’s always thrist for new experiances, can’t stick to one standard/technology for a long time, and especially in this era whether PC or mobile.
9.Why did we adopt to Flash for web and Why is that difficult for mobile.Its been 40 years since man set foot on moon, did they make it or fake it.
10.It really doesn’t matter for the end user/customer who owns what, what really matters is that who can satisfy him/her.
11. And there’s a lot more …………………..

i am really tired of this shit, so if you people have any thoughts on this just comment.


Tip on Panel Class in Flex

December 16, 2009

Often hear questions on Alert Control like, remove default Button(OK),add new Button’s and so on.., and on TitleWindow like, re-arrange close Button to top-left,add new Buttons and so on..

One thing we got to notice at first is that TitleWindow and Alert are Classes which are derived from Panel Class, which in turn is derived from Container Class, so Alert and TitleWindow are sub-classes of Panel Class, they are created by addding new functionality[methods and properties] to the Panel Class.And the final tip is that, look in to the code,look in to the Class Diagram and if you dont have one then download it here , make a print and stick to a wall near you.

So, having said that you need to decide an appropriate implementation based of your requirements.Example, if you dont want to show OK(default Button) Button on the Alert Control,then better not to use Alert Control, go for a Panel,which is appropriate.

Below fig shows the Relational Diagram of Container,Panel,Alert and TitleWindow Classes.

Relational Diagram of Panel,Alert,TitleWindow

Enjoy the Post.


Sorting Date’s on ArrayCollection in Flex

November 16, 2009

First things first, read about the mx.collections.Sort Class before going in to the code below.

About the Post,suppose i have a AC[ArrayCollection] like below;

[Bindable]
private var arrClldetails:ArrayCollection = new ArrayCollection([
{Fname:”Kranthi”, Lname:”Kata”, dob:”21 Sep 79″},
{Fname:”Vasanth”, Lname:”Lola”, dob:”11 Jun 80″},
{Fname:”Manoj”, Lname:”Pati”, dob:”16 July 81″},
{Fname:”John McClain”, Lname:”Mela”, dob:”15 Feb 72″},
{Fname:”Ross”, Lname:”Geller”, dob:”02 Jan 74″},
{Fname:”Chandler”, Lname:”Bing”, dob:”18 Oct 76″}
]);

Now i want to Sort the “dob” Date field in the AC.,so for this i need to
write a compareFunction for Sort which in turn is applied to the AC like below,

Read the rest of this entry »


Tracing Childrens of a Container in Flex

November 9, 2009

A Container in Flex is one that controls the layout characteristics of child components and which extends the Container base Class like the famous Panel,Canvas,ViewStack,TabNavigator,…

Container contains childrens or Sub Components or Sub Containers[Container in a Container], and so on.Childrens/child components in a Container are all are created using the creationPolicy setting of that Container.In case of sub containers, outer Containers are created before the inner one’s.And creation can be altered by setting the creationPolicy.

So now we know some basics of Container its time for the Topic.

Tracing..
We can manage the child components of a Container by using its predefined methods,like below..
1.Container.getChildren() – returns an Array of child components.
var arr:Array=Container.getChildren();
2.Container.getChildAt(index:int) – returns an instance of the DisplayObject at that creation index,which we can cast to required.
var obj:Object=Container.getChildAt(0);
3.Container.removeChildAt(index:int) – removes child at that creation index
var disObj:DisplayObject=Container.removeChildAt(0);
4.Container.removeAllChildren() – as the name specifies
….so on

In the below download code i have implemented all these methods with a Panel.Enjoy the Post.

Download code.


Assign a menu item(on right click menu list) to DataGrid control in Flex.

October 9, 2009

OK, First thing to do, read about flash.ui.ContextMenu Class.
Some points..
->In SWF content, any object that inherits from InteractiveObject can be given a context menu by assigning a menu object to its contextMenu property.
->In Flex, only top-level components in the application can have context menus.
->Flash Player has three types of context menus:standard menu ,the edit menu and an error menu.Only the standard and edit menus can be modified with the ContextMenu class.

so first create a ContextMenu for the DataGrid like below..

private function fnDgContextMenu():ContextMenu
{
var newContextMenu:ContextMenu = new ContextMenu();
var newContextMenuItem:ContextMenuItem=new ContextMenuItem(“Sort”);
newContextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,fnSortSelect);
newContextMenu.customItems.push(newContextMenuItem);
return newContextMenu;
}

now assign it to DataGrid.
dg.contextMenu=fnDgContextMenu(); // here dg is the “id” of the DataGrid.check the code below.

[showmyads]

Download code.

Enjoy the post.


Tips on MenuBar control and its dataProvider in flex

September 25, 2009

Suppose we have a MenuBar and its dataPovider as below.

<mx:MenuBar id=”myMenu” dataProvider=”{xmlLst}” labelField=”@label” itemClick=”fnItemClick(event)” />

<mx:XMLList id=”xmlLst”>
        <root label=”year”>
            <menuitem label=”2001″ enabled=”true”/>
            <menuitem label=”2002″ enabled=”false”/>
            <menuitem label=”2003″ enabled=”true”/>
            <menuitem label=”2004″ enabled=”false”/>
            <menuitem label=”2005″ enabled=”true”/>
        </root>
</mx:XMLList>

and the itemClick handler below
private function fnItemClick(event:MenuEvent):void
{
//code goes here on itemClick
}
Desc: The MenuBar displays the XMLList dataProvider with all the years as menuitems[because labelField=”@label”], and has a handler for itemClick “fnItemClick”.

Now the tips..

1.To set enabled=true for the year 2002.
xmlLst.menuitem.(@label==”2002″).@enabled=true;
//this is like traversing the XMLList.
//this will reflect changes both to XMLList and MenuBar
2.To set for all enabled=true.
//here we got to traverse the XMLList and change the data.
for each(var xml:XML in xmlLst.menuitem)
{
 xml.@enabled=true; 
}
3.To set enabled=false for selected Item.
//in the itemClick handler use the below code
event.item.@enabled=false;

Things to remember:- while accessing attributes of XML we got to use ‘@’ before the attribute name, not neccessary if it is an Object.

Download code.

Note:- Examples or code you have seen on this blog so far are related to Flex 3 SDK.