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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:23:08+00:00 2026-05-15T19:23:08+00:00

i am using get and setters in my as3 code to edit values of

  • 0

i am using get and setters in my as3 code to edit values of an other class (because those variables are shared) i dont like to put stage.sharedVar.isScrabble in my code every time to change a variable so i used get/set functions

see below

private function get isScrabble(){return stage.sharedVar.isScrabble;} 
private function set isScrabble(val){stage.sharedVar.isScrabble = val;}  

private function get superGrid(){return stage.sharedVar.superGrid} 
private function set superGrid(val){stage.sharedVar.superGrid = val;} 

private function get gridSize(){return stage.sharedVar.gridSize} 
private function set gridSize(val){stage.sharedVar.gridSize = val}

private function get blokDefaultWidth(){return stage.sharedVar.blokDefaultWidth} 
private function set blokDefaultWidth(val){stage.sharedVar.blokDefaultWidth = val}

private function get blokDefaultHeight(){return stage.sharedVar.blokDefaultHeight} 
private function set blokDefaultHeight(val){stage.sharedVar.blokDefaultHeight = val}

as you van see it has a lot of duplicate code every time the “return stage.sharedVar.” and the “stage.sharedVar.”+ the value + ” = val” is constantly comming back.

i was wondering is there a other way of creating these get/sets?
something like?:

private function get variable1(){getValue("hisOwnFunctionName")} 
private function set variable1(val){setValue("hisOwnFunctionName")}

and so on??

thanks,
Matthy

  • 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-15T19:23:08+00:00Added an answer on May 15, 2026 at 7:23 pm

    If I understand your question, you just want to get and set multiple properties on an Object. Depending on your situation you could try:

    private function setProperty(name:Object,value:Object):void {
        stage.sharedVar[name]=value;
    }
    private function getProperty(name:Object):Object {
        return stage.sharedVar[name];
    }
    private function example():void {
        setProperty("foo","bar");
        trace(getProperty("foo")); //prints: bar
    }
    

    These functions will let you set and access the properties you want, and you wont have to keep changing the functions. It does mean that if you change superGrid to be something else, you can’t just change the function, you have to change everywhere you use the get and setProperty. But it does mean that you don’t have to keep writing new functions.

    Hope this helps.

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

Sidebar

Related Questions

i have this simple code to load data from other php page using get
Since I am using get I expect to see the submitted values appended to
Background: I recently completed a tic-tac-toe game in AS3, using some simple function-based code
What's the advantage of using getters and setters - that only get and set
Using a getter/setter in the internal code of a class instead of accessing the
I'm using mootools 1.4.3 for basic class inheritance. I'm actually converting some code from
I'm using getters and setters for creating an instance of a class. Is it
Which is the most semantically correct way to get/set variables when using OO PHP?
I'm using reflection to map getters from one class to setters in another i.e.
I am serializing a class like this into JSON using Flexjson: public class Item

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.