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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:09:50+00:00 2026-05-24T21:09:50+00:00

Is it possible to make a dynamic class in AS3 only accept dynamically created

  • 0

Is it possible to make a dynamic class in AS3 only accept dynamically created properties if they’re a given type?

For example, I may only want Sprites to be allowed. So take this quick example class:

public dynamic class Test extends Object{}

——-

And a few quick lines to get an idea of what I mean:

var test:Test = new Test();

test.something = 32; // error
test.something = "party hats"; // error
test.something = new Sprte(); // works

Maybe using the proxy class/namespsace there’s a way to manipulate whatever is run when creating variables dynamically?

  • 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-24T21:09:50+00:00Added an answer on May 24, 2026 at 9:09 pm

    The Test class:

    package classes {
        import flash.display.Sprite;
        import flash.utils.Proxy;
        import flash.utils.flash_proxy;
    
        public dynamic class Test extends Proxy {
            private var _properties : Object;
    
            public function Test() {
                _properties = new Object();
            }
    
            override flash_proxy function getProperty(name : *) : * {
                return _properties[name];
            }
    
            override flash_proxy function setProperty(name:*, value:*):void {
                if (!(value is Sprite)) throw new Error("No Sprite given: " + value);       
                _properties[name] = value;
            }
        }
    }
    

    The App:

    package classes {
        import flash.display.Sprite;
    
        public class TestTest extends Sprite {
            public function TestTest() {
                var test:Test = new Test();
    
                try {
                    test.something = 32; // error
                } catch (e : Error) {
                    trace (e);
                }
    
                try {
                    test.something = new Sprite(); // works
                } catch (e : Error) {
                    trace (e);
                }
    
                trace (test.something);
            }
        }
    }
    

    The output:

    Error: No Sprite given: 32
    [object Sprite]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to make a method return a dynamic List type. Such as
Is it possible to make a generic class that acts as a dynamic array
I am wondering whether it is possible to make dynamic variables in Java. In
Is it possible to make the following bar() method return blue? class TestClass {
Is it possible to make the schema name dynamic in a BIRT query. I
Is it possible make some handler that will do something when user shutdown computer
Possible Duplicate: Make iPhone app paid version replace free version on install from app
is possible to make own help message or attach own event on help option
How is it possible to make prototype methods in C#.Net? In JavaScript, I can
Is it possible to make a site with ASP.NET MVC Framework using .NET 2.0?

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.