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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:05:51+00:00 2026-05-16T08:05:51+00:00

I am trying to have the function toggleClick return powerData. I need to store

  • 0

I am trying to have the function toggleClick return powerData. I need to store powerData in a variable and have it passed to another function to do calculations.

Inside the function toggleClick, I am assigning powerData to houseArray[e.currentTarget.name.toLowerCase()];

 var powerData:int = houseArray[e.currentTarget.name.toLowerCase()];

I tried just to write return powerData–but it breaks the program.

// function toggleClick

  function toggleClick(e:MouseEvent) {

// Store "Power" Values of House Objects in Array
   var houseArray:Object = {lightA: 1, lightB: 1, lightC: 1,lightD: 1, lightE: 1,
                             comp: 2,
                             tv: 3,
                             stove: 4,
                             laundry: 5};

   // Store User Power in Variable called powerData
   // The currentTarget will equal powerData
   var powerData:int = houseArray[e.currentTarget.name.toLowerCase()];
   //return powerData;

  trace("movieClip Instance Name = " + e.currentTarget); // [object Comp]
  //trace(houseArray[e.currentTarget.name]); // comp
  trace("using currentTarget: " + e.currentTarget.name); // comp
  trace("powerData: " + powerData); // the amount of power that I clicked on
  //trace("houseArray: " + houseArray[0]); // the 0 index of house array
  trace(houseArray[e.currentTarget.name]); // currentTarget inside Array

   // how to find out which object selected

   if (e.currentTarget.currentFrame == 2)
   {
    e.currentTarget.gotoAndStop(3);
    e.currentTarget.bstate = 1;
   }

   if (e.currentTarget.currentFrame == 4)
   {
    e.currentTarget.gotoAndStop(1);
    e.currentTarget.bstate = 0;
   }

}

  • 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-16T08:05:51+00:00Added an answer on May 16, 2026 at 8:05 am

    Why don’t you have powerData defined oustside the function, the value of powerData will be updated after each click

    var powerData:int;
    
    function toggleClick(event:MouseEvent):void
    {
       powerData = houseArray[e.currentTarget.name.toLowerCase()];
    
       performCalculation();
    }
    
    function performCalculation():void
    {
        // you can use the powerData new value here
    }
    

    Or you simply pass the powerData value to your function arguments

    var powerData:int;
    
    function toggleClick(event:MouseEvent):void
    {
       powerData = houseArray[e.currentTarget.name.toLowerCase()];
    
       performCalculation(powerData);
    }
    
    function performCalculation(value:int):void
    {
        // access the new value here
    }
    

    for “return powerData” to work, your function needs to return a value of int

    
    function toggleClick(event:MouseEvent):int
    {
       return powerData;
    }
    

    but I’m not sure how that would work within your code though…

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

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Should be: $('myElementID').visible(); Note that you do not use '#'… May 16, 2026 at 3:37 pm
  • Editorial Team
    Editorial Team added an answer I would recommend that you learn using Expression Blend since… May 16, 2026 at 3:37 pm
  • Editorial Team
    Editorial Team added an answer Take a look at rack-rewrite. I bet you will be… May 16, 2026 at 3:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to have a function compare the first argument of a passed in
I am trying to have the function vbsme call another function called sad... is
I have a ticket management program that I am trying to add 'accordian' style
I have an html form. When you click the button, a javascript function adds
I have a function which takes in a font (ttf or otf file) and
I am trying to write a function to format a date and time for
I have been trying to figure out a way to convert bitmap files into
I have noticed in Java that you can have a function with object... as
I have a function that uses reflection to set properties of object A from
So, I'm trying to have same data plotted based on a drop down filter,

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.