Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom event does not reach caller
    text
    copied!<p>I made a custom event that's supposed to be fired when a specific function within a class is executed. I listen for this event from within my main script, frame one of my timeline. See the code to understand my question a bit better.</p> <p>My CustomEvents.as</p> <pre><code>package { import flash.events.Event; public class CustomEvents extends Event { public static const PAGE_EMPTY:String = "Page Empty"; public function CustomEvents(type:String) { super(type); trace("hello from within the event class!"); } } } </code></pre> <p>The function within FRONT_PAGE.as that dispatches the event</p> <pre><code>public function exitPage(){ dispatchEvent(new CustomEvents(CustomEvents.PAGE_EMPTY)); var mainLinkExitMove:Tween = new Tween(mainLink, "y", Strong.easeOut, mainLink.y , -150, 3, true); var gridExitMove:Tween = new Tween(grid, "y", Strong.easeOut, grid.y , -150, 3, true); } </code></pre> <p>And finally the code that calls the above function, and listens for the returned event. frontPage is an object of the FRONT_PAGE.as class, declared earlier in the code.</p> <pre><code>function gotoSubPage(){ frontPage.exitPage(); frontPage.addEventListener(CustomEvents.PAGE_EMPTY, ef_FrontPageFinishedExiting); function ef_FrontPageFinishedExiting(event:CustomEvents){ trace("Event has been caught"); } } </code></pre> <p>I know I am reaching the CustomEvents constructor, as the trace within it gets printed. The problem is it seems like the event does not reach the function caller?</p> <p>I was unable to find good examples of how to use simple custom events, so this is how I think it's supposed to be. What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload