A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: listen for dispatchEvent and run a function?

  1. #1
    Senior Member
    Join Date
    Apr 2000
    Location
    Minneapolis
    Posts
    2,127

    listen for dispatchEvent and run a function?

    Hi,
    if I have a class I load,
    import com.pixelator;//import explosion class

    In my movie I want to run a function when it finishes and dispatches the event below. How do I do that?

    here is the code from the class
    PHP Code:
    function completeHandler() {
                    
    dispatchEvent(new Event("PIXELS_DONE"));

    thanks mark

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You'll want to add a listener to the instance of the class or movieclip dispatching the event.

    PHP Code:
    myInstance.addEventListener("PIXELS_DONE"onPixeslDone);

    function 
    onPixelsDone(e:Event):void{
      
    //handler code


  3. #3
    Senior Member
    Join Date
    Apr 2000
    Location
    Minneapolis
    Posts
    2,127
    it might be more complicated than I thought
    here is where I set up the class, and what I tried
    PHP Code:
    var pixelExplosion:pixelator = new pixelator(menu_mc);
    addChild(pixelExplosion);
    pixelExplosion.explode();

    //then I end it and try to listen for the end

    pixelExplosion.retract();

    pixelExplosion.addEventListener("PIXELS_DONE"finished);

    function 
    finished(e:EVENT):void{
        
    trace("pixels imploded");

    I got these errors which refer to tweenmax which pixelator uses.

    this one refers to the listener line
    1046: Type was not found or was not a compile-time constant: EVENT.

  4. #4
    Member
    Join Date
    Jun 2008
    Posts
    34
    Shouldn't it be:

    function finished(e:Event):void{ ...









    http://www.maniacworld.com/are-you-g...ish-strong.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center