Archive for the ‘Flex (RIA)’ Category

How to transfer Array within an Object to JavaScript using External Interface ?

November 4th, 2011 by aabhaanjan
Here is an example :
Flex Side :
<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application
xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:mx=”library://ns.adobe.com/flex/mx”
xmlns:s=”library://ns.adobe.com/flex/spark”>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:Script><![CDATA[
import flash.external.*;
public function callJavaScriptFunction():void {
var msg:String;
if (ExternalInterface.available) {
var _obj:Object = new Object();
_obj.fname = “Aava”;
_obj.lname = “Rani”;
_obj.familly = new Array(‘RP’,’AK’,’SK’,’BK’);
msg = ExternalInterface.call(‘receiveComplexDataTypes’, _obj);
} else {
msg = “Not available”;
}
}
]]></fx:Script>
<s:Button label=”Send Data” click=”callJavaScriptFunction()”/>
</s:Application>
HTML Side :-
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>
<head>
<title>Complex Data and ExternalInterface Example</title>
<script type=”text/javascript” src=”swfobject.js”></script>
<script type=”text/javascript”>
var swfVersionStr = “0”;
var xiSwfUrlStr = “”;
var flashvars = {};
var params = {};
params.quality = “high”;
params.bgcolor = “#ffffff”;
params.allowscriptaccess = “sameDomain”;
var attributes = {};
attributes.id = “ComplexDataExternalInterface”;
attributes.name = “ComplexDataExternalInterface”;
attributes.align = “middle”;
swfobject.embedSWF(
“ComplexDataExternalInterface.swf”, “flashContent”,
“100%”, “100%”,
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
</script>
</head>
<SCRIPT LANGUAGE=”JavaScript”>
function receiveComplexDataTypes(object) {
var str = (“The Data values are :- ” + object.fname + ” \n and :-” + object.lname + “!”);
for (i=0; i<object.familly.length; i++) {
str +=  i + “: ” + object.familly [i] + “\n”;
}
alert(str);
return “successful”;
}
</SCRIPT>
<body>
<div id=”flashContent”/>
</body>

Here is an example :

Flex Side :

[xml]

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”>

<s:layout>

<s:HorizontalLayout/>

</s:layout>

<fx:Script><![CDATA[

import flash.external.*;

public function callJavaScriptFunction():void {

var msg:String;

if (ExternalInterface.available) {

var _obj:Object = new Object();

_obj.fname = “Aava”;

_obj.lname = “Rani”;

_obj.familly = new Array(‘RP’,’AK’,’SK’,’BK’);

msg = ExternalInterface.call(‘receiveComplexDataTypes’, _obj);

} else {

msg = “Not available”;

}

}

]]></fx:Script>

<s:Button label=”Send Data” click=”callJavaScriptFunction()”/>

</s:Application>

[/xml]

HTML Side :-

[xml]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>

<head>

<title>Complex Data and ExternalInterface Example</title>

<script type=”text/javascript” src=”swfobject.js”></script>

<script type=”text/javascript”>

var swfVersionStr = “0”;

var xiSwfUrlStr = “”;

var flashvars = {};

var params = {};

params.quality = “high”;

params.bgcolor = “#ffffff”;

params.allowscriptaccess = “sameDomain”;

var attributes = {};

attributes.id = “ComplexDataExternalInterface”;

attributes.name = “ComplexDataExternalInterface”;

attributes.align = “middle”;

swfobject.embedSWF(

“ComplexDataExternalInterface.swf”, “flashContent”,

“100%”, “100%”,

swfVersionStr, xiSwfUrlStr,

flashvars, params, attributes);

</script>

</head>

<SCRIPT LANGUAGE=”JavaScript”>

function receiveComplexDataTypes(object) {

var str = (“The Data values are :- ” + object.fname + ” \n and :-” + object.lname + “!”);

for (i=0; i<object.familly.length; i++) {

str +=  i + “: ” + object.familly [i] + “\n”;

}

alert(str);

return “successful”;

}

</SCRIPT>

<body>

<div id=”flashContent”/>

</body>

[/xml]

Tags: , , , , , , , ,

How to transfer complex data to JavaScript using External Interface ?

November 4th, 2011 by aabhaanjan

Here is an example :
Flex Side :
[java]
<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application
xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:mx=”library://ns.adobe.com/flex/mx”
xmlns:s=”library://ns.adobe.com/flex/spark”>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:Script><![CDATA[
import flash.external.*;

public function callJavaScriptFunction():void {
var msg:String;
if (ExternalInterface.available) {
var _obj:Object = new Object();
_obj.fname = “Aava”;
_obj.lname = “Rani”;
msg = ExternalInterface.call(‘receiveComplexDataTypes’, _obj);
} else {
msg = “Not available”;
}
}
]]></fx:Script>

<s:Button label=”Send Data” click=”callJavaScriptFunction()”/>

</s:Application>
[/java]
HTML Side :-
[xml]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>
<head>
<title>Complex Data and ExternalInterface Example</title>
<script type=”text/javascript” src=”swfobject.js”></script>
<script type=”text/javascript”>
var swfVersionStr = “0”;
var xiSwfUrlStr = “”;
var flashvars = {};
var params = {};
params.quality = “high”;
params.bgcolor = “#ffffff”;
params.allowscriptaccess = “sameDomain”;
var attributes = {};
attributes.id = “ComplexDataExternalInterface”;
attributes.name = “ComplexDataExternalInterface”;
attributes.align = “middle”;
swfobject.embedSWF(
“ComplexDataExternalInterface.swf”, “flashContent”,
“100%”, “100%”,
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
</script>
</head>

<SCRIPT LANGUAGE=”JavaScript”>
function receiveComplexDataTypes(object) {
alert(“The Data values are :- ” + object.fname + ” \n and :-” + object.lname + “!”);
return “successful”;
}
</SCRIPT>

<body>
<div id=”flashContent”/>
</body>
</html>
[/xml]

Tags: , , , , , , , , , ,

ExternalInterface and Flex

November 3rd, 2011 by aabhaanjan
ExternalInterface and Flex :
The ExternalInterface API enables a communication between SWF and JavaScript.
Here is an simple example :

The ExternalInterface API enables a communication between SWF and JavaScript.

Here is an simple example :

Flex Side :

[xml]<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”>

<s:layout>

<s:HorizontalLayout/>

</s:layout>

<fx:Script>

import flash.external.ExternalInterface;

public function callASFunction():void {

var msg:String;

if (ExternalInterface.available) {

msg = ExternalInterface.call(‘javaScriptFunction’,’ Communication between JS and App done’);

} else {

msg = “Not available”;

}

}

</fx:Script>

<s:Button label=”Show Output” click=”callASFunction()”/>

</s:Application>[/xml]

Html side :

[xml]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<!– saved from url=(0014)about:internet –>

<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>

<head>

<title>ExternalInterface Example</title>

<script type=”text/javascript” src=”swfobject.js”></script>

<script type=”text/javascript”>

var swfVersionStr = “0”;

var xiSwfUrlStr = “”;

var flashvars = {};

var params = {};

params.quality = “high”;

params.bgcolor = “#ffffff”;

params.allowscriptaccess = “sameDomain”;

var attributes = {};

attributes.id = “ExternalInterfaceExample”;

attributes.name = “ExternalInterfaceExample”;

attributes.align = “middle”;

swfobject.embedSWF(

“ExternalInterfaceExample.swf”, “flashContent”,

“100%”, “100%”,

swfVersionStr, xiSwfUrlStr,

flashvars, params, attributes);

</script>

</head>

<SCRIPT LANGUAGE=”JavaScript”>

function javaScriptFunction(msg) {

alert(msg);

return “successful”;

}

</SCRIPT>

<body>

<div id=”flashContent”/>

</body>

</html>

[/xml]

Tags: , , , , , , , , , , , , , ,

Application development phases in Flex 4.5

November 2nd, 2011 by aabhaanjan
We can divide it in following phases :
1.Design phase
This is the phase where we decide about the reusability of code, interaction with enivironment and
also choose the design patterns such MVC. We anyalze the architectural issues.
2.Configure phase
This is the phase where we decide the configurations for example flex sdk, crossdomain,serverside settings etc.
3.Build phase
Building the application have again three process:
a) Compile:compiling the application converts the application files and assets into a single SWF file.
where we select the compiling options etc.
b) Debug
Flex provides several tools for debugging :
AIR Debug Launcher (ADL) A command line version of the Adobe® AIR™ debugger for outside use.
Flash Player:
Flash Builder visual debugger
Flex Command-line debugger A command line version of the debugger  for outside use.
c) Test
4.Deploy phase
This is the phase where we deploy our application in form of swf etc.
5. Secure phase
This is the phase where we put the security concerns by .
Using the security features built into Flash Player
Building security into the application

We can divide it in following phases :

1.Design phase

This is the phase where we decide about the reusability of code, interaction with enivironment and also choose the design patterns such MVC. We anyalze the architectural issues.

2.Configure phase

This is the phase where we decide the configurations for example flex sdk, crossdomain,serverside settings etc.

3.Build phase

Building the application have again three process:

a) Compile:compiling the application converts the application files and assets into a single SWF file.   where we select the compiling options etc.

b) Debug

Flex provides several tools for debugging :

AIR Debug Launcher (ADL) A command line version of the Adobe® AIR™ debugger for outside use.

Flash Player:

Flash Builder visual debugger

Flex Command-line debugger A command line version of the debugger  for outside use.

c) Test

4.Deploy phase

This is the phase where we deploy our application in form of swf etc.

5. Secure phase

This is the phase where we put the security concerns by .

Using the security features built into Flash Player

Building security into the application

Tags: , , , , , , , , , , , , , ,

What is new in Flex 4.5 ?

November 1st, 2011 by aabhaanjan

There are major these areas where the new Flex SDK 4.5 has changed the way of working of its earlier version.

1.Development for the multiple platform.

2.Improved Spark components.

3.Improvement in video and text.

4.improvements in Adobe Flex 4.5 SDK compiler

Lets continue with the detail of these points :

1.Development for the multiple platform :

The new SDK is providing us an opportunity to develop application for multiple platform such as Android, iOS and

the web using our existing knowledge of Flex.

2.Improved Spark components.

There are lots of improvement in Spark Component which are more optimized. For example :

a)Spark DataGrid : Providing i) easy and straightforward visual customization. ii)Improved rendering, scrolling and interactive performance system

b)Spark Form :Improved and much more flexible layout with customization options.

c)Spark Image and BitmapImage: There is a lot of enhancements in Image and BitmapImage of Spark like scaleMode, caching etc.

d)Spark Formatters: With lots of feature the new Spark formatter is with the SDK. New Sort and SortField classes have been added.

e)Spark Validators: Enhancement in Spark Validators.

3.Improvement in video and text.

a) Upgraded OSMF Libraries adds support for HTTP streaming.

b) Upgraded TLF library, adding some new features like floats and bulleted and numbered lists.

4.improvements in Adobe Flex 4.5 SDK compiler

There are three major improvements:

a) Reducing memory consumption for full builds.

b) Reducing compilation time for full and incremental builds.

c) Improving the compiler’s RSL linking logic.

will discuss it in detail in our next articles.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , ,

Starling -Gaming with 2D hardware rendering

October 13th, 2011 by aabhaanjan

The Straling:
What is Starling ? :-
a)Starling is an ActionScript 3 2D framework developed based on the Stage3D APIs
b)Starling for the desktop in Adobe Flash Player 11 and Adobe AIR 3.
c)Starling is specially designed for the game development
d)Starling makes it possible to write fast GPU accelerated applications without having to touch the low-level Stage3D APIs.
e)Starling is designed for ActionScript 3 developers, especially those involved in 2D game development.
f) Starling is lightweight, flexible and easy to use.

will discuss few tutorials soon.

Future of New Media

October 13th, 2011 by aabhaanjan

I am developer of all these four platform :

a) Native iOs

b) Android

c)Flash/Flex

d) HTML5

On the basis of my experience in these technologies I would like to share my views about Future of New Media.

I found few Facts about the wide area presence of Flash Player from the various online resources :

75% of all video on the web is viewed with Flash Player.
Flash Player is on 99% of all connected PCs.
85 % of 100 top websites use Flash
95% of top 20 phone OEMs will deliver Flash

so what is the present of flash in New Media Space :
1. Already grown a lot.
2. Still growing.
3. Have a large foot print in the sector of media,game etc.

And what is the future:
1. The new version will come as the replacement of fastly growing Unity3D.
2. The new version with a great performnace feature like hardware rendering will change the
gaming industry and mobile world.
3. In future Flash will be the cheapest medium to develope game/app or video for all platform with its great performance.
4. The Adobe AIR3 going to make a great presence in the field of television and desktop app world.
The Stage Video having :
a)smoothest, highest quality, seamless video
b)lowest CPU usage, longest battery life
c)optimized for multi-screen: PC, smartphone, tablet, television
d)reaching also out to low-end PC devices

All the best Adobe :)🙂