Solved

Flex 2 "Access of undefined property" Error.

Posted on 2007-04-04
3
2,944 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

734 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