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

  • Home
  • SEARCH
  • 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 3287888
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:32:40+00:00 2026-05-17T20:32:40+00:00

I need some help! I have no doubt this is a dumb problem that

  • 0

I need some help! I have no doubt this is a dumb problem that I’ve just over-thought to the point I got dumb about it.

I’ve got one “main” instance of a MovieClip symbol (let’s call it Mountain) with an accompanying class. In the flow of the program, I automatically generate 8 other instances of the same symbol, let’s say, each has a different fill color. When i click one of those automatically generated ones, I wanted the main instance to change color to whatever color the automatically generated one was.

So after dynamically generating the item in a different class, I added an eventListener for MouseClick

var thisMountain=new Mountain; 
thisMountain.ChangeColor();
thisMountain.addEventListener(MouseEvent.CLICK, itemClicked);
this.addChild(thisMountain);

But that’s when I realized that the eventListener had no way to tell the function it’s calling, WHICH instance of the symbol was clicked on. So I went and added the event listener into the “Mountain” class, but then it’s being called even when the main one is clicked on. So I added a boolean when the instance is created to differentiate, but that seems like awful awful coding.

So what should I do? Is that example clear? Should I just make yet ANOTHER class that extends the mountain class or something? What is the best way to go about doing this?

  • 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-17T20:32:40+00:00Added an answer on May 17, 2026 at 8:32 pm

    You could do something like:

    item1.addEventListener(MouseEvent.CLICK, itemClicked);
    item2.addEventListener(MouseEvent.CLICK, itemClicked);
    item3.addEventListener(MouseEvent.CLICK, itemClicked);
    ...
    ...
    function itemClicked(e:MouseEvent):void{
     trace((e.currentTarget as MyInstances).myColor);
    }
    

    but if you were creating the items in a separate class and didn’t know the instance, or how many were created etc. etc. You might like to look into ‘Custom Events’. Your items when clicked would fire off an event something like the following.

    var myItemClickedEvt:MyCustomEvent = new MyCustomeEvent("itemClicked", myColor);
    

    You could then listen for the “itemClicked” event and then doing something like:

    function itemClicked(e:MyCustomeEvent):void{
         trace(e.myColor);
    }
    

    … but I’m probably just confusing the situation… you probably just need:

    (e.currentTarget as MyInstances).myColor
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

need ask you about some help. I have web app running in Net 2.0.
Need some help about with Memcache. I have created a class and want to
I need some help from the shell-script gurus out there. I have a .txt
Hi I need some help with the following scenario in php. I have a
I am new to all the anonymous features and need some help. I have
I'm working with jQuery for the first time and need some help. I have
I've some questions .. and I really need your help. I have an application.
I need some help regarding algorithm for randomness. So Problem is. There are 50
I need some help with jQuery script again :-) Just trying to play with
I need some help calculating Pi. I am trying to write a python program

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.