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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:50:28+00:00 2026-06-05T22:50:28+00:00

I am new to Flex (got assigned to maintain an old project at work)

  • 0

I am new to Flex (got assigned to maintain an old project at work) and am having some trouble getting data binding to work correctly. I have a popup form class, AddOffer.mxml which uses a model AddOfferModel.as. On my popup form, I have the following component:

    <mx:FormItem label="{getResource('addOffer.form.OFFER_DATE')}:"
        labelWidth="90">
        <views:OfferWindowDatesFragment 
            id="offerWindowField" 
            start="{model.offerStartDate}"
            stop="{model.offerStopDate}" />
    </mx:FormItem>

My AddForm.mxml file also has some embedded actionscript where I define my ‘model’ variable:

    [Bindable]
    public var model:AddOfferModel;

The model variables I am trying to bind to are standard getters/setters and look like this inside AddOfferModel.as:

    [Bindable]
    public function set offerStartDate(val:EditableInstant):void
    {
        _offerStartDate = val;
    }
    public function get offerStartDate():EditableInstant
    {
        return _offerStartDate;
    }
    private var _offerStartDate:EditableInstant;


    [Bindable]
    public function set offerStopDate(val:EditableInstant):void
    {
        _offerStopDate = val;
    }
    public function get offerStopDate():EditableInstant
    {
        return _offerStopDate;
    }
    private var _offerStopDate:EditableInstant; 

Inside the OfferWindowDatesFragment component class, the start and stop variables look like this:

    [Bindable]
    public function set start(val:EditableInstant):void
    {
        _start = val;
    }
    public function get start():EditableInstant
    {
        return _start;
    }
    private var _start:EditableInstant;


    [Bindable]
    public function set stop(val:EditableInstant):void
    {
        _stop = val;
    }
    public function get stop():EditableInstant
    {
        return _stop;
    }
    private var _stop:EditableInstant;

Basically, I just want to bind the start and stop variables in my OfferWindowDatesFragment class to the offerStartDate and offerStopDate variables in the AddOfferModel.as file. Whenever I access the start/stop variables in functions inside the OfferWindowDatesFragment class, they are null.

I have an event listener function that gets triggered in OfferWindowDatesFragment anytime a user selects a new date, it looks like this:

    private function changeOfferDate():void
    {
        start.currentValue = offerDateEditor.start;
    stop.currentValue  = offerDateEditor.stop;
    }

Every time I reach this function, it throws up an error because ‘start’ and ‘stop’ are both null … but should have been initialized and bound already. If I look at the variables in the debugger, I can confirm that values on the right side of the assignment expression are valid, and not what is causing the error.

I am not real familiar with how initialization works in Flex, and I assumed as long as I instantiated the component as seen in the first code snippet at the top of my post, it would initialize all the class variables, and setup the bindings. Am I missing something? Perhaps I am not properly initializing the model or class data for AddForm.mxml or AddFormModel.as, thereby binding null references to the start/stop fields in my OfferWindowDatesFragment class?

Any help would be greatly appreciated. Thanks!

EDIT:

I looked into this further and tried using Mate to inject the ‘model’ variable inside AddOffer.mxml with a valid AddOfferModel object:

    <Injectors target="{AddOffer}" debug="{debug}">
        <ObjectBuilder generator="{AddOfferModel}" constructorArguments="{scope.dispatcher}" cache="local"/>
        <PropertyInjector targetKey="model" source="{lastReturn}" />
    </Injectors>

I load the AddOffer.mxml dialog as the result of a button click event on another form. The function that pops it up looks like this:

    public function addOffer():void
    {
        var addOfferDialog:AddOffer = new AddOffer();

        addOfferDialog.addEventListener("addOffer", addOfferFromDialog);

        modalUtil.popup(addOfferDialog);
    } 

It doesn’t seem to be assigning anything to the ‘model’ variable in AddOffer.mxml. Does loading a view/dialog this way not trigger an injection from Mate by chance? (I realize this last part might belong in the Mate forums, but I’m hoping somebody here might have some insight on all of this).

  • 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-05T22:50:29+00:00Added an answer on June 5, 2026 at 10:50 pm

    In AddOffer.mxml, you have this code:

    [Bindable]     
    public var model:AddOfferModel;
    

    Is there something outside AddOffer.mxml that is setting this to a valid AddOfferModel? There should be. The nature of how the Flex component life cycle means that you can expect that things may be null at times as a View builds. So you should build your components to be able to “right themselves” after receiving bad data, if the data eventually comes good.

    Data binding is one way to do this, but it may not paper over everything depending on what else is going on.

    Have you verified that the model value you’re getting is not null at the point where the user selects the date and that its offerStartDate and offerEndDate properties have been populated with valid EditableInstants? If both of those are correct, I’d start looking for pieces of the Views that expect to have stuff at a given instant and then don’t recover if it is provided later.

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

Sidebar

Related Questions

I got a new project. and some part of it, Flex was exist. <mx:
I've got a Java/Flex project that I'm building using Maven. After doing some research
I am trying to build a pure as3 project in flex and I got
I am quite new to Flex (virtually got tossed into it...lol). I am trying
I am new to Flex development. I got an error when i tried to
I'm totally new to Adobe Flex Builder 3. I've been assigned a fully functional
I've got a Flex 3 datefield like this: <mx:DateField id=myDateSelector selectableRange={{ rangeStart : new
I am working on an existing project in Flex, and got tripped up for
In Flex builder 3 when I create a new flex application targeting the flex
I'm new to flex , so forgive me if this is a dumb question.

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.