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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange behavior - creating, loading movie clips works only for first

Status
Not open for further replies.

clemcrock

Programmer
Dec 17, 2006
63
US
Hello,

I am reading an XML document and creating empty movie clips and attaching multiple instances of a movie clip from the library into each empty movie clip.

it works fine in the first loop and function call but after that, the movie clips register as being created, and attached but they aren't showing up.


Here's some of the code, in a nutshell:

Code:
function call_xml( start_cnt )
{ 
        var xml_menu:String =  'gallery.xml'; 
       menuXML = new XML();
       menuXML.ignoreWhite=true;     
       menuXML.load( xml_menu ); 
       menuXML.onLoad = parse_xml;   
}


function parse_xml()
{
	 //---- create holder movie clips  w/in the pc_movie_loader
	 //---------------------------------------------------------------------------
	_root.pc_movie_loader.mc_holder_clip.unloadMovie();
	_root.pc_movie_loader.createEmptyMovieClip( 'mc_holder_clip', 1 );
         //----------------------------------------------------------------------------
			  
          for( var i:Number = 0; i < node_1.length; i++ ) 
	 {	
	           subnode_1 = node_1[i].childNodes;
		 
		  if( i >= this_start_cnt && i < this_end_cnt )
		  {
			   _root.pc_movie_loader.mc_holder_clip.createEmptyMovieClip( 'mc_demo_panel_' + i, i );
	                      _root.attach_movie_clip('reg_demo_panel', _root.pc_movie_loader.mc_holder_clip['mc_demo_panel_' + i], '', row_x, row_y );
		             _root.print_clip_elements(_root.pc_movie_loader.mc_holder_clip); 
			   
			     row_cnt++;
			     row_y = row_y + (_root.pc_movie_loader.mc_holder_clip['mc_demo_panel_' + i]._height + 10);
			   		
			     if( row_cnt == 2)
			     {
				   row_x = 444;
				   row_y = 10;
				   row_cnt = 0;
			   }
		  }
	 }

}

and here's the print_clip_elements test function I'm using to print the contents of the movie clips:


function print_clip_elements( clip:Object )
{
	for( var j in clip )
	{
		 trace( "****** j:" + j + " : " + clip[j] );
	}
}

and here's the attach_movie_clip test function I'm using to attach the movie clips from the library:

function attach_movie_clip( movie_clip:Object, level:Object, message_var:String, x_coords:Number, y_coords:Number ) 
{ 
       level.attachMovie( movie_clip, movie_clip,10,{_x:x_coords,_y:y_coords});
}

When I call the print clip elements the output is as follows for every function call:


===== START PRINT MOVIE CLIPS ============================
j:mc_demo_panel_4 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_4
===== END PRINT MOVIE CLIPS ============================


===== START PRINT MOVIE CLIPS ============================
j:mc_demo_panel_5 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_5
j:mc_demo_panel_4 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_4
===== END PRINT MOVIE CLIPS ============================


===== START PRINT MOVIE CLIPS ============================
j:mc_demo_panel_6 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_6
j:mc_demo_panel_5 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_5
j:mc_demo_panel_4 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_4
===== END PRINT MOVIE CLIPS ============================


===== START PRINT MOVIE CLIPS ============================
j:mc_demo_panel_7 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_7
j:mc_demo_panel_6 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_6
j:mc_demo_panel_5 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_5
j:mc_demo_panel_4 : _level0.pc_movie_loader.mc_holder_clip.mc_demo_panel_4
===== END PRINT MOVIE CLIPS ============================

it's registering that all the movie clips have been created and the mc_demo_panel library item has been attached.

Any ideas why the first function call works and everyone after that doesn't?

Thanks,
Clem C


 
Hey - thanks for your help.

This did the trick but- it seems a bit strange as to why it would work?

I thought, w/ every function call I would have to unload that movie and recreate it to start off w/ a clean slate.

but - it works so what the hell.

Thanks!
 
If you want you could use [tt]removeMovieClip()[/tt], but creating a MovieClip at a depth occupied by another MovieClip will delete the existing one anyway, you won't need to explicitly remove the MovieClip.

Kenneth Kawamoto
 
Ah - great - I didn't know that - thanks a lot.

clem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top