# Using mx.core.Application.application.url in a class

**URL:** <https://forum.kirupa.com/t/using-mx-core-application-application-url-in-a-class/238905>\
**Category:** flash\
**Created:** [September 17, 2007, 1:39am UTC](https://forum.kirupa.com/t/using-mx-core-application-application-url-in-a-class/238905 "2007-09-17T01:39:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamermans](https://avatars.discourse-cdn.com/v4/letter/k/8797f3/32.png) [@kamermans](https://forum.kirupa.com/u/kamermans)\
**Post date:** [September 17, 2007, 1:39am UTC](https://forum.kirupa.com/t/using-mx-core-application-application-url-in-a-class/238905/1 "2007-09-17T01:39:09Z")

</div>

I have a VERY simple class that does not work and I would like to know why. Here it is:

**[SIZE=2][COLOR=#9900cc]package [/COLOR][/SIZE]**[SIZE=2]Test{[/SIZE][LEFT]  
[LEFT]**[SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE]**[SIZE=2] mx.core.Application;[/SIZE][/LEFT]

[LEFT]**[SIZE=2][COLOR=#0033ff] public[/COLOR][/SIZE]\*\*\*\*[SIZE=2][COLOR=#9900cc]class[/COLOR][/SIZE]**[SIZE=2] Environment{[/SIZE][/LEFT]

[LEFT]**[SIZE=2][COLOR=#0033ff] private[/COLOR][/SIZE]\*\*\*\*[SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE]**[SIZE=2] CurrentURL:String;[/SIZE][/LEFT]

[LEFT]**[SIZE=2][COLOR=#0033ff] public[/COLOR][/SIZE]\*\*\*\*[SIZE=2][COLOR=#339966]function[/COLOR][/SIZE]**[SIZE=2] Environment(){[/SIZE]  
**[SIZE=2][COLOR=#0033ff] this[/COLOR][/SIZE]**[SIZE=2].CurrentURL = mx.core.Application.application.url;[/SIZE]  
**[SIZE=2][COLOR=#cc6666] trace[/COLOR][/SIZE]**[SIZE=2]([/SIZE]**[SIZE=2][COLOR=#990000]"Current URL: "[/COLOR][/SIZE]**[SIZE=2]+[/SIZE]**[SIZE=2][COLOR=#0033ff]this[/COLOR][/SIZE]**[SIZE=2].CurrentURL);[/SIZE]  
[SIZE=2] }[/SIZE]  
[SIZE=2] }[/SIZE][/LEFT]  
[SIZE=2]}[/SIZE]

[SIZE=2]The error message is “TypeError: Error #1009: Cannot access a property or method of a null object reference”. This is because mx.core.Application.application is null. My problem is that when I trace mx.core.Application.application.url in my Flex2 application it **is** defined, and it is the current Request URI. Why can’t I access it from within my class? Can this be some kind of namespace issue? Why does ActionScript insist on making me mad (rhetorical).[/SIZE]

[SIZE=2]Thanks in advance![/SIZE]

[/LEFT]
