Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 445651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:23:32+00:00 2026-05-12T21:23:32+00:00

Update: Modified title to better reflect my question Hi everybody :) My question today

  • 0

Update: Modified title to better reflect my question

Hi everybody 🙂

My question today revolves around a CustomEvent I’m trying to send from one sub Class to another.

I’ve used my CustomEvent class to pass an event from a sub Class to my main class fine, but I’m not sure who to do that between sub classes.

My Custom Event Class

package src.events {
import flash.events.Event;

public class CustomEvent extends Event 
{
    public static const CHANGE:String="onChange";
    public static const COMPLETE:String="onComplete";
    public static const IMAGE_LOADED:String="onImageLoaded";
    public static const SWF_LOADED:String="onSWFLoaded";
    public static const SWF_UNLOAD:String="onSWFUnload";
    public static const CLICK:String="onClick";
    public static const PAUSE_MOVIE:String="onPause";
    public static const INTRO_CLICKED:String="introClicked";

    public var params:Object;

    public function CustomEvent(type:String, params:Object, bubbles:Boolean = false, cancelable:Boolean = false)
    {
        super(type, bubbles, cancelable);
        this.params=params;
    }

    public override function clone():Event 
    {
        return new CustomEvent(type, this.params, bubbles, cancelable);
    }

    public override function toString():String 
    {
        return formatToString("CustomEvent","params","type","bubbles","cancelable");
    }

}

Sub Class INTRO – dispatches event

package src.display {

import gs.easing.*;
import gs.TweenLite;
import flash.text.*;
import flash.events.*;
import flash.display.*;
import flash.geom.Matrix;
import flash.geom.ColorTransform;

// ☼ ----------------------------------------- Imported Custom Classes
import src.events.CustomEvent;

// ☼ ----------------------------------------- Intro Class
public class Intro extends Sprite 
{
    private var playBtn:MovieClip;

    // ☼ ----------------------------------------- Constructor
    public function Intro():void 
    {
        this.addEventListener(Event.ADDED_TO_STAGE, init);
    }

    // ☼ ----------------------------------------- Init
    public function init(event:Event):void 
    {
        draw();
    }

    public function draw():void 
    {           
        playBtn = new PlayThumb;
        playBtn.buttonMode = true;
        playBtn.x = 582;
        playBtn.y = 259;
        playBtn.alpha = 1;

        addChild(playBtn);

        playBtn.addEventListener(MouseEvent.MOUSE_UP, clicked);
    }

    private function clicked(e:MouseEvent):void 
    {
        trace("clicked big play");
        dispatchEvent (new CustomEvent(CustomEvent.INTRO_CLICKED, {}));
        trace("event = "+CustomEvent.INTRO_CLICKED);
    }

}

Sub Class NAVIGATION – where I’m listening for the event
Need to call this function inside of the Navigation class:

function introPlayButtonClick(e:CustomEvent):void
        {
            trace("introPlayButtonClick called");

            TweenLite.to(buttons[0], 1, {y:20, ease:Strong.easeOut});
            TweenLite.to(buttons[1], 1, {y:navBtnY, ease:Strong.easeOut});
            TweenLite.to(introTab, 1, {y:60, ease:Strong.easeOut});
            TweenLite.to(scrollerMov, 1, {y:60, ease:Strong.easeOut});
            $btn1 = true;
            $btn2 = false;

            trace("introPlayButtonClick called --- end");
        }

Ok so I believe my problem lies in the Navigation Class, how do I correctly add the addEventListener here? I’m not getting any of the traces in my introPlayButtonClick function.

How it worked in my Main class with the PAUSE_MOVIE event, was I attached the eventListener to the Navigation class via the variable name nv:

nv.addEventListener("onPause", pauseMovie); // Inside of MAIN class

But since I’m adding the event listener inside of the Navigation class for the INTRO_CLICKED event I thought all I needed was (this.) added, but so far I’m not getting that event to trigger.

Any ideas, tips, thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:23:33+00:00Added an answer on May 12, 2026 at 9:23 pm

    I used public static var so I could reference the Class I was trying to call a function in directly, instead of using event dispatchers.

    First part:
    Navigation class

    public class Navigation extends MovieClip
    {
        private var // where I put many private vars
        private var intro:Intro;
        public var // where I put many public vars
        public static var instance:Navigation;
    
    
        // ☼ --------------------------------- Constructor
        public function Navigation():void
        {
            instance = this; //<- so I can reference this Class from another
            //other code
    

    Intro class button action:

    private function clicked(e:MouseEvent):void 
        {
            trace("clicked play -> launch function in Navigation");
            Navigation.instance.introPlayButtonClick(); //Class targeted
        }
    

    Now I can from inside the Intro class, call this function in my Navigation class:

    public function introPlayButtonClick():void
        {               
            TweenLite.to(buttons[0], 1, {y:20, ease:Strong.easeOut});
            TweenLite.to(buttons[1], 1, {y:navBtnY, ease:Strong.easeOut});
            TweenLite.to(introTab, 1, {y:60, ease:Strong.easeOut});
            TweenLite.to(scrollerMov, 1, {y:60, ease:Strong.easeOut});
            $btn1 = true;
            $btn2 = false;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Modified title and added update. UPDATE : We no longer believe this is
UPDATE: Based on suggestions here, I've modified my code. To get a handle on
Update: Is there a way to achieve what I'm trying to do in an
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
Update : This is no longer an issue from C# 6, which has introduced
Update : I found almost exact similar question , yet it has slightly different
SELECT items.item_id, items.category_id, items.title, items.description, items.quality, items.type, items.status, items.price, items.posted, items.modified, zip_code.state_prefix, zip_code.city, books.isbn13,
Not exactly how sure how to title this question, so I hope the title
EDIT : You're not allowed to have the word question in the title. Q-mark
I have an entityframework entity called ABC (attributes ID and Title). On update record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.