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

The Archive Base Latest Questions

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

I would like to implement a very simple way to store a variable containing

  • 0

I would like to implement a very simple way to store a variable containing the last specific “CustomObject” I clicked. I’d like clicks on other objects to be ignored. Take the following sample code for example, given CustomObject extends MovieClip:

//Code within the Document Class:
var square1:CustomObject = new CustomObject();
var square2:CustomObject = new CustomObject();
var square3:CustomObject = new CustomObject();
var triangle1:DifferentObject= new DifferentObject();
square1.x=100; square2.x=200; square3.x=300;
addChild(square1);
addChild(square2);
addChild(square3);
addChild(triangle1);

//Code within the CustomObject Class:
this.addEventListener(MouseEvent.CLICK,radioButtonGlow);
public function radioButtonGlow(e:MouseEvent):void
{
    var myGlow:GlowFilter = new GlowFilter();
    myGlow.color = 0xFF0000;
    myGlow.blurX = 25;
    myGlow.blurY = 25;
    this.filters = [myGlow];
}

This works great for whenever I click on squares- they light up exactly as expected. However, I’d like to implement a functionality that:
1) Stores the last square I clicked into a variable in the document class
2) Removes the glow from all other squares when I click on another one

Any feedback is greatly appreciated!

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

    I suggest creating a class that acts as a collection of CustomObject instances and manages them in that manner (i.e. ensuring only one of that collection can be selected, etc).

    Sample:

    public class CustomCollection
    {
    
        // Properties.
        private var _selected:CustomObject;
        private var _items:Array = [];
    
        // Filters.
        private const GLOW:GlowFilter = new GlowFilter(0xFF0000, 25, 25);
    
    
        // Constructor.
        // @param amt The amount of CustomObjects that should belong to this collection.
        // @param container The container to add the CustomObjects to.
        public function CustomCollection(amt:int, container:Sprite)
        {
            for(var i:int = 0; i < amt; i++)
            {
                var rb:CustomObject = new CustomObject();
                rb.x = i * 100;
    
                _items.push(rb);
                container.addChild(rb);
            }
        }
    
    
        // Selects a CustomObject at the specified index.
        // @param index The index of the CustomObject to select.
        public function select(index:int):void
        {
            for(var i:int = 0; i < _items.length; i++)
            {
                if(i == index)
                {
                    _selected = _items[i];
                    _selected.filters = [GLOW];
    
                    continue;
                }
    
                _items[i].filters = [];
            }
        }
    
    
        // The currently selected CustomObject.
        public function get selected():CustomObject
        {
            return _selected;
        }
    
    
        // A copy of the array of CustomObjects associated with this collection.
        public function get items():Array
        {
            return _items.slice();
        }
    }
    

    Then you can revise your code in the document class to something like:

    var collection:CustomCollection = new CustomCollection(3, this);
    collection.select(1);
    

    You will need to add your own logic for the click event that deals with selecting the buttons. I suggest adding an index property to each CustomObject as well as a reference to the collection it was added to. That way, you can simply add the click event into the CustomObject class and have the handler function something like:

    private function _click(e:MouseEvent):void
    {
        _collection.select(index);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to implement a simple queueing service specific to a project. Where
I would like to implement a simple AR desktop application. This application should first
I would like to implement a distinct thread for each route in apache camel.I
I would like to implement a function with R that removes repeated characters in
I would like to implement a switch button, android.widget.Switch (available from API v.14). <Switch
I would like to implement something similar to 37Signals's Yellow Fade effect. I am
We would like to implement a web form that automatically saves content at regular
I would like to implement some Drag-select functionality into a project of mine but
I would like to implement a map simmilar to this: http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/examples/advanced_example.html One of the
I would like to implement per-directory quotas for a multi-user web application we're developing.

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.