Solved

Flex 2 "Access of undefined property" Error.

Posted on 2007-04-04
3
2,928 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

757 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

22 Experts available now in Live!

Get 1:1 Help Now