Wednesday, March 11, 2009

Dynamically Changing Image Source.

If you are dynamically changing the image source. It does not reflect the same on the screen/Display. so to overcome the problem.
use like this..

imgUrl ="path of the image";

image1.source = imgUrl+"?"+new Date().time;

Friday, January 16, 2009

Singleton in Flex and its Usage

What is singleton pattern?

The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. If you create the class as a singleton then no way to create more than one instance. But, you can get that single instance in any number of classes. So all the classes will share the same properties and behaviours of that singleton object.

How to implement the singleton pattern?

Implementation of a singleton pattern must satisfy the single instance and global access principles. It requires a mechanism to access the singleton class member without creating a class object and a mechanism to persist the value of class members among class objects. The singleton pattern is implemented by creating a class with a method that creates a new instance of the class if one does not exist. If an instance already exists, it simply returns a reference to that object. To make sure that the object cannot be instantiated any other way, the constructor is made protected (not private, because reuse and unit test could need to access the constructor). Note the distinction between a simple static instance of a class and a singleton: although a singleton can be implemented as a static instance, it can also be lazily constructed, requiring no memory or resources until needed. Another notable difference is that static member classes cannot implement an interface, unless that interface is simply a marker. So if the class has to realize a contract expressed by an interface, it really has to be a singleton.

The singleton pattern must be carefully constructed in multi-threaded applications. If two threads are to execute the creation method at the same time when a singleton does not yet exist, they both must check for an instance of the singleton and then only one should create the new one. If the programming language has concurrent processing capabilities the method should be constructed to execute as a mutually exclusive operation.
The classic solution to this problem is to use mutual exclusion on the class that indicates that the object is being instantiated.

How to implement the singleton pattern in Flex and ActionScript?

  • Can we implement the singleton pattern in ActionScript? Why not? Ofcource we can.
  • Is there any keyword named as singleton in Flex?. No.
  • Can we declare the constructor as protected in Flex?. No. (ActionScript 3.0 will not support protected constructors)
  • Can we declare the constructor as private in Flex?. No. (ActionScript 3.0 will not support private constructors)
  • Then how can we implement the singleton pattern in Flex ? See the next line.

Steps to implement the singleton pattern in Flex and ActionScript

Consider the MySingleTon class as a singleton class.

package {
public class MySingleTon {

// Single Instance of Our MySingleTon
private static var instance:MySingleTon;

//DEFINE YOUR VARIABLES HERE
public function MySingleTon (enforcer:SingletonEnforcer)
{
if (enforcer == null)
{
throw new Error( "You Can Only Have One MySingleTon" );
}
}

// Returns the Single Instance
public static function getInstance() : MySingleTon
{
if (instance == null)
{
instance = new MySingleTon ( new SingletonEnforcer );
}
return instance;
}
}
}

// Utility Class to Deny Access to Constructor
class SingletonEnforcer {}

1). We should create one static variable. It will be called "instance" and it will be of type MySingleTon. This will be the variable where we will store our
one instance of our class.

2). Then we should create one constructor. The constructor takes one argument - "enforcer". You will notice that this "enforcer" has a type of "SingletonEnforcer"
which is defined directly after our class. Here is the logic behind that:
  • When you put a class in an Actionscript file below the main class, it is only available to that class.
  • If the constructor requires this argument - then only our main class can create an instance of itself, because we do not have access to the “SingletonEnforcer” class. Only the main class has this access.
  • We will not access our class in the normal way by using the “new” statement because we can’t call the constructor. Once we get inside of the constructor, we have a few lines that make sure things work as planned. The “if” statement ensures that we had a valid “enforcer” passed in. If there wasn’t it throws an Error stating that “You Can Have Only One MySingleTon”.

Then we should create one static function named as getInstance. The “getInstance” function is how we will access our MySingleTon from our application. This function simply passes back the “instance” of the class. If it doesn’t exist yet, it creates it. We can now get the MySingleTon by using the following:

var mySingleTone:MySingleTon = MySingleTon.getInstance();. So you can share this single object in any number of classes.

PureMVC and Guidelines

PureMVC is a framework which helps the Flex programmers to create applications in the MVC architecture. It helps the programmers to develop loosely coupled components. It helps to create the resusable codes. Very easy to understand and maintain than other frameworks. Forces the singleton pattern.

We can divide the pureMVC as:

  • Facade & Core
  • Controller & Commands
  • Model & Proxies
  • View & Mediators
  • Observers & Notifications

Steps to follow in PureMVC

1. Main application should call the facade.startup(this). Here facade is the singletone instance of ApplicationFacade class.

2. ApplicationFacade

  • Singleton class.
  • It extedns the org.puremvc.as3.patterns.facade.Facade.
  • It implements org.puremvc.as3.interfaces.IFacade .
  • Should override the initializeController() method.
  • It defines static constants for Notification names.
  • Initializes the Commands used to access and notify the Commands, Mediators and Proxies.

3. MacroCommand(s)

  • It extends the org.puremvc.as3.patterns.command.MacroCommand.
  • It implements the org.puremvc.as3.interfaces.ICommand.
  • Should override the initializeMacroCommand() method.
  • Executes the SimpleCommands and MacroCommands.
  • User can registerand retrieve the Mediators and Proxies.

4. SimpleCommand(s)

  • It extends the org.puremvc.as3.patterns.command.SimpleCommand.
  • It implements org.puremvc.as3.interfaces.ICommand.
  • Should override the execute( note:INotification ) method.
  • User can register and retrieve the Mediators and proxies.

5. Mediator(s)

  • It extends the org.puremvc.as3.patterns.mediator.Mediator.
  • It implements the org.puremvc.as3.interfaces.IMediator.
  • Should override the listNotificationInterests() and handleNotification( note:INotification ) methods to listen to the notifications.
  • Registers the mediators and proxies.
  • User can retrieve the Mediators and proxies.
  • User can register the notifications.
  • Listens for the notifications from other Mediators, Proxies and commands.
  • Listens for the events from the component.
  • Sends the notifications to other mediators.

6. Proxy(ies)

  • It extends org.puremvc.as3.patterns.proxy.Proxy.
  • It implents the interface org.puremvc.as3.interfaces.IProxy.
  • User can send the notifications.
  • Used to access the Delegates and datas.

7. Component(s)

  • Views of our application.
  • Every component should have its own Mediator. One Mediator per Component.
  • Dispatches the event. So the mediator can listen for that events.

Observers

PureMVC applications may run in environments without access to Flash’s Event and EventDispatcher classes, so the framework implements an Observer notification scheme for communication between the Core MVC actors and other parts of the system in a loosely-coupled way. No need to create instance for the Observers and notificatios. These are inbuilt things in the pureMVC.

Notifications
PureMVC implements the Observer pattern so that the Core actors and their collaborators can communicate in a loosely-coupled way, and without platform dependency.

Not simply a replacement for Events, Notifications operate in a fundamentally different way, and work synergistically with Events to produce extremely reusable View Components that need not even know that they are coupled to a PureMVC system at all if engineered properly.

Events are dispatched from Flash display objects that implement the IEventDispatcher interface. The Event is ‘bubbled’ up the display hierarchy, allowing the parent object to handle the Event, or the parent’s parent, etc.

Notifications are sent by the Facade and Proxies; listened for and sent by Mediators; mapped to and sent by Commands. It is a publish/subscribe mechanism whereby many Observers may receive and act upon the same Notification.

WorkFlow of the PureMVC framework

  • MainApplication should startup the pureMVC framework by calling the ApplicationFacade(Facade)’s startup method.
  • ApplicationFacade Registers the Commands,Mediators and Proxies.
  • User can retrieve the Mediators and Proxies in the ApplicationFacade.
  • Two commands are there: MacroCommand and SimpleCommand.
  • MacroCommand registers other commands, Mediators and Proxies.
  • SimpleCommand registers the Mediators and Proxies.
  • Both the Macro and Simple Commands can be used to retrieve the Mediators and Proxies.
  • User can send notifications from both the Macro and Simple commands.
  • Mediators registers the component with the PureMVC.
  • Mediators will listen for the events and notifications.
  • Mediators will listen for the events dispatched from the Components.
  • Mediators will listen for the notifications sent from the other Mediators, Proxies and Commands.
Courtesy:ponbharathi

Wednesday, December 31, 2008

Flex Interview Questions & Answers

1. Is it possible to make httpService Requests synchronous?
Yes, By using Custom Class and Remote Objects..
http://blog.lab49.com/archives/category/flex
2. I need to load an image from flickr into my application. Do I need a crossdomain.xml file on flickr?

Of course it's Adobe's problem. The player work "as designed", but it's a poor design.

The idea behind crossdomain.xml files is to prove that the site hosting the SWF file also controls the domain the data is being loaded from. Unless you think that you should need to own Flickr to be able to host a SWF that can access Flickr images, I can't see how you could possibly think this is a good design.

At best it can be said that Flash isn't designed to do that you're trying to do, in which cse you've made a bad choice in using it at all. It's either Adobe's fault or yours, but certainly not Flickr's.
3. What is the difference between httpService and Data Service?
The Flex presentation layer communicates with the business layer by using Flex
data services, which are objects you insert in a Flex file. Specifically, you can
use Flex data services to interact with the following:

* Web services
* HTTP services
* Remote objects

A Flex data service is an object you insert in an MXML file to communicate with
the business layer of a multi-tier application. You use data services to send and
receive data from web services, HTTP URLs, and remote objects such as
server-based Java objects.

An HTTP service is nothing more than an HTTP request to a URL. The primary
purpose of HTTP services is to retrieve XML data from an external source.

4.How do you generate random numbers within a given limit with actionscript?
public function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}
5.Have you built any components with actionscript? If so explain how you did it?
Yes, By extending any UI Compopnents
6.How do you implement push on a flex applications?
Pushing datas into array
7. I am going to add images into a tag. How will it resize itself?
Scalecontent = true
For the tag in which you are going to add images you don't have to specify any width or height property. This will help the container to resize itself.

8.What is a resource Manager?
With Flex 3, localization support will become much more Flexible! Here’s how:
• You can put your resources into resource modules -- similar to style modules -- rather than into the application itself. You can preload the module for an appropriate locale when the application starts, and you can load modules for additional locales later.
• You can compile resources for multiple locales into a single application or module.
• You access all resources through a new ResourceManager, which can manage resources for multiple locales. You can change at runtime which locales get searched for resources.
• Binding expressions that reference resources via the new ResourceManager will automatically update if the locale changes. Components are notified when the locale changes so that they can update themselves appropriately.
• You can also use images, sounds, etc. as resources rather than just strings.
• You can programatically create your own resources at runtime and use them just like ones that were compiled from .properties files. So you can create resources at runtime from downloaded XML files, database results, etc.
http://sujitreddyg.wordpress.com/2008/01/22/localizing-flex-applications/
9.What are the similarities between java and flex
• Java is a virtual machine that can be used to create platform-independent software. Software created in Java can run on any hardware that supports the Java Virtual Machine.
• In web development, Java can be used as either a client-side or server-side programming language.
• When Java is used on the client side, we're generally talking about Applets, which can run on a browser with Java support.
• When Java is used on the server side, we're probably thinking JSP or [???] to create framework-based web applications or to create web services.
How does it compare to Flex?
• Java Applets, with their ability to run inside a browser window, are similar to Flex applications. Flex apps, however, are much easier to deploy through the lightweight easy-to-install Flash Player.
• Server-side Java can be used to create web services for consumption by a Flex application
10. What is the dynamic keyword used for?
dynamic

11.What are the methods called when a UI component is intialized?
createChildren(),commitProperties(),measure(),layoutChrome(),updateDisplayList()
http://flexcomps.wordpress.com/2008/05/09/flex-component-life-cycle/
12. How do you implement drag and drop on components that do not support ondrag and ondrop?
DragManager.doDrag( componentname, new Datasource, mouseevent);
Accept drag on DestinationPlace.
13. Can you write to the file system from flex?
No
14. What is a drag manager?
The DragManager class manages drag and drop operations, which let you move data from one place to another in a Flex application. For example, you can select an object, such as an item in a List control or a Flex control, such as an Image control, and then drag it over another component to add it to that component.
All methods and properties of the DragManager are static, so you do not need to create an instance of it.
All Flex components support drag and drop operations. Flex provides additional support for drag and drop to the List, Tree, and DataGrid controls.
When the user selects an item with the mouse, the selected component is called the drag initiator. The image displayed during the drag operation is called the drag proxy.
When the user moves the drag proxy over another component, the dragEnter event is sent to that component. If the component accepts the drag, it becomes the drop target and receives dragOver, dragExit, and dragDrop events.
When the drag is complete, a dragComplete event is sent to the drag initiator.

15. How do you call javascript from Flex?
The ExternalInterface class is the External API, an application programming interface that enables straightforward communication between ActionScript and the Flash Player container– for example, an HTML page with JavaScript. Adobe recommends using ExternalInterface for all JavaScript-ActionScript communication.
You can call an ActionScript function in Flash Player, using JavaScript in the HTML page. The ActionScript function can return a value, and JavaScript receives it immediately as the return value of the call.
This functionality replaces the fscommand() method.
The ExternalInterface class requires the user's web browser to support either ActiveX® or the NPRuntime API that is exposed by some browsers for plug-in scripting. Even if a browser and operating system combination are not listed above, they should support the ExternalInterface class if they support the NPRuntime API. See http://www.mozilla.org/projects/plugins/npruntime.html.
Note: When embedding SWF files within an HTML page, make sure that the id and name attributes of the object and embed tags do not include the following characters:
. - + * / \

From ActionScript, you can do the following on the HTML page:
• Call any JavaScript function.
• Pass any number of arguments, with any names.
• Pass various data types (Boolean, Number, String, and so on).
• Receive a return value from the JavaScript function.
From JavaScript on the HTML page, you can:
• Call an ActionScript function.
• Pass arguments using standard function call notation.
• Return a value to the JavaScript function.
Flash Player does not currently support SWF files embedded within HTML forms.

16. How do you use a repeater?
The Repeater class is the runtime object that corresponds to the tag. It creates multiple instances of its subcomponents based on its dataProvider. The repeated components can be any standard or custom controls or containers.
You can use the tag anywhere a control or container tag is allowed, with the exception of the container tag. To repeat a user interface component, you place its tag in the tag. You can use more than one tag in an MXML document. You can also nest tags.
You cannot use the tag for objects that do not extend the UIComponent class.
MXML Syntax Hide MXML Syntax
The class has the following properties:


17. What are three ways to skin a component in flex?
Tag,class,typed
18. How do you use css styles in flex?

19. What is the difference between sealed class and dynamic classes?
Sealed Classes cannot add properties and methods dynamically.
Dynamically cannot add proprties or methods.
20. What is MVC and how do you relate it to flex apps?
MVC is an Model View Controller Architecture used to differentiate the Model(business Classes), View (Mxml components) and Contoller(command classes).
21. What is state? what is the difference between states and ViewStack?
View Stack is to handle different MXML file eg TAB control..
And states is the transition within single MXML file
ViewStack should be used were there is complete change in the controls used and States should be used when you just want to add or remove a few components based on certain conditions.
Login/Registration/Forgot password is the best example for using States as each page will either add or remove to the already existing one.
22. How does item renderer work? How do I add item renderer at runtime?
Item renderer works with Listbased Contols such as list,combo,datagrid,menu,menubar,tree etc.. It Populate the list based on the dataprovider to the particular component.
xxx.itemrenderer = new classfactory(rendrerer component name);
23. What are the various ways of creating and using item renderers?
• Using the default item renderer
• Using a drop-in item renderer
• Creating an inline item renderer
• Creating a reusable inline item renderer
• Using a component as an item renderer
http://www.adobe.com/devnet/flex/quickstart/using_item_renderers/

24. What keyword allows you to refer to private variables of a class?
this
25. How polymorphism works on actionscript?
http://www.adobe.com/devnet/actionscript/articles/oop_as3_05.html
26. Whats the difference between itemRenderer & itemEditor?
ItemRenderer can be used to edit the cells and make modifications..,
Itenrenderer only readonly no modification possible.
27. How do you overload functions in actionscript?
Ex:An constructor can contain ‘n’ number of arguments
28. What is dynamic keyword used for?
We can add properties to the class which has the keyword dynamic.
29. What are sealed classes ?
We cant add properties to the class which are sealed.
30. What are runtime shared libraries?
Runtime-shared-libraries (RSLs) to reduce the size of your applications and thereby reduce the time required to download the application. RSLs are just SWF files whose code is used as a shared library between different application SWF files. There are two kinds of RSLs, signed and unsigned. Signed RSLs are libraries that are signed by Adobe and may be stored in the Flash Player Cache, which can be accessed by applications from any domain. This means if your application is using a signed RSL, the RSL may not even need to be downloaded if the RSL is already in the Flash Player Cache. The signed RSL may have been put into the Flash Player Cache by visiting another web site that was using the same signed RSL. Signed RSLs have a "swz" extension.
http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs
31. What is caringorm ? how do you use it?Have you worked with Cairnghorm?
Cairngorm is the lightweight micro-architecture for Rich Internet Applications built in Flex or AIR.Add the Cairgorm.swc file to ur librarypath.
http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm;jsessionid=B01E4B7E105462969ED5A7FA1FFD4543
32. What design patterns have you used? in Actionscript and java?
PureMVC,Cairngorm

33. What's the difference between ChangeWatcher.watch, and BindingUtils.bindProperty?
The ChangeWatcher class defines utility methods that you can use with bindable Flex properties. These methods let you define an event handler that is executed whenever a bindable property is updated.
public function initWatcher():void {
// Define a watcher for the text binding.
ChangeWatcher.watch(textarea, "text", watcherListener);
}
// Event listener when binding occurs.
public function watcherListener(event:Event):void {
myTA1.text="binding occurred";
}

The BindingUtils class defines utility methods for performing data binding from ActionScript. You can use the methods defined in this class to configure data bindings.

private function init():void {
BindingUtils.bindProperty(textInputDst, "text", textInputSrc, "text");
}
34. How do you add event listeners in mxml components. Now AS3 components?
Inside the tag you can add event listeners by specifying the components id/name or using this keyword.
35. What does calling preventDefault() on an event do? How is this enforced?
preventDefault () method
public function preventDefault():void
Cancels an event's default behavior if that behavior can be canceled.
Many events have associated behaviors that are carried out by default. For example, if a user types a character into a text field, the default behavior is that the character is displayed in the text field. Because the TextEvent.TEXT_INPUT event's default behavior can be canceled, you can use the preventDefault() method to prevent the character from appearing.
An example of a behavior that is not cancelable is the default behavior associated with the Event.REMOVED event, which is generated whenever Flash Player is about to remove a display object from the display list. The default behavior (removing the element) cannot be canceled, so the preventDefault() method has no effect on this default behavior.
You can use the Event.cancelable property to check whether you can prevent the default behavior associated with a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event; otherwise, preventDefault() has no effect.




The quick brown fox jumped over the lazy dog.



36. How do you identify a component created in a repeater?
No way. But you can get the data of the selected repeated component, or the number of child its holds. By accessing its parent container.
37. LifeCycle of Flex-application??

initialized property
initialized:Boolean [read-write]
A flag that determines if an object has been through all three phases of layout: commitment, measurement, and layout (provided that any were required).


Ex:










38. What is meant by data binding?
Data binding is the process of tying the data in one object to another object. It provides a convenient way to pass data around in an application.
39. What are the different ways to specify data binding in flex?
• Using the curly braces ({}) syntax
• Using ActionScript expressions in curly braces
• Using the tag in MXML
• Using bindings in ActionScript
http://www.adobe.com/devnet/flex/quickstart/using_data_binding/
40. Write code to create a button with the title "Press". Add code to intercept the button click event. When clicked, the title of the button should change to "Button Pressed". Either use MXML or ActionScript.





41. What is the FaultEvent class ?
Fault event class indicates an error has occurred.. You can use the Fault Event with HTTP Service , Remote Object. When there is connection failure or some error the Fault Event handles and displays it..
42. What is the difference between Array and ArrayCollection classes?
ArrayCollections can hold different instances of varying data types. You can add and remove items from ArrayCollections, causing repositioning along the array. ArrayCollections can hold far more data than regular Arrays
43. What is Flex?
Its is an Framework or tool Used for developing RIA.
44. What kind of applications you can create from Flex?
Web Application
45. What is the output of Flex applications?
Swf  shock wave file/object.
46. What development environment you need to create Flex applications?
Adobe Flex Builder / flashplayer 9
47. Can you manipulate images using Flex programs?
yes
48. Does Flex support creating workflow based applications?
yes
49. What kind of data grids you can create through Flex applications?
Datagrid,Advanced Datagrid,OLAP Datagrid
50. How do you connect to a database via a Flex program?
Using any server side Languages such as ASP,DotNet,JSP,PHP etc..

51. Can you develop web based applications in Flex?
Yes
52. Is Flex OS specific or operating system independent?
No its OS Independent.
53. Can we run Flex applications in MAC?
Yes
54. Do we need any plugins to run Flex applications?
Flash Player 9 should be installed in the browser.
55. What's the difference between Java and AS3 getters and setters?
In Java, getter and setter methods have to be explicitly called.While in AS3, they're called automatically and externally indistinguishable from public properties.
For instance trace(myClass.foo) might be referencing a public property or it might be referencing the method "public get foo():Object". It makes no difference to an external class.
56. Data Grid adding and changing columns with item renderers at runtime.
Right click to view the source.
http://www.dgrigg.com/post.cfm/08/01/2007/Datagrid-runtime-item-renderers
Step 1.
Create the basic item renderer. One of the things I needed to accomplish with my item renderer was the ability to add it to different columns (ie the dataField was not always the same). This meant I needed a way from within the renderer to determine what column it was bound to so I could get and display the correct data. To do this the renderer needs to implement the IDropInListItemRenderer. This interface allows the renderer to have access to information about the list and column it is in via the BaseListData and DataGridListData classes. The DataGridListData gives you everything you need to get the data required to make a flexible, reusable renderer.
Here is my basic image item renderer. Nothing to exciting, but it is very reusable. I can drop this into any datagrid to render an image column and it will work.






Step 2.
Modify the renderer so that it can be added at runtime. To do this the renderer needs to implement the IFactory interface. This will allow the renderer to be added at any point during runtime. Without implementing this interface it won't work, period. Below is the code to implement the interface.

public function newInstance():*
{
return new ImageRenderer();
}

Step 3.
The code to change a column at runtime from a basic column to an item renderer column. Get the columns from the datagrid, modify the column you are interested in and then reassign the columns to the datagrid. Notice that when you set the column's itemRenderer value you must create a new instance of the desired item renderer.
private function switchStatusColumn(event:MouseEvent):void {
var cols:Array = users_dg.columns;
var col:DataGridColumn = cols[1] as DataGridColumn;
col.itemRenderer = new CheckBoxRenderer();
users_dg.columns = cols;
}
Step 4.
The code to add a new column with an item renderer at runtime. This is almost identical to modifying an existing column. The only difference is that we push the new column into the columns array.
private function addImageColumn(event:MouseEvent):void {
var cols:Array = users_dg.columns;
var col:DataGridColumn = new DataGridColumn();
col.itemRenderer = new ImageRenderer();
col.dataField = 'emoticon';
col.headerText = 'Image';
cols.push(col);
users_dg.columns = cols;
}
57. whats the difference between mx.rpc.http.HTTPService and
mx.rpc.http.mxml.HTTPService ?
whats the difference and when each has to be used..


mx.rpc.http.mxml.HTTPService inherits from mx.rpc.http.HTTPService. So
basically mx.rpc.http.mxml.HTTPService has everything that mx.rpc.http.HTTPService has. But apart from that, it can also handle concurrency. This means if concurrency is set to multiple, you can send multiple asychronous requests using the same object. But the flipside of this is that while handling the results, you have to be careful about which request is the data pertaining to...
58. How BindingUtils.bindProperty works?
Works pretty much the same way as the watch, but instead of having to handle and event it allows you to immediately bind two properties one-way. The first two parameters are for the the target, the second parameters are the triggers.
BindingUtils.bindProperty( this, "va1", this, "var2");

Some More Questions
How to delete an element/node from the xml?
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
Explain how binding works in mxml components.
Why would you want to keep a reference to a ChangeWatcher and call unwatch()?
What kind of source code integration tools are available with Flex?
What third party development tools are available to program in Flex?
How do you implement push with flex data services?
What keyword allows you to implement abstraction better?

Friday, December 12, 2008

Communicating Flex to DotNet using Objects

Flex can communicate with Dot Net using Web service. Now explain how to pass objects from Flex to Dot net and fore back.

The Declaration of the objects must be done either in Dot Net or Flex.

First Declare and declare the object that we have to access in Dotnet as Address.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

///
/// Summary description for custaddrinfo
///

public class addressinfo
{


public string offaddressline;
public string offplace;
public string offcity;
public string offstate;
public string offmobile;
public string offpostalcode;
public string offcountry;
public string offtelephone;
public string offfaxno;
public string offemailid;
public string offemerperson;
public string offemerperteleph;
public string offemerperobile;

public addressinfo()
{
// TODO: Add constructor logic here
}
}


In the Second Step Define the Web service (C#.Net) as

[WebMethod]
public string insert_contact_testing(addressinfo addr)
{

database_connection....and other statements..
insert into contacttable values (addr.offaddressline, addr.offpostalcode, addr.offplace, addr.offcity, addr.offstate, addr.offcountry, addr.offtelephone, addr.offmobile, addr.offfaxno, addr.offemailid, addr.offemerperson, addr.offemerperteleph, addr.offemerperobile);

}

Then in flex Initialize an object and bind values to it and Pass the values to DotNet using Webservice.


/////////////////////////////////////////////////////////////////////////////////////////////////////
//###############################creating object for address info #############################


public var addressinfo:Object;
public function crtobj():void
{
addressinfo= new Object();
//office address
addressinfo.offaddressline = Prj_Reg_CustAddressparty1text.text;
addressinfo.offpostalcode = Prj_Reg_CustAddressPin1text.text;
addressinfo.offplace = Prj_Reg_CustAddressplace1text.text;
addressinfo.offcity = Prj_Reg_CustAddressCity1text.text;
addressinfo.offstate = Prj_Reg_CustAddressState1text.text;
addressinfo.offcountry = Prj_Reg_CustAddresscountry1Text.text;
addressinfo.offtelephone = Prj_Reg_CustAddressTel1text.text;
addressinfo.offmobile = Prj_Reg_CustAddressMobile1Text.text;
addressinfo.offfaxno = Prj_Reg_CustAddressFax1Text.text;
addressinfo.offemailid = Prj_Reg_CustAddressMail1text.text;
addressinfo.offemerperson = Prj_Reg_CustAddressconperson1Text.text;
addressinfo.offemerperteleph = Prj_Reg_CustAddresscontel1Text.text;
addressinfo.offemerperobile = Prj_Reg_CustAddresscontmobile1Text.text;

}

//###################################### web service initialize ########################
private var prjRegService:WebService;

public function initService()
{
prjRegService = new mx.rpc.soap.WebService();
prjRegService.wsdl = 'http://';
}
//############################################ save datas to database ###################
public function saveCustAddrInfoDetails():void
{

initService();
prjRegService.insert_contact_testing.addEventListener("result",custaddrinfodetailsSave);
prjRegService.loadWSDL();
prjRegService.insert_contact_testing(addressinfo);

}
public function custaddrinfodetailsSave(event:ResultEvent):void
{

var res:String;
res=event.result.toString();
//Alert.show("result value" + res);

}
}

Tuesday, October 28, 2008

RIA WAR BEGINS



On the Web Today a War to decide how Web applications and content will be developed and how users will consume the content of the future Web. The browser war’s are gone, its about RIA(Rich Internet Application) , a type of webapplication that can run independently of browsers, and can run on any O.S and works similiar to deskop systems.
Some Developement Frameworks for creating RIA Applications are
1. Adobe Flex
2. Adobe AIR
3. Microsoft SilverLight
4. Mozilla Prism
5. Curl
6. Apple’s Sprout core
7. Eclipse RIA plugins(UltraLightClient)
8. Open Laszlo
9. XBAP

Adobe Flex:


Adobe Flex is a cross-platform developement framework for creating rich internet applications(RIAs). It is a highly productive framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops and operating systems.
It provides a modern, standards-based language and programming model that supports common design patterns. MXML, a declarative XML-based language, is used to describe UI layout and behaviors, and ActionScrip 3.0, a powerful object-oriented programming language, is used to create client logic. Flex also includes a rich component library with more than 100 proven, extensible UI components for creating rich Internet applications (RIAs), as well as an interactive Flex application debugger.

Adobe AIR:

Adobe AIR is a cross-platform runtime environment for building rich Internet applications using Adobe Flash, Adobe Flex, HTML, or Ajax, that can be deployed as a desktop application. AIR applications can operate offline, and then activate further functionality or upload data when an active Internet connection becomes available
Adobe AIR uses the same proven, cost-effective technologies used to build web applications, so development and deployment is rapid and low risk. You can use your existing web development resources to create engaging, branded applications that run on all major desktop operating systems.

Microsoft SilverLight:


Microsoft released Silverlight 1.0 in 2007.Silverlight works on multiple Web browsers, including Firefox and Safari, and ran on both Windows and Mac OS X. Silverlight's browser and operating system support is impressive, as an RIA platform, its scope is much more modest. Silverlight proved to be a fairly basic and even old-school approach to building and using RIAs. Silverlight can't be considered a direct competitor to more advanced RIA platforms such as Adobe AIR. Silverlight is more of a direct competitor to Flash.
Silverlight is designed to run within browsers and has mainly been focused on Web-based animations and interactivity, long the forte of Flash.Silverlight 2.0 beta, the Microsoft RIA platform is moving beyond its initial focus on animation and interactivity. With the new release, more data awareness has been added to the Silverlight framework, making it possible to build more business-friendly applications.
Future plans for Silverlight include support for offline applications. Right now, however, Silverlight is an interesting but fairly basic version of Flash that doesn't match up to more advanced RIA systems such as AIR.


Mozilla Prism:


Prism is a simple but powerful program that makes it possible to take any existing Web application and turn it into a stand-alone application
We can convert any web application to a desktop application that would run outside of a standard browser window. It removes all the unnecessary browser controls and allows to focus on the application itself.
Prism isn't actually removing the browser from the equation. In fact, Prism is essentially a stripped-down version of the Firefox 3 browser.
But this simple approach to RIA development and use may prove to be one of the most attractive for many developers. The biggest benefit is that there is no need to learn any new development techniques. Simply develop Web application for any browser, and then deliver it through Prism. Prism is the only RIA platform that will be immediately usable by Web users without any development skills.
Prism is still under the Mozilla Labs umbrella, meaning it is in many ways considered experimental. But that hasn't stopped Prism from being used by some high-profile applications, including the recently released desktop client for the Zimbra mail platform.


Curl:

Curl has a more specific focus--helping businesses and developers actually get work done through RIAs.Curl is a complete and finished product, and it shows in Curl's capabilities and feature set. Using Curl, easily build and deploy business-focused RIAs that integrated well with business data systems and applications.
The latest version of Curl, 6.0, which shipped late in 2007, has added beta support for running Curl applications on Mac OS X. (Curl already supports Windows and Linux.) The Curl organization also released several open-source projects for building Curl applications and integrating them with Web services. The basic Curl tools are free, and the professional tools for business use and deployment start at $12,000.
The main tool for creating Curl applications is the Curl IDE (integrated development environment), and I found it a very good, straightforward tool for creating RIAs.
Curl applications tend to work well in business and enterprise situations, as they have excellent data-handling capabilities and good information presentation features. Curl isn't as focused on animation and graphics as some other RIA platforms are, it does do a good job when it comes to data analysis and reporting graphics.
It has a well-established base of users and support, and can quickly find information and help in the developer areas of the Curl Web site.


Apple’s Sprout Core:


SproutCore is Apple's official JavaScript framework of choice for developing Rich Internet Applications. SproutCore is a JavaScript framework, being modeled after Apple's Cocca development environment. SproutCore code executes completely within a browser although Apple has already needed to hitch the SquirrelFish JavaScript Interpreter to its Safari browser to boost performance.
Many of the popular RIA effects, for example animation, require a considerable amount of graphics horsepower ,typically more than can be provided by a simple browser-JavaScript combination. Apple is late in the race , the front runners are Adobe and following by Microsoft.


Eclipse RIA plugins (UltraLightClient):


Canoo has released a new plug-in for Eclipse 3.0 that simplifies Rich Internet Application (RIA) development with the UltraLightClient (ULC) Java library. The new plug-in provides a tight ULC integration into the Eclipse IDE, enabling developers to deliver pure Java-based RIAs with unprecedented efficiency.
UltraLightClient is a library to build Rich Internet Applications (RIA) in Java. Offering a server-side programming and execution model, it is the ideal complement for the Eclipse Rich Client Platform (RCP). With this standard Java library, developers will be very effective in providing rich, responsive graphical user interfaces (GUIs) for enterprise web applications within J2EE and J2SE infrastructures. UltraLightClient builds on available developer know-how by following the Swing API, yet shields the developer from the complexities of client/server code distribution by taking care of the code split and by optimizing communication. Application releases are deployed on the server only. The user interface is handled by an application-independent Java presentation engine distributed as an applet to a browser, to Eclipse RCP, or via Java Web Start.

Open Laszlo:


OpenLaszlo is an open source platform for the development and delivery of rich Internet applications. The OpenLaszlo platform consists of the LZX programming language and the OpenLaszlo Server.
LZX programming language is an XML and JavaScript description language. LZX enables a declarative, text-based development process that supports rapid prototyping and software development best practices. It is designed to be familiar to traditional web application developers who are familiar with HTML and Javascript.
OpenLaszlo Server is a Java servlet that compiles LZX applications into executable binaries for targeted run-time environments.
Laszlo applications can be deployed as traditional Java servlets, which are compiled and returned to the browser dynamically. This method requires that the web server be running the OpenLaszlo server. Laszlo applications can be compiled from LZX into a binary SWF file, and loaded statically into an existing web page. This method is known as SOLO deployment. Applications deployed in this manner lack some functionality of servlet-contained files, such as the ability to consume SOAP web services and XML remote procedure calls.
The platform formerly known as the Laszlo Presentation Server (LPS) gave up its server-side requirement and went solo and open source in its 3.0 incarnation. Laszlo has a very similar declarative model to Flex but has a rich set of options for being hosted on the Web including the ability to support the Flash 6 player and above. The most compelling upcoming feature of Laszlo is the ability to generate Flash applications or Ajax applications from the same source code. Laszlo also support the usual round of Web services, has robust community support including a compelling integration model with RIFE. Laszlo also has a Webified feel and has been used in very large-scale Internet applications such as Pandora and Monster.com. Because it's open source, OpenLaszlo is also completely free and has no run-time licenses of any kind.


XBAP :


XBAP (XAML Browser Application) is a new Windows technology used for creating Rich Internet Applications. While windows applications are normally compiled to an .exe file, browser applications are compiled to an extension .xbap and can be run inside Internet Explorer.
Xbap applications are run within a security sandbox to prevent untrusted applications from controlling local system resources. (e.g deleting local files) .

Web 3.0

Web 3.0 is one of the terms used to describe the evolutionary stage of the Web that follows Web 2.0. The term "Web 3.0" has been introduced to hypothesize about a future wave of Internet innovation. Views on the next stage of the World Wide Web's evolution vary greatly, from the concept of emerging technologies such as the Semantic Web, ubiquitous connectivity, network computing, Distributed Databases,Intelligent Applications and advances in computer graphics will play the key role in the evolution of the World Wide Web.Web 3.0 has been described as the "executable web".

Network Computing :

Web 3.0 could be the realization and extension of the Semantic web concept. Semantic web is materialized by improving the principles of knowledge representation from Artificial Intelligence.Web 3.0 has also been linked to a possible convergence of Service-oriented architecture and the Semantic web.Web 3.0 is also called the "Internet of Services".

Distributed Databases :

Web 3.0 is the emergence of "The Data Web" as structured data records are published to the Web in reusable and remotely queryable formats, such as XML, RDF, Website Parse Template and microformats.

The recent growth of SPARQL(Simple Protocol and RDF Query Language.) technology provides a standardized query language and API for searching across distributed RDF(RESOURCE DESCRIPTION FRAMEWORK) databases on the Web. The Data Web enables a new level of data integration and application interoperability, making data as openly accessible and linkable as Web pages

Intelligent Appliations :

Web 3.0 has also been used to describe an evolutionary path for the Web that leads to artificial intelligence that can reason about the Web in a quasi-human fashion. The companies are implementing new technologies that are yielding surprising informations about latest market trends and most searched topics etc.. from mining information on Web sites.

Google uses this technoloy in its http://www.google.com/trends