Adobe, webGL and HTML5

I had written a blog post for my company website, please check the link:

http://www.xoriant.com/blog/javascript-2/web-graphic-library-and-html5.html

Flash ActionScript – getURL in AS3

Flash ActionScript

After a long time I am writing something…during my project I found out something interesting in Flash and JavaScript function. This will be useful for people with basic knowledge in Actionscript. So let’s discuss it here.

First we will discuss about the difference between AS2 and AS3 script on Flash button. Previously in AS2 it’s very easy to write script on Flash button.

AS2 script on Flash button:

on(release){

//Write your action

trace(“Button has been pressed”);

}

And function should be like this (this should be placed on the keyframe of timeline (make actionscript layer) :

function myFunction(){

//Write your action

trace(“Hello”); //write trace option

}

Above example was quiet easy with AS2, now let’s see same example with AS3:

Important point to remember is that in AS3 you can’t write script on button. Just write it on keyframe in timeline (make actionscript layer). And give instance name to your button e.g. HelloButton. Now write the button script on keyframe of timeline:

AS3 script for Flash button:

HelloButton.addEventListener(MouseEvent.CLICK, myFunction);

Here, we have use button name i.e. HelloButton. And a function i.e. myFunction

In AS3 function is written as:

function myFunction (event:MouseEvent):void{

                trace(“Hello”);

}

In above function, remember to add “event:MouseEvent” and “:void” as compare to AS2, which tells that on which mouse event this function should execute.

Now let’s discuss about simple script of “getURL”. Previously it was easy to open a webpage on click of a Flash button. You just need to put this script on Flash button. See example:

on(release){

                //getURL(“http://www.google.com”, _blank);

                }

After clicking this button it will open an http://www.google.com link in new window.

But now if you just put this script on Flash button and publish HTML, you will find that it’s not working….don’t worry this is just a simple glitch within your HTML…….try to find out this param tag…in HTML:

<param name=”allowScriptAccess” value=”always”/>

Make sure that….value=”always”….if you want to run getURL script on Flash button….Now your Flash button works perfectly in HTML.

Now learn something interesting, capture Flash button event in Javascript of HTML page. Check AS2 and AS3 versions:

AS2 version:

On Flash button write this script:

on(release){

               getURL(“javascript:myfunction()”);           

}

In above script, “myFunction()” is a javascript function which is present in HTML.

In HTML, where you are going to run this Flash button, just write javascript function “myFunction()” in <body> section. Check this:

JavaScript Function in HTML

<script language=”JavaScript”>

function myfunction(){

alert(“Hello World”);       

}

In the object tag for the SWF file in the containing HTML page, set the following parameter:

<param name=”allowScriptAccess” value=”always” />

Now check above scenario in Actionscript 3:

AS3 version:

import flash.external.ExternalInterface;

Instead of “getURL”, in AS3 we should use “ExternalInterface” classes. For more details check link: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html

import flash.events.Event;

HelloButton.addEventListener(MouseEvent.CLICK, myFlashFunction);

Above code is for Flash button with instance name: “HelloButton”, and when someone press this button it execute “myFlashFunction”(JavaScript function).

 

function myFlashFunction (e:Event):void{

     ExternalInterface.call(“myfunction”, HelloButton.name);

};

myFlashFunction is a Flash function which runs javascript function(i.e. myfunction) in HTML file.

 

And in HTML, place this javascript function:

<script language=”JavaScript”>

function myfunction(){

alert(“Hello World”);       

}

In the object tag for the SWF file in the containing HTML page, set the following parameter:

<param name=”allowScriptAccess” value=”always” />

 

Now run HTML file in Internet Explorer (browser). And when you press Flash button in SWF file in the containing HTML page, javascript code catch the Flash button event. This way you can catch any Flash event in javascript and use for many purposes. Hope this will be helpful for those who want to understand basic event catching with JavaScript from Flash.

3D support in new Flash Player

adobe_alternativa_racingI was reading different articles on internet about the new technologies in Multimedia field. During this I come across an interesting piece of information which I feel is interesting to you all. This is about the ‘alternativaplatform’ which is a Flash-3D-engine i.e. Alternativa3D.

‘Alternativa3D’ is developed by a Russian company which is working on this platform for more then 10 years(as they claim ), and cooperating close with Adobe and working in pre-release groups, and participate in developing of new Flash Player versions.

‘Alternativa3D’, which is intended for displaying 3D graphics in the Flash Player environment. You can use this technology in wider areas such as 3D websites to multiplayer browser games and applications for social networks in full 3D.

Alternativa3D version 7 has been widely used in the architectural and building sector, interior design and internet advertising. They are also providing servers for online gaming. AlternativaCore is a cluster of several Linux-powered Java servers. It is a ready to use core for creating real-time and turn-based multiplayer online games. This client-server solution helps in version control, high speed data transfer, load balancing  system, store unlimited amount of data, faster and easier development of games, allows expansion, decreases expenses, support payment systems, social networks support etc. For more details just visit: http://alternativaplatform.com/en/alternativa3d/

The best thing is that Alternativa3D is free of cost, so just download it and explore the possibilities. But one thing to remember, you need to have a good understanding of Actionscript 3 and Flash.

Actually Adobe Flash team is working on technologies which make possible to create and play 3D games through Adobe Flash Player. Adobe team is working on a new set of 3D GPU accelerated APIs that delivers advanced 3D rendering in Flash Player and AIR. This API codename is ‘Molehill’. For more information just visit this link: http://tv.adobe.com/watch/adc-presents/molehill-3d-apis/