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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:02:37+00:00 2026-05-24T10:02:37+00:00

I want to make a clicked function that recognized the item being click, is

  • 0

I want to make a clicked function that recognized the item being click, is that possible? Could you teach me ?^^

Here is my try, but It didn’t work:

package  {

import flash.display.MovieClip;
import flash.events.MouseEvent;


public class main extends MovieClip {
    private var _s1:s1Mc;
    private var _s2:s2Mc;


    public function main() {
        _s1=new s1Mc();
        this.addChild(_s1);
        _s2=new s2Mc();
        this.addChild(_s2);

        _s1.addEventListener(MouseEvent.CLICK,ClickedF(_s1));
        _s2.addEventListener(MouseEvent.CLICK,ClickedF(_s2));
    }
    public function ClickedF(e:MouseEvent,$varMc:MovieClip)
    {
        if($varMc==_s1)
        trace("_s1");
        if($varMc==_s2)
        trace("_s2");
    }
}

}

Here is the Errors:

F:\test\click test\main.as, Line 18 1067: Implicit coercion of a value of type s1Mc to an unrelated type flash.events:MouseEvent.
F:\test\click test\main.as, Line 18 1136: Incorrect number of arguments.  Expected 2.
F:\test\click test\main.as, Line 19 1067: Implicit coercion of a value of type s2Mc to an unrelated type flash.events:MouseEvent.
F:\test\click test\main.as, Line 19 1136: Incorrect number of arguments.  Expected 2.

I understand that I should set 2 things inside the ClickedF of addEventListener but I really don’t know how to do it T_T

  • 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-24T10:02:39+00:00Added an answer on May 24, 2026 at 10:02 am

    You can only have one argument in an event handler, but the Event object that comes in has a property currentTarget, which is that object that dispatched the event.

    public function main() {
        _s1=new s1Mc();
        this.addChild(_s1);
        _s2=new s2Mc();
        this.addChild(_s2);
    
        _s1.addEventListener(MouseEvent.CLICK,ClickedF);
        _s2.addEventListener(MouseEvent.CLICK,ClickedF);
    }
    public function ClickedF(e:MouseEvent)
    { 
        if(e.currentTarget==_s1)
        trace("_s1");
        if(e.currentTarget==_s2)
        trace("_s2");
    }
    

    Also, by convention you should start your function names with a lowercase character. Only Class names should start with an uppercase character. This makes your code easier for others to understand, because by convention ClickedF looks like you are passing a reference to a class, not a function. When working in a team of developers sticking to these standards is essential for productivity and is usually a workplace requirement, so it’s best to get into the habit now.

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

Sidebar

Related Questions

I want to make an entity that has an autogenerated primary key, but also
I want to make a div that expands to reveal its content when clicked.
Here's a little jQuery function that does what I want when a checkbox is
I want to make a script that disables hyperlinks and instead fires a function
I want to make a splash screen, which cannot be clicked/selected by mouse/UI. As
I want make datetimepicker in my project. Using jquery how it is possible? I
I want to make an etag that matches what Apache produces. How does apache
I want to make a table in SqlServer that will add, on insert, a
Here is my jQuery code: <script type=text/javascript> //<!-- $(document).ready(function() { $('input[type=submit]').click(function() { $.ajax({ type:
I have a div id overlay that I want to make visible when the

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.