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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:03:02+00:00 2026-05-19T01:03:02+00:00

Hello i have a function as following: private function seatClickHandler(e:MouseEvent):void{ var check:Check = new

  • 0

Hello i have a function as following:

private function seatClickHandler(e:MouseEvent):void{

            var check:Check = new Check();
            if(e.target.contains(check)){
                e.target.removeChild(seat);
            }else{
                e.target.addChild(check);
            }
        }

basicly i want to check if e.target contains a child called check. If it does i want e.target to remove the child, else i want to add the child. But the method i tried doesnt seem to work although i think this is the way to go. Any suggestions?

  • 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-19T01:03:03+00:00Added an answer on May 19, 2026 at 1:03 am

    When you declare your Check object, Actionscript creates a reference code for that specific object.

    So the first time your code is run, your Check object could be given a reference of @c0ecc29. Your if statement checks to see if @c0ecc29 is a child component of target. It won’t be, so the Check object with reference @c0ecc29 is added to target.

    The second time the clickHandler is called, a new instance of the Check object is created which will have a new reference id. Your target has the original Check object with the @c0ecc29 reference so it won’t get removed.

    The correct way to get this working depends on what target is (DataGrid, Group, etc.).

    EDIT:
    Based on your comments, I would try something like this. It checks to see if the Check object is a child of target and adds it if needed. Then when the Check object is clicked, it will toggle its visibility.

    public var check:Check = new Check();
    
    private function seatClickHandler(e:MouseEvent):void
    {
      if(!e.target.contains(check))
      {
        check.addEventListener(MouseEvent.CLICK, check_handleClick);
        e.target.addChild(check);
      }
    }
    
    protected function check_handleClick(event:MouseEvent):void
    {
      check.visible = !check.visible;
    }
    

    If you need to actually remove the Check object from target instead of just changing its visibility, you could try this:

    public var check:Check = new Check();
    
    private function seatClickHandler(e:MouseEvent):void
    {
      if(!e.target.contains(check))
      {
        e.target.addChild(check);
      }
      else
      {
        e.target.removeChild(check);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i have this following function: ... var model = $(#carModel); .... model.change(validModel); function
Hello I have a following formvalidatior function in my document. function formValidator(formid) { var
Let's say I have some simple Javascript like: <script> var hello = function(){ alert(Hello
I have some function taht is caller periodically: var func = function() { alert('Hello
Hello friends I have the following script in my Template: window.addEvent('domready', function () {
Say I have the following: class C { private $f; public function __construct($f) {
Hello I have the following function that is NOT working at the moment.. What
Hello I have the following code: Javascript/jQuery: $(document).ready(function() { $(.clickMe).click(function() { $(.textBox).toggle(); }); });
Hello I have written the following code. My objective was to write a function
I have a following code which works fine MsgBox(AddSomething(Of String)(Hello, World)) Public Function AddSomething(Of

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.