logo

Custom Event in actionscript 3

logo

Adding custom event in as3 can make life easy. Sometime it needs to set root variable from different class or need to call root function for a specific application. Its better to use custom event than using "root" in class. Its easy to trigger and also can be listen from anywhere. Its make a class independent. Creating custom event handlers in ActionScript 3 is pretty much simple. Here i’m showing a simple myCustomEvent class which extends the flash Event class.

   1: //Declare a class for myCustomEvent
   2: package wneeds.events{
   3:     
   4:     import flash.events.Event;
   5:  
   6:     public class myCustomEvent extends Event {
   7:         
   8:         public var myMessage:String;
   9:         
  10:         public function myCustomEvent(msg) {
  11:             
  12:             super("myCustomEvent");
  13:             myMessage = msg;
  14:         }
  15:     }
  16: }

In the above class i also declare a variable named "myMessage" to show how to pass variable in a custom event class. For triggering the custom event, it just need to include the class and use the dispatchEvent method as like below…

   1: //How to asign a event
   2: import wneeds.events.myCustomEvent;
   3:  
   4: dispatchEvent(new myCustomEvent("Hello ..."));

Now time to add Listener to listen the event from anywhere….

   1: //How to add the listener for the myCustomEvent..
   2:  
   3: this.addEventListener("myCustomEvent", showMessage);
   4:  
   5: function showMessage(e:myCustomEvent):void {
   6:     trace(e.myMessage);
   7: }

In various purpose its better to pass object. Because in object its easy to pass multiple properties and easy to write in json format.

   1: dispatchEvent(new myCustomEvent({name:'tma',height: 100, msg : 'Hello...'}));

Then it can be easily possible to get all the properties from the listener…. :)

Some links on flash help

logo

Some of my friends want to learn flash. They are searchig for web address where they can found help. So my friends don’t worry here are some flash help sites.. click any and get ur one..


“eXtplorer” a cool PHP- and JavaScript- based File Manager

logo

I saw many ajax or javascript based work but i really became fan of “eXtplore”.Its not only a file manager for local files but also a web-based ftp application.

Its cool interface and simple animations are awesome. I am pleased with its amazing Features. No doubt its really brilliant , ausum!!!!

eXtplore

Features:

  • browse directories & files on the server and
  • edit, copy, move, delete files,
  • search, upload and download files,
  • create and extract archives,
  • create new files and directories,
  • change file permissions (chmod) and much more..
  • Create and Extract Archives (ZIP, Tar, Tar/GZ, Tar/BZ)
  • User Management with different permission levels like “View only” or “Edit” and “Admin”
  • Available as a component for Joomla! and Mambo.

For more information please visit : http://extplorer.sourceforge.net/


Flash multiple file uploader

logo

You need to upload multiple files at once? Are you searching for java applet script for multiple file uploading? Why not going with flash? Here, I have a solution with flash ….

I know Flickr, solved this problem with a downloadable desktop application. But Most Others used Java applets. But i think flash is very simple for multiple file upload. I have used flash 8 to do the job…

smartupload preview

Demo : http://www.apueee.com/smartupload/

Download: http://www.apueee.com/downloads/smartuploader (downloaded 3744 times)

Features:

1. Multiple file selection option

2. Multiple file selection when upload on progress

3. Multiple progressbar for files

4. Its possible to remove a file from the file list even when upload on progress

5. Standard interface

6. Custom javascript function can be used after upload files.

7. Reset Option to use it again

Features Coming Soon:

1. ActionScript 2.0 to ActionScript 3.0 Migration

2. Post/Get data sending from the html

3. Flash Error message control from the javascript

4. Getting Error message from server side script

6. Custom interface setting

7. Support for all Browser.

Comments and suggestions are most welcomed :)


Page 2 of 3«123»
logo
Powered by Wordpress | Designed by Elegant Themes
5 visitors online now
5 guests, 0 members
Max visitors today: 5 at 04:41 am GMT+8
This month: 9 at 03-11-2010 05:20 pm GMT+8
This year: 46 at 01-15-2010 12:41 am GMT+8
All time: 51 at 10-22-2009 08:26 am GMT+8