Archive for the ‘Flash’ Category

11
Mar

XML connector and Data binding tutorial soon

Posted By Tarek in Flash Tutorials

Hello,

Expect a new hot tutorial about XML connector and Data binding soon…

These two are among the least known and understood, they however are truely time saving and extremely powerful.

It will be up within two or three days.

Regards

12
Feb

The bottlenecks of developping a desktop application using Flash and a wrapper

Posted By wassim in Flash

Flash is nice, eyecatching, fun for games and web intro and navigation as well as e-learning and a couple other stuff…

Building a desktop application with Flash is however a different story.

Of course you’ll need a “wrapper” around your swf to allow it to communicate with the file system to write to the hard disk, connect to a database and similar common programming tasks.

Choosing a “wrapper” is a hard task as you need to assess the stability/functionality of each and what you can and cannot do reliably with each.

Moreover, each wrapper, and I really mean each!, has its set of known bugs that you’ll have to discover and learn to workaround or to live with…

After seriously digging in each of the available commercial wrappers out there, I’ve found the following:

- There is no “best in the market” for every functionality.
- There is no “has all you need” either
- They use different objects/methods rendering the usage of a combination of them a pain.
- They are all more or less unstable/buggy.
- They do not have their own IDE, so don’t expect any serious debugging involving stepping the code or setting breakpoints or the like.
- They do not support all types of DLLs, especially .Net Dlls.

In conclusion, making a productive/stable program is not an area where flash wrappers excell, They can be used to makes smalll screen mates or eye candies or the like but not serious programs, not for the time being at least…

29
Dec

External Interface class

Posted By wassim in Flash, Flash Tutorials

This new addition to ActionScript is a very wanted feature, older versions of flash scripting language relied completely on fscommand to comunicate with the flash ocx container, fscommand is very limited in functionality, the new externalInterface is much more versatile.

Let’s consider the following scenario, you want to get the type of browser the user is using and to adjust certain properties of your flash movie accordingly, there is no flash command that does just that, however there is one in javascript.

So the job now is to code a simple function in javaScript and call it from flash, flash should be able to call the function and to get the return value of it.

That’s where externalInterface jumps in.

Here’s a fast code snipet:

In javaScript:

[js]
function tellFlash(){
var n=navigator.appName;
return n;
}

[/js]

now n holds the name of the navigator we want to know, in flash we will call this javascript function and we’ll get the return value n, assign the n held text as the text of a dynamic text box, here’s the code that does that:

[as]

import flash.external.ExternalInterface;// we start by importing the class

btn.onPress = function() {

txt.text = ExternalInterface.call(“tellFlash”, “”);

};

[/as]

and that’s about it!

Now what if we want to do the opposite? i.e call an ActionScript function from the container , from javascript for example, how do we do that?

Easy, we register a flash function as callable using the code:

[as]

ExternalInterface.addCallback(“methodName”, instance, method);

[/as]

where:

methodName:String – The name by which the ActionScript function can be called from JavaScript. This name does not need to match the actual name of the ActionScript method.

instance:Object – The object to which this resolves in the method. This object is not necessarily the object on which the method can be found — you can specify any object (or null).

method:Function – The ActionScript method to be called from JavaScript.

to show this in action, I’ve placed a small red rectangle on top of the swf and wrote the following code:

ExternalInterface.addCallback(“obey”, null, obey);
function obey() {
square._visible =false;
}

so whenever javascript calls the function obey, the red rectangle whose instance name is “square” will simply disappear since the function obey() does just that, see the code below:

function obey() {
square._visible =false;
};

one last step, the javascript that will call this actionscript function from:
function callExternalInterface() {
thisMovie(“externalInterfaceExample”).obey();
}

And that’s all it takes.

I’ve added a more advanced sample where javascript prompts you for input then sends the input text back to flash.

Click here to see a sample swf showing externalInterface in action.

5
Dec

External Communication Tutorial

Posted By wassim in Flash, Flash Tutorials

Annoucement: Expect an external communication tutorial soon

Hello, the externalInterface class is going to be the topic of the next tutorial to be posted decembre 10.

So stay tuned :)

24
Nov

Diacritics stripper (Remover) tutorial.

Posted By wassim in Flash, Flash Tutorials

Hello and salam;

I have been working onthis project for a couple of hours now and I thought I should share with you my findings since I tried searching the internet and found nothing at all in this area, what I am trying to show you is how to remove Arabic diacritics from Arabic text dynamically in Flash using ActionScript.

Now what I am about to explain is not an undocumented feature, a hidden API or some sort of a hack, it’s simply my approach to solve this problem. In fact this method will work in flash player version 5 and up.

This method for removing Arabic diacritics is based on the charCode and fromCharCode methods of the String class in ActionScript.

The thing is, all Arabic specific diacritics have an AScii char code between 1611 and 1618, Arabic characters as you might know are double bytes characters and thus each character is represented by two bytes instead of one as it is the case of latin characters.

So in pseudocode, this is how to remove the diacritics dynamically:

- start by storing all the charcodes of the input text in an Array. You will have to make a for loop for that to grab them using the charCodeAt method of the String class.

- loop through the Array and check the charcodes, if a charcode is between 1611 and 1618 just omit it, store the results in a new Array.
- loop through the purified Array and convert the charcodes back to characters using the fromCharCode method, store the results in yet a new Array.

- Finally , joing the elements of the last array and voila!

Below is a sample of the diacritics remover actionscript in action.

Diacritics Stripper