Flex Error #1009: Cannot access a property or method of a null object reference (update)

A couple of years ago I wrote a post discussing the Flex error #1009 (cannot access a property or method of a null object reference). If you’ve done any serious amount of Flex coding I’m sure you’ve run into this error a number of times.

While there are a few possible causes, the post discussed how a lack of understanding of the Flex component creation lifecycle could be a possible culprit. While everything in the post is still technically accurate (for Flex 3) I find that I often just use bindings if I need to set a property of a child component.

So… here’s the fourth way to solve the problem (at least for simpler use cases).

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">


			public var buttonLabel:String;

	<mx:Button id="button" label="{ buttonLabel }"/>


I realize this is pretty obvious to most Flex programmers, I just wanted to clarify for people who are new to Flex and are finding the old post.

6 thoughts on “Flex Error #1009: Cannot access a property or method of a null object reference (update)”

  1. TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.core::UIComponent/drawFocus()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9416]
    at com.hillelcoren.components.autoComplete.classes::FlowBox/handleFocusIn()[C:\dev_workspace\YmcoLibrary\src\com\hillelcoren\components\autoComplete\classes\FlowBox.mxml:63]

    I’m using the AutoComplete everywhere and with no problems. I have a popup form that uses the AutoComplete and always throws this error. I literally have the exact same code elsewhere with no issues (not a popup);

    1. I think you’ll need to extend the component (or use the source) and modify the handleFocusIn function in AutoComplete.mxml to check if focusManager is null.

      1. protected function handleFocusIn( event:FocusEvent ):void
        if(event.relatedObject != null)
        if (event.relatedObject && contains( event.relatedObject ))
        if(focusManager != null)
        if (focusManager.getFocus() == _inlineButton)


        I don’t think this is enough. Why would focusManager be null? Another instance of this component just failed. Completely frustrating. This instance is not on a popup, and no code has changed. I am using the source as well, not the swc.

  2. “Flex Error #1009: Cannot access a property or method of a
    null object reference (update) Hillel Coren”
    was a great posting, can’t help but wait to examine even more
    of your postings. Time to waste a little time online lmao. Thanks for your effort -Winnie

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s