Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attachMovie problems

Status
Not open for further replies.

motte

Programmer
May 31, 2001
155
US
Hi all,

I'm very new to Flash, MX to be exact, and am having troubles with something. I've tried to research this, but I haven't found any examples.

What I am doing is loading up a movie clip dynamically with attachMovie. I have the movie's linkage properties set and I can do everything with the movie, such as load it, unload, change its position, and change its alpha. What I can't do is set the dynamic textfields inside the attached movie. I tried finding more about this initObject but haven't been successful. Can someone help?

Here is what I have, sitting on the main timeline:

Code:
on(release){
	_root.attachMovie("FrontScreen_mv","homemovie", 1);
	homemovie._x = 337;
	homemovie._y = 285;

	SiteContent1 = new LoadVars();
	SiteContent1.onLoad = onText1;
	SiteContent1.load("site_content.txt");

	function onText1() {
		homemovie.frontscreen_name.text = SiteContent1.hometitle;
		homemovie.frontscreen_content.text = SiteContent1.home_content;
	}

}

frontscreen_name and frontscreen_content are the instance names of 2 textfields inside of FrontScreen_mv. They don't show any text, even undefined. I checked the font color to make sure it doesn't match the background. All looks fine. Any and all help is appreciated. Do I need to use the initObject? If so, how?

Mike
 
You are slightly out of order. You need to pass the variables in with the attachMovie action. Try this:

Code:
on (release) {
	SiteContent1 = new LoadVars();
	SiteContent1.onLoad = onText1;
	SiteContent1.load("site_content.txt");
	function onText1() {
		homemovie.frontscreen_name = SiteContent1.hometitle;
		homemovie.frontscreen_content = SiteContent1.home_content;
		_root.attachMovie("FrontScreen_mv", "homemovie", this.getNextHighestDepth, {frontscreen_name:SiteContent1.hometitle, frontscreen_content:SiteContent1.home_content});
		homemovie._x = 337;
		homemovie._y = 285;
	}
}

In your FrontScreen_mv library item change the dynamic text boxes to no instance name and move the name that you have in instance name to the var box (in properties).

I think that will fix you but might need some tweeking.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
pixl8r,

Thanks for your reply and suggestions. I do apologize for the multiple post. I edited this original, but I guess it ended up posting 2x.

Onto the code. Thanks for setting me straight about using the variables, not textbox instances. It worked perfectly. I did, however, remove the first 2 lines inside function onText1 since the values are set inside the attachMovie. I appreciate all your help on this.

Mike
 
In any other case I would recommend using the instance names instead of the Var, but for attachMovie it seems to work better with Var.

Glad it helped.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top