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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:59:33+00:00 2026-06-12T11:59:33+00:00

I wrote a class which contains a few variabes: public class myButton extends Sprite{

  • 0

I wrote a class which contains a few variabes:

public class myButton extends Sprite{
    private var button:Sprite = new Sprite();
    public var Colors:Array;
    public var gType:String = GradientType.LINEAR;
    public var mRotate:Number = 0;
    ...
}

I want to edit this variables in main file like that:

var btn:myButton = new myButton();
btn.Colors = [0xFFFFFF, 0xFFFF00];
btn.mRotate = Math.PI/2;

The sciript is running but it doesnt see the changing of these variables. I think that its a easy problem but I cant solve it.

  • 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-06-12T11:59:35+00:00Added an answer on June 12, 2026 at 11:59 am

    What you want are setter and getter functions inside your class:
    http://en.wikipedia.org/wiki/Mutator_method#Actionscript_3.0_example

    Then, in every setter you need to actually do something when the variable changes.

    Try this

    public class myButton extends Sprite{
        //....
        //note the change to private, common practice is to use lowercase first names in vars 
        //and include _ in front of private vars 
        private var _colors:Array;
        private var _mRotate:Number = 0;
        //...
    
        //getter and setter for _colors
        public function set colors(value:Array):void{
              _colors = value;
              var ct:ColorTransform = this.transform.colorTransform;
              ct.color = _colors[0]; //for simplicity I use only 1 color
              this.transform.colorTransform = ct;
        }
    
        public function get colors():Array{
             return _colors;
        }
    
        //do the same for mRotate but use the Number type
    
    }
    

    This will allow you to do

     var btn:MyBtn = new MyBtn();
     btn.colors = [...];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a System.Collections.Generic , which contains instances of a class I wrote.
I recently wrote a DLL in C# (.Net 2.0) which contains a class that
I'm trying to write a generic class which contains a generic TObjectList< T >
I wrote a JavaScript class called MyClass in which I've defined a method closeThis
I wrote a code sometime ago in which the object of ResultSet class res
I wrote a PHP CUrl Class, if i execute Methods which should return the
I've wrote an app to iterate through a directory which contains x amount of
I'm developing this time container which basically contains instances of a class called week,
i wrote an array wrapper class PersonArray which can contain objects of a certain
So assume I have one class named Program which contains my whole program 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.