ReferenceError: Error #1065: Variable is not defined.

ReferenceError: Error #1065: Variable item 1 is not defined.

The problem is that a variable is not defined. But it does not tell you where. You have to follow the method stack or do a search for the variable since no line number is given. In my case there were no curly braces around the dataprovider string array in the DataGrid. Using a string array without curly braces actually works in a List component but when using a DataGrid an error is thrown. See below.

// incorrect in List (but works)
	< mx:List id="list1" dataProvider="['item 1','item 2','item 3']">
// correct
	< mx:List id="list1" dataProvider="{['item 1','item 2','item 3']}">

// incorrect in DataGrid (does not work)
	< mx:DataGrid id="grid1" dataProvider="['item 1','item 2','item 3']">
// correct
	< mx:DataGrid id="grid1" dataProvider="{['item 1','item 2','item 3']}">

Another case where you must define the id in curly braces:


CHANGE the dataProvider to this and it will work:


Please leave a comment if this has helped you or not. Also check out the error search application.

This entry was posted in Flex. Bookmark the permalink.

4 Responses to ReferenceError: Error #1065: Variable is not defined.

  1. Here is my rant. Why can’t they just build some more stuff into there as3 parser to check out why the variable is undefined.
    Also, the most common cause of this error is simply not declaring a class public in a cs3 as3 package. Read more about Error 1065 here.

  2. Hi…

    It probali will work, but how i do that when the dataProvider of my DataGrid is a external XML?


  3. Judah says:

    @Andrew – The new version of Flex Builder 3 (in beta at the time of this writing) has better debugging support.

    @Felipe – Check out the examples for populating a datagrid from xml on this lame article at

  4. Kusha waghmare says:

    i got this error: ReferenceError: Error #1065: Variable SomeclassName is not defined.
    this basically occurs when you won’t append public before the class.

Leave a Reply

Your email address will not be published. Required fields are marked *

Wrap your code before posting! Click the links below: