Adobe Dreamweaver Forums



Last 10 THreads :         Flash-PHP Mail Form (Last Post : kglad - Replies : 3 - Views : 4 )           »          Flash Controls Not Displaying in Embedded File (Last Post : kglad - Replies : 5 - Views : 6 )           »          DW Flash Encoder (Last Post : wycn - Replies : 2 - Views : 3 )           »          navigation bar (Last Post : G. Rex - Replies : 5 - Views : 6 )           »          Adobe Flash 10 kills Wimpy (Last Post : ClubEXL.com - Replies : 82 - Views : 955 )           »          static sound (Last Post : 21n9 - Replies : 10 - Views : 11 )           »          flash loader reappears after movie plays (Last Post : kglad - Replies : 4 - Views : 5 )           »          Flex compiler in FlexBuilder and Flex SDK (Last Post : 2009 Matt - Replies : 4 - Views : 5 )           »          Is file too large? (Last Post : kglad - Replies : 1 - Views : 2 )           »          Embed files in a projector (Last Post : Sean Wilson - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 12-03-2008, 09:33 AM
xtempore
 
Posts: n/a
Diggs:
Default Class returning null

I was working on my code, busily making changes when suddenly I started to get
the following error...

"Cannot access a property or method of a null object reference"

The weird thing is that this is occurring when calling a static function of a
class. As far as Flex is concerned my class now has a value of null.

The class is called "Global", and it contains a variety of static functions,
static constants and static variables. It's been working fine for months but
suddenly it has broken and I'm tearing my hair out trying to figure out why.

I tried doing a trace to see what's going on ("Setting" us also a class)....

trace(Setting);
trace(Glb);

... returns ...

[class Setting]
null

WTF? How can a class be null? I wondered it I had somehow messed up and had
a line like Global=null, but I tried that and it wouldn't even compile.

Anyone got any ideas?

Could it me the internal load order of the packages? If so how do I change
that to make sure Global loads first?

Help!!!!!

Please!




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-03-2008, 01:03 PM
John Hall
 
Posts: n/a
Diggs:
Default Re: Class returning null

Doesn't it drive you crazy when you feel like you're working backwards? I
wonder if using the preinitialize event on the application to instantiate the
class would help to ensure its existence upon applicationComplete. Though, if
it's been working for months, gotta wonder if there's a conflict somewhere. I
assume you did a Project > clean.

Reply With Quote
  #3 (permalink)  
Old 12-03-2008, 04:23 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Class returning null


"xtempore" <webforumsuser@macromedia.com> wrote in message
news:gh5je1$e18$1@forums.macromedia.com...
>I was working on my code, busily making changes when suddenly I started to
>get
> the following error...
>
> "Cannot access a property or method of a null object reference"
>
> The weird thing is that this is occurring when calling a static function
> of a
> class. As far as Flex is concerned my class now has a value of null.
>
> The class is called "Global", and it contains a variety of static
> functions,
> static constants and static variables. It's been working fine for months
> but
> suddenly it has broken and I'm tearing my hair out trying to figure out
> why.
>
> I tried doing a trace to see what's going on ("Setting" us also a
> class)....
>
> trace(Setting);
> trace(Glb);
>
> ... returns ...
>
> [class Setting]
> null
>
> WTF? How can a class be null? I wondered it I had somehow messed up and
> had
> a line like Global=null, but I tried that and it wouldn't even compile.
>
> Anyone got any ideas?
>
> Could it me the internal load order of the packages? If so how do I
> change
> that to make sure Global loads first?


A lot of times static methods can't operate on instance variables and vice
versa.


Reply With Quote


  #4 (permalink)  
Old 12-03-2008, 06:32 PM
levancho
 
Posts: n/a
Diggs:
Default Re: Class returning null

[q]Originally posted by: Newsgroup User

"xtempore" <webforumsuser@macromedia.com> wrote in message
news:gh5je1$e18$1@forums.macromedia.com...
>I was working on my code, busily making changes when suddenly I started to
>get
> the following error...
>
> "Cannot access a property or method of a null object reference"
>
> The weird thing is that this is occurring when calling a static function
> of a
> class. As far as Flex is concerned my class now has a value of null.
>
> The class is called "Global", and it contains a variety of static
> functions,
> static constants and static variables. It's been working fine for months
> but
> suddenly it has broken and I'm tearing my hair out trying to figure out
> why.
>
> I tried doing a trace to see what's going on ("Setting" us also a
> class)....
>
> trace(Setting);
> trace(Glb);
>
> ... returns ...
>
> [class Setting]
> null
>
> WTF? How can a class be null? I wondered it I had somehow messed up and
> had
> a line like Global=null, but I tried that and it wouldn't even compile.
>
> Anyone got any ideas?
>
> Could it me the internal load order of the packages? If so how do I
> change
> that to make sure Global loads first?


A lot of times static methods can't operate on instance variables and vice
versa.


[/q]
IMHO, regardless of circumstances
class reference should never bee null, that just sounds plain wrong,from any
angle ,

Reply With Quote
  #5 (permalink)  
Old 12-03-2008, 07:23 PM
myIP
 
Posts: n/a
Diggs:
Default Re: Class returning null

[Q]Could it me the internal load order of the packages?[/Q]

It could very well be. But I would suspect that it would return undefined
instead of null. Just like if you were to access an RSL before it was loaded.
At any rate, you can change the Build Order by navigating to:

Windows> Preferences...> General> Workspace> Build Order

Reply With Quote
  #6 (permalink)  
Old 12-03-2008, 09:53 PM
xtempore
 
Posts: n/a
Diggs:
Default Re: Class returning null

After much cursing of Flex, I finally realised what my mistake was. Needless
to say a more helpful error would have been nice.

Many of the static vars in Global are set in the initialization. One of them,
which instantiated an object, caused a circular reference back to Global. This
is what caused the problem.

It is still strange though that it did not generate a run-time error in the
initialization code rather than later when I referenced the class.

Thanks to everyone who replied.

Reply With Quote


  #7 (permalink)  
Old 12-03-2008, 09:53 PM
levancho
 
Posts: n/a
Diggs:
Default Re: Class returning null

myIP,
I have to disagree,with fact that it can be import order ...
IMHO, if in OOP, class reference existence is dependent on an import sequence
that's pretty bad, also not sure how build order in flex is related to Class
refference not being available,unlees there are more than one swf projects
... its gotta be something else ,

Reply With Quote
  #8 (permalink)  
Old 12-04-2008, 03:53 PM
myIP
 
Posts: n/a
Diggs:
Default Re: Class returning null

I never disagreed that it could of been the build order. If the OP was using
SWCs in the form of RSLs (Runtime Shared Libraries) or SWFs (for bootstrapping
a Flex app) then build order could very well have been a culprit, as you stated
in your last post.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:30 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk