<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Global Variables within Flex Applications</title>
	<atom:link href="http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/</link>
	<description>code = joy</description>
	<pubDate>Tue, 06 Jan 2009 15:33:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Pippo</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-15360</link>
		<dc:creator>Pippo</dc:creator>
		<pubDate>Thu, 18 Dec 2008 12:03:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-15360</guid>
		<description>ahahah tf I do agree with you :)
when an application is:
- scalable
- easily maintainable
- follows consistent rules
- secure

who the heck is worrying about using or not global variables??? it all depends on the architecture and mind state of the programmer.
I hate flex, but I cant say no to a client.... finding this post was really useful :)

namaste
Pippo</description>
		<content:encoded><![CDATA[<p>ahahah tf I do agree with you :)<br />
when an application is:<br />
- scalable<br />
- easily maintainable<br />
- follows consistent rules<br />
- secure</p>
<p>who the heck is worrying about using or not global variables??? it all depends on the architecture and mind state of the programmer.<br />
I hate flex, but I cant say no to a client&#8230;. finding this post was really useful :)</p>
<p>namaste<br />
Pippo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lalo</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-14399</link>
		<dc:creator>Lalo</dc:creator>
		<pubDate>Tue, 14 Oct 2008 16:25:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-14399</guid>
		<description>I think global variables are still very useful, just try to think about an application with java smart cards + flex and you must get worried about security issues like username, money and pin code inside the java smart card....ok, you get the pin to make a login and you get others variables too, obviously the pin data or serial card number must get a few and really neccesary times, but your username variable can be loaded just one time and jump happines for everywhere , yes, global variables works, lol</description>
		<content:encoded><![CDATA[<p>I think global variables are still very useful, just try to think about an application with java smart cards + flex and you must get worried about security issues like username, money and pin code inside the java smart card&#8230;.ok, you get the pin to make a login and you get others variables too, obviously the pin data or serial card number must get a few and really neccesary times, but your username variable can be loaded just one time and jump happines for everywhere , yes, global variables works, lol</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-14308</link>
		<dc:creator>Johan</dc:creator>
		<pubDate>Thu, 09 Oct 2008 19:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-14308</guid>
		<description>tf - best comment, ever!</description>
		<content:encoded><![CDATA[<p>tf - best comment, ever!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tf</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-14278</link>
		<dc:creator>tf</dc:creator>
		<pubDate>Wed, 08 Oct 2008 17:47:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-14278</guid>
		<description>People who are afraid of globals are usually afraid of girls, spiders, etc.</description>
		<content:encoded><![CDATA[<p>People who are afraid of globals are usually afraid of girls, spiders, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: giechika</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-13561</link>
		<dc:creator>giechika</dc:creator>
		<pubDate>Fri, 29 Aug 2008 09:04:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-13561</guid>
		<description>I just tried what
mikechambers said on February 5th, 2007
and
Alan said on 29 Nov 2007 at 7:34 pm.

It worked for me.

I was trying to get the values of 2 variables created for use in one mxml state file to be available in another one so that I could post them to a server. The two files are in the same package. The main application mxml imports the package they are in.

I would like to know a better way than what I have done. If there is one.

George</description>
		<content:encoded><![CDATA[<p>I just tried what<br />
mikechambers said on February 5th, 2007<br />
and<br />
Alan said on 29 Nov 2007 at 7:34 pm.</p>
<p>It worked for me.</p>
<p>I was trying to get the values of 2 variables created for use in one mxml state file to be available in another one so that I could post them to a server. The two files are in the same package. The main application mxml imports the package they are in.</p>
<p>I would like to know a better way than what I have done. If there is one.</p>
<p>George</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-12717</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Tue, 15 Jul 2008 15:28:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-12717</guid>
		<description>As far as globals goes... (at least from an old school C++ programmer)

It is always best practice to contain the data in the class designed specifically for that class.  

With that said, there are always reasons to do global variables...

For instance, I have my components set up to display different tools depending on the access of the user (Set through a remote object component).  There may be an edit button if the person has edit rights for instance.

I have a global user object that each of the components can easily refer to.  I also have a bind set so that the components can react if a variable changes (like if the user logs out).

I could be wrong on this... But I don't see another way to easily get around that by keeping the information in the login component.  

This is only one example, I can think of numerous ones that I've encountered over the past 30 years of coding. 

However with that said you should ALWAYS ask yourself, is this the best place to store the variables?  What and how do other pieces of code have to do to access them?  It's never best practice to store 95% of data in public variables (unless you're doing BASIC code that is... ;)</description>
		<content:encoded><![CDATA[<p>As far as globals goes&#8230; (at least from an old school C++ programmer)</p>
<p>It is always best practice to contain the data in the class designed specifically for that class.  </p>
<p>With that said, there are always reasons to do global variables&#8230;</p>
<p>For instance, I have my components set up to display different tools depending on the access of the user (Set through a remote object component).  There may be an edit button if the person has edit rights for instance.</p>
<p>I have a global user object that each of the components can easily refer to.  I also have a bind set so that the components can react if a variable changes (like if the user logs out).</p>
<p>I could be wrong on this&#8230; But I don&#8217;t see another way to easily get around that by keeping the information in the login component.  </p>
<p>This is only one example, I can think of numerous ones that I&#8217;ve encountered over the past 30 years of coding. </p>
<p>However with that said you should ALWAYS ask yourself, is this the best place to store the variables?  What and how do other pieces of code have to do to access them?  It&#8217;s never best practice to store 95% of data in public variables (unless you&#8217;re doing BASIC code that is&#8230; ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gorgon_the_destroyer</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-11690</link>
		<dc:creator>gorgon_the_destroyer</dc:creator>
		<pubDate>Thu, 27 Mar 2008 19:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-11690</guid>
		<description>jari,

several ways:

.outerDocument

.parentDocument

if you have an id of the element just use the element.id.</description>
		<content:encoded><![CDATA[<p>jari,</p>
<p>several ways:</p>
<p>.outerDocument</p>
<p>.parentDocument</p>
<p>if you have an id of the element just use the element.id.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Martin</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-11342</link>
		<dc:creator>Dan Martin</dc:creator>
		<pubDate>Fri, 07 Mar 2008 21:10:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-11342</guid>
		<description>@Jake

Sorry, but on this one you're quite wrong.  There is a very common Flex scenario where using Singleton's just doesn't work, but Application.application does.  Singleton's don't work when you build a modular system, where each module is its own swf, and loaded using SWFLoader or ModuleLoader.  However, with such a modular system works great with globals loaded from Application.application.  I use Application.application frequently, and have never encountered mem leaks like you describe.

The use of Singletons is the primary reason that Cairngorm doesn't work with modular Flex apps.  That and the problem of multiple instance of commands loaded into controllers causing things to double/triple/etc load.</description>
		<content:encoded><![CDATA[<p>@Jake</p>
<p>Sorry, but on this one you&#8217;re quite wrong.  There is a very common Flex scenario where using Singleton&#8217;s just doesn&#8217;t work, but Application.application does.  Singleton&#8217;s don&#8217;t work when you build a modular system, where each module is its own swf, and loaded using SWFLoader or ModuleLoader.  However, with such a modular system works great with globals loaded from Application.application.  I use Application.application frequently, and have never encountered mem leaks like you describe.</p>
<p>The use of Singletons is the primary reason that Cairngorm doesn&#8217;t work with modular Flex apps.  That and the problem of multiple instance of commands loaded into controllers causing things to double/triple/etc load.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jake Hawkes</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-11137</link>
		<dc:creator>Jake Hawkes</dc:creator>
		<pubDate>Mon, 11 Feb 2008 20:46:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-11137</guid>
		<description>I would have to agree that Application.application is very rarely the best way of creating "global" variables. Sure, in some cases it's okay, but make sure you learn this lesson:

NEVER bind to variables using Application.application

In my experience, it will create a memory leak in nearly all cases. If you must bind, use a singleton. I believe the best way to implement a singleton is the way it's done in Cairngorm (I hate Cairngorm, but at least they do this one thing well).

I respect Mike, and I will grant that in some cases creating global variables using "Application.application" is acceptable (although I personally try to avoid it), but I think Mike probably should have given a little more caution in his blog post so as not to mislead developers who are new to Flex.</description>
		<content:encoded><![CDATA[<p>I would have to agree that Application.application is very rarely the best way of creating &#8220;global&#8221; variables. Sure, in some cases it&#8217;s okay, but make sure you learn this lesson:</p>
<p>NEVER bind to variables using Application.application</p>
<p>In my experience, it will create a memory leak in nearly all cases. If you must bind, use a singleton. I believe the best way to implement a singleton is the way it&#8217;s done in Cairngorm (I hate Cairngorm, but at least they do this one thing well).</p>
<p>I respect Mike, and I will grant that in some cases creating global variables using &#8220;Application.application&#8221; is acceptable (although I personally try to avoid it), but I think Mike probably should have given a little more caution in his blog post so as not to mislead developers who are new to Flex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: _t</title>
		<link>http://www.mikechambers.com/blog/2007/02/05/global-variables-within-flex-applications/comment-page-1/#comment-10996</link>
		<dc:creator>_t</dc:creator>
		<pubDate>Wed, 30 Jan 2008 21:27:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1091#comment-10996</guid>
		<description>I can reference these variables, but I can't seem to bind to them.  When I do, I get the infamous:

warning: unable to bind to property 'application' on class 'mx.core::Application' (class is not an IEventDispatcher)

But I can reference these in components and elsewhere and get the values of them.  Can you not bind to the Application class?</description>
		<content:encoded><![CDATA[<p>I can reference these variables, but I can&#8217;t seem to bind to them.  When I do, I get the infamous:</p>
<p>warning: unable to bind to property &#8216;application&#8217; on class &#8216;mx.core::Application&#8217; (class is not an IEventDispatcher)</p>
<p>But I can reference these in components and elsewhere and get the values of them.  Can you not bind to the Application class?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
