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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:16:11+00:00 2026-05-23T04:16:11+00:00

I have some components declared in MXML tags, with some properties and event handlers.

  • 0

I have some components declared in MXML tags, with some properties and event handlers.
For some of them there is the need to re-instantiated, so I came up with the following architecture.

Array of components that will be re-instanciated at some poin:

<flint:forms>
    <fx:Component>
        <login:LoginForm loginClick="outerDocument.form_loginClick()" />
    </fx:Component>
    <fx:Component>
        <config:CustomizerWizard close="outerDocument.init()" />
    </fx:Component>
</flint:forms>

At some point in my controller when I need a brand new “LoginForm”:

public var form:LoginForm;
...
form = ReDo(LoginForm);

The ReDo function should look like this:

public function ReDo(classe:Class):* {

    for each (var factory:ClassFactory in forms) {
        if (factory.generator == classe) return factory.newInstance();
    }
}

But it does’t work as I would like it to. The class created by the Flex compiler for every tag its not compatible with the actual class that is declared in it.

I tried to create my own tag, but the compiler won’t let me use it in the same way that can. (Complains that it’s not a container)

Is there a way to use a custom ClassFactory class with a property that I could use in my ReDo function? Like this:

<flint:forms>
    <flint:MyComponent type="loginForm">
        <login:LoginForm loginClick="outerDocument.form_loginClick()" />
    </flint:Component>
    <flint:MyComponent type="wizard">
        <config:CustomizerWizard close="outerDocument.init()" />
    </flint:Component>
</flint:forms>

Or instead of the custom ClassFactory, try to cast/convert the ClassFactory.generator property to something that can be expected, not some random class name that it has righ now?

Edit

Instead of comparing both Class variables (which I think it’s the best aproach), I could instantiate every component in the list and compare if its the type that I want.

public function ReDo(classe:Class):* {

    for each (var factory:ClassFactory in forms) {
        var obj:* = factory.newInstance();
        if (obj is classe) return obj;
        //if (factory.generator == classe) return factory.newInstance();
    }
}

That would be the only change in my code, but isn’t it wasteful? Would GC be smart enough to cleanup all the obj’s that don’t pass the “if”?

  • 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-23T04:16:12+00:00Added an answer on May 23, 2026 at 4:16 am

    If you make events buddle and move handlers a level higher:

    addEventListener(LoginEvent.LOGIN_CLICK, ...);
    addEventListener(WizardEvent.CLOSE, ...);
    

    then you can write basically:

    <flint:forms>
        <login:LoginForm id="loginForm" />
        <config:CustomizerWizard id="wizard" />
    </flint:forms>
    

    And then:

    public function ReDo(classe:Class):* {
        return new classe();
    }
    

    Another (and more correct) approach is using a separate factory function for each component:

    public function createLoginForm():LoginForm {
        var loginForm:LoginForm = new LoginForm();
        loginForm.addEventListener(LoginEvent.LOGIN_CLICK, ...);
        return loginForm;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some components ( alpha controls ) I can install them to Delphi
I have a following problem trying to compile some components in XE2. These components
I have been tasked with refactoring some components that used xmlbeans to now make
I have a question about laying out some swing components. Say, I have a
I have a web application on ASP.NET (C#) that has some precompiled components. I've
I have several C# projects along with some internal library components that I'm trying
i have several common elements (components), that will generate some html. it seems my
i have JavaScript components, that has following architecture: var MyComponent = function(params) { setup(params);
I have some common components that are always present in every page served by
I have some open source components used in different projects. And some times it

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.