Solved

Flex 2 "Access of undefined property" Error.

Posted on 2007-04-04
3
2,934 Views
Last Modified: 2009-12-04
Flex 2 "Access of undefined property" Error.

I can't figure out why I'm getting this error...

Main app Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >

<mx:Script>
      <![CDATA[
            import dto.Example;
            
            [Bindable]
            public var tempExample:Example = new Example();
            tempExample._id = "test";
            
            
      ]]>
</mx:Script>

</mx:Application>



Class Code: (File saved in "dto" folder off application root)
package dto
{
      public class Example{
            
            public var _id:String;
            
            public function Example(){
                  
            }
            
      }
}

0
Comment
Question by:jpilz
3 Comments
 
LVL 4

Accepted Solution

by:
teddysetiawan earned 500 total points
ID: 18855531
<![CDATA[
            import dto.Example;
           
            [Bindable]
            public var tempExample:Example = new Example();
            tempExample._id = "test";   // you can't do this , as property/method must be change in function
           
           
      ]]>

---- Must understand that <![CDATA[]]>  tag is a class


so your code should be

<![CDATA[
            import dto.Example;
            import mx.controls.Alert;
           
            [Bindable]
            public var tempExample:Example = new Example();
           
            public function init():void{
                  tempExample._id="asdalsdhashdjha";
                  Alert.show(tempExample._id);
            }
                       
      ]]>


------------------------------------------------------------------------------
I change a little bit , just copy and paste the code



<?xml version="1.0" encoding="utf-8"?>
<mx:Application
      xmlns:mx="http://www.adobe.com/2006/mxml"
      layout="absolute"
    creationComplete="init()">

<mx:Script>
      <![CDATA[
            import dto.Example;
            import mx.controls.Alert;
           
            [Bindable]
            public var tempExample:Example = new Example();
           
            public function init():void{
                  tempExample._id="TEST";
                  Alert.show(tempExample._id);
            }
           
           
      ]]>
</mx:Script>

</mx:Application>



It will pop up an Alert Message "TEST"


0
 
LVL 4

Expert Comment

by:danieldear
ID: 18918964
 tempExample.var _id = "test";
i think so
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now