AS3 Class - Access Object In Root

Hey Guys,

I am creating a class in AS3 that loads some info from a remote file.  What I want to be able to do is put this info into a text box.

I have given the text box an instance name, but I am not sure on how I would target the text box from within a class method.

Thanks
LVL 6
pD_EOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh ChopraCommented:
USE "root" instead of "_root"

it should work
0
pD_EOAuthor Commented:
Hi,

I gave that a try, but I get an error...

"1120: Access of undefined property root.
0
Aneesh ChopraCommented:
The MovieClip/textField is located on the timeline created by the flash player. You can call it using this syntax by casting the Displayobject "this.root" to a MovieClip:

trace("this.root: "+MovieClip(this.root).getChildByName("mytxt") );

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

pD_EOAuthor Commented:
Hmm, still having a problem.
package com.blah.apples {
 
	public class apples {
	
		public function apples {
			trace("this.root: " + MovieClip(this.root).getChildByName("mytxt"));
		}
	
	}
 
}

Open in new window

0
Aneesh ChopraCommented:
main timeline root is not accessible freely anymore in AS3,
it can be accessed by any class only if class gets any reference of the main timeline.

so simplest way is store a global refernce to any object is create a class which can act as similar to "_global" of AS2

visit following link to get more details about storing and accesing Global variables in ActionScript 3.0
http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_22997849.html


-------------------
Aneesh Chopra
-------------------
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pD_EOAuthor Commented:
I worked out that I could pass the main timeline to my class, but thought there might be a better way.

Thanks for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.