<?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: Where is as2 _root in as3?</title>
	<atom:link href="http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/</link>
	<description>There is no universally agreed-upon biological definition of dreaming</description>
	<lastBuildDate>Wed, 28 Jul 2010 11:46:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andre</title>
		<link>http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/comment-page-1/#comment-1087</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Thu, 01 Apr 2010 09:25:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/?p=181#comment-1087</guid>
		<description>just use MovieClip(root)

usage: MovieClip(root).myProperty = value;

if you want to cast it, go for MovieClip(root) as Main

done :)</description>
		<content:encoded><![CDATA[<p>just use MovieClip(root)</p>
<p>usage: MovieClip(root).myProperty = value;</p>
<p>if you want to cast it, go for MovieClip(root) as Main</p>
<p>done <img src='http://www.dreaminginflash.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Britton</title>
		<link>http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/comment-page-1/#comment-593</link>
		<dc:creator>Mike Britton</dc:creator>
		<pubDate>Wed, 29 Oct 2008 02:59:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/?p=181#comment-593</guid>
		<description>I would avoid trying to emulate tactics used in AS2 and make an extra effort to port your solution to AS3 without using root.  Root can be the display object of your choosing.  I suggest you emphasize separation of view logic from business logic.  Keep your views dumb and you&#039;ll be happier!</description>
		<content:encoded><![CDATA[<p>I would avoid trying to emulate tactics used in AS2 and make an extra effort to port your solution to AS3 without using root.  Root can be the display object of your choosing.  I suggest you emphasize separation of view logic from business logic.  Keep your views dumb and you&#8217;ll be happier!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Valadares</title>
		<link>http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/comment-page-1/#comment-589</link>
		<dc:creator>Ivan Valadares</dc:creator>
		<pubDate>Tue, 28 Oct 2008 11:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/?p=181#comment-589</guid>
		<description>Off course Sev, you are right.I did soft examples not getting in design patterns :) by the way, this is a awesome book http://www.as3dp.com/</description>
		<content:encoded><![CDATA[<p>Off course Sev, you are right.I did soft examples not getting in design patterns <img src='http://www.dreaminginflash.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  by the way, this is a awesome book <a href="http://www.as3dp.com/" rel="nofollow">http://www.as3dp.com/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sev</title>
		<link>http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/comment-page-1/#comment-587</link>
		<dc:creator>Sev</dc:creator>
		<pubDate>Tue, 28 Oct 2008 09:04:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/?p=181#comment-587</guid>
		<description>If the classes who need to share variables are project specific, you might prefer to go with a Singleton:

public class SharedProjectData {

static private var _value : String;

static public function set myValue( value : String ) : void { _value = myValue; }
static public function get myValue() : String  { return _value; }

}

In project classes you can access like SharedProjectData.myValue

well... usually there&#039;d be just one static method called getInstance(), but for the sake of simplicity :) Also many devs would go with MVC or something similar to keep things clean.

Anyway, I don&#039;t recommand using root or stage to store any values. As you said in your post: you couldn&#039;t access data a) from withing constructor and b) when instance is not in display chain.</description>
		<content:encoded><![CDATA[<p>If the classes who need to share variables are project specific, you might prefer to go with a Singleton:</p>
<p>public class SharedProjectData {</p>
<p>static private var _value : String;</p>
<p>static public function set myValue( value : String ) : void { _value = myValue; }<br />
static public function get myValue() : String  { return _value; }</p>
<p>}</p>
<p>In project classes you can access like SharedProjectData.myValue</p>
<p>well&#8230; usually there&#8217;d be just one static method called getInstance(), but for the sake of simplicity <img src='http://www.dreaminginflash.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Also many devs would go with MVC or something similar to keep things clean.</p>
<p>Anyway, I don&#8217;t recommand using root or stage to store any values. As you said in your post: you couldn&#8217;t access data a) from withing constructor and b) when instance is not in display chain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrSteel</title>
		<link>http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/comment-page-1/#comment-585</link>
		<dc:creator>MrSteel</dc:creator>
		<pubDate>Tue, 28 Oct 2008 02:55:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/?p=181#comment-585</guid>
		<description>I meant instead of main = this; 
instance = this; 

in 4th line of prev comment</description>
		<content:encoded><![CDATA[<p>I meant instead of main = this;<br />
instance = this; </p>
<p>in 4th line of prev comment</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrSteel</title>
		<link>http://www.dreaminginflash.com/2008/10/27/where-is-as2-_root/comment-page-1/#comment-584</link>
		<dc:creator>MrSteel</dc:creator>
		<pubDate>Tue, 28 Oct 2008 02:55:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/?p=181#comment-584</guid>
		<description>you can make a static variable named instance in Main
public static var instance : Main;

and in Main constructor you can assign
main = this;

then from any other class you can 
import Main; // or other structure that point to main

and then easily you can use in code
Main.instance to get to the main class

introducing one more variable to class
private var _main : Main = Main.instance;
is even better and you can just refer to it through _main

there are other ways but this is what I use, somewhat like Singleton but being this is main class there is no need for getInstance and checking in constructor if it&#039;s already created</description>
		<content:encoded><![CDATA[<p>you can make a static variable named instance in Main<br />
public static var instance : Main;</p>
<p>and in Main constructor you can assign<br />
main = this;</p>
<p>then from any other class you can<br />
import Main; // or other structure that point to main</p>
<p>and then easily you can use in code<br />
Main.instance to get to the main class</p>
<p>introducing one more variable to class<br />
private var _main : Main = Main.instance;<br />
is even better and you can just refer to it through _main</p>
<p>there are other ways but this is what I use, somewhat like Singleton but being this is main class there is no need for getInstance and checking in constructor if it&#8217;s already created</p>
]]></content:encoded>
	</item>
</channel>
</rss>
