Archive for December, 2005

Access Modifiers in ActionScript 3.0

The Basic Access Modifiers are

  1. internal
  2. private
  3. public
  4. protected

internal is the default access modifier which is used if no other modifier is specified. It allows internal access and package-level access. Unlike in ActionScript 2.0 where it was treated as public, internal is not public but internal by default in ActionScript 3.0.

private is strictly private in ActionScript 3.0. Private is the most restrictive access modifier. It only allows internal access to members and it does not allow package-level access nor access from subclasses.

public is the least restrictive access modifier and thus allows access from anywhere.

protected allows internal access to members and access from subclasses but restricts package-level access.
(more…)

Unique, Random, Serial Movies, Image Loader

While doing a randomizer for our splashes, we decided to get this out to the public and make it open for people to use it. This is a Flash SWF or an Image Loader spiced with the ability to load a default SWF or a random/serial from a list listed in an xml nodes.

The SWF/Image Unique, Random, Serial Loader will try to load an SWF or an Image either randomly or in a serial order. In order to get to the next or a random SWF, the mother Splash looks up for the splashes with the method splashDone();. Thus all splashes will need to called the method _parent.splashDone() for this example to work. In the case of an Image, it is considered single frame and thus the method is automatically called. One may be able to customize the SWFs or the images in the splash.xml available in the download.

The SWF is published to version 6 to attain high compatibility with browser-flash-plugins. Coded in ActionScript 2.0 and adorned with Model View Presenter pattern. Well, you might as well look at it as a simple MVP sample.
(more…)

Flash Player 8 – ExternalInterface

Pre Flash Player 8 Era

In the times before the dawn of the Flash Player 8, Flash-Javascript communication, interaction was done with methods like, SetVariable and GetVariable. The technique however is not that browser-proof in some cases, and is a bit slow too. Nonthless, with the release of the Flash Javascript Integration Kit, it makes it possible to somehow seamlessly communicate between Flash and JavaScript. You can call JavaScript functions from Flash, and ActionScript functions from JavaScript.

In the time of Flash Player 8

Then, came Flash Player 8 and specifically ExternalInterface class; flash.external.ExternalInterface which extends Object. Now the entire approach of Flash-Javascript communication is realizing to a new awakening. The ExternalInterface enables straightforward communications between ActionScript and the Flash Player’s contrainer (for instance, the HTML page with Javascript or a C#, C++ or a Java wrapper). We can safely say that the olden days method of FSCommand() is replaced.

ActionScript – JavaScript

  • to invoke custom ActionScript functions from JavaScript and vice versa and that too with a much cleaner API
  • pass primitive (number, boolean, string) or complex (array, object, etc) data between ActionScript and JavaScript
  • function calls are synchronous and makes you feel as if you are invoking the functions withing same scripting engine (if you invoke a JavaScript function from ActionScript you get the return values instantly, same is true if you invoke ActionScript function from JavaScript).
    (more…)