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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:16:53+00:00 2026-05-16T18:16:53+00:00

this code is written in simple ActionScript, but i’m assuming this problem of mine

  • 0

this code is written in simple ActionScript, but i’m assuming this problem of mine would occur in all languages that have boolean datatypes.

i’m simply clicking the stage so that my boolean variable reverses its value and than traces/prints/logs it’s new value. however, it’s always tracing true instead of switching between true and false for each mouse click.

what am i doing wrong?

var myBool:Boolean;

stage.addEventListener(MouseEvent.CLICK, mouseClickHandler);

function mouseClickHandler(evt:MouseEvent):void
    {
    changeBoolean(myBool);
    }

function changeBoolean(boolean:Boolean):void
    {
    boolean = !boolean;
    trace(boolean);
    }
  • 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-16T18:16:54+00:00Added an answer on May 16, 2026 at 6:16 pm

    You are passing a value to the function, not the reference. This means that boolean value inside your changeBoolean function is copied from myBool variable so when you changed it inside the function, it didn’t realy change myBool variable. There are basically two solutions to this:

    1. change the function to not accept parameters and inside it change myBool variable or
    2. change the function so that it returns the boolean parameter and on calling the function, set the myBool valu to the result of the function
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a beginner in Python and I have written this simple code but
I have written this code outside all functions: int l, k; for (l =
Hey everyone. I've written this simple function that is supposed to load a portion
I have this code sample (written by someone else) that parses the website, and
This code written as it is in a simple page generates an [object] as
I have written this simple c code in microsoft visual c++ 2010. #include<stdio.h> #include<conio.h>
I have written a simple utility that loops through all C# files in my
I have this code written in jQuery to have a simple on hover slide
I have written a simple log4net wrapper. I was wondering whether this wrapper code
Below, I have written simple code that re-creates problems that have emerged as my

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.