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 8209955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:54:40+00:00 2026-06-07T09:54:40+00:00

I have a class that I made to control all my buttons from a

  • 0

I have a class that I made to control all my buttons from a centralized location. The buttons are pushed into an array on load and a for loop adds a MouseEvent.CLICK event listener to all the buttons in the array.

Now my problem comes in with the function tied to this event listener. I have created a switch statement

function btnclick(e:MouseEvent):void
    {
        switch (e.currentTarget)
        {
            case Profile_btn_63 :
                removearrayreference(this);
                e.currentTarget.parent.gotoAndStop("profile");
                break;

        }
    }

but the problem is when I test the game it states Profile_btn_63 is undefined. Which is actually true at the very beginning(first frame) as the button hasn’t been added to the button array yet nor has an event listener been placed on it. So to get to the point I need help with making flash ignore that Profile_btn_63 is undefined until it eventually does get defined.

Finally this may be somewhat off topic but does anyone know why _63 is added to the end of Profile_btn when it is pushed into my button array?

  • 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-06-07T09:54:42+00:00Added an answer on June 7, 2026 at 9:54 am

    If you’re going to have a “magic switch statement” that does everything in your program – which is a horrible idea in more than one way, but that is a different matter – then you should make the case decisions based on the instance name: switch( e.currentTarget.name )

    While a button instance may be null or undefined, a constant String never is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that handles events from a WinForms control. Based on what
This is a C++ class that I have made with n number of pointers.
I made a music class that will play a song. I have made onResume
I have a custom-made view that extends the View class. I would like 2
I have class that represents users. Users are divided into two groups with different
I have a class that I instantiate to save or load xml data. For
I have a custom WPF control that I made a couple of days ago:
I have class that extend FragmentActivity in it I add fragment to layout as
I have class that looks like this: class A { public: class variables_map vm
I have class grades that I need to check if a specific grade is

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.