PDA

View Full Version : 1119: Access of possibly undefined property. Annoying. :)


oniell121
09-16-2009, 07:47 PM
Hey there, I'm constructing a couple classes to go along with my FLA. One is establishing a system for *gasp* emulation of Global Vars. The other is importing the global vars class, loading a XML file, then after the load is complete, runs a function that defines several vars inside of the global vars class. However, I am running into an issue when I try to run the class that defines that vars and loads the XML. It's difficult to describe, but the error it gives is

weather.as; line 26;

1119: Access of possibly undefined property target through a reference with static type Class.



Any ideas why it's complaining about my event target? I am attached the FLA, and both AS classes I've constructed. Background is that this is going to be a page that displays some information published by my weather station as XML. The FLA doesn't do anything right now except try to trace a defined var from MyWeather.as.

oniell121
09-17-2009, 12:30 AM
Soo...any ideas?

sydd_hu
09-17-2009, 01:50 AM
Event is a Class type variable, not an instance of Event.
youll need something like this:

function onLoaded(e:Event):void{
xml = new XML(e.target.data);
var il:XMLList = xml.PARAM;
MyWeather.temp = il.temp.text();
var time = il.time.text();
}

trace e.target.data to see if its not null
(note: i havent tested it, got no Flash installed)

oniell121
09-17-2009, 01:54 AM
Alright thanks. I'll try that in just a sec. I figure it was something along those lines, but I could not for the life of me find out what it needed to be.

sydd_hu
09-17-2009, 02:02 AM
btw a listener function (the one you assign with addEventListener)
always needs to have a parameter of type Event (or its subclasses like MouseEvent, ResizeEvent,...)

oniell121
09-17-2009, 02:07 AM
Ieven knew that. But man-o-man it just completely left my mind!