externe Movieclip anzeigen und ausrichten per XML

H

hornmartin

Hi Leutz erstmal,
wie kann ich diese test.swf auf das index.swf das grüne Feld bereich so anzeigen und ausrichten per XML?
wenn ich angeklickt habe!!
oder geht es auch anders?
 

Anhänge

  • problem.zip
    28,7 KB · Aufrufe: 14
So ich habe auf dem Suche gemacht da habe ich ja etwas gefunden die als externe Movieclip lädt und die im XML einschreiben kann (=A), ich will aber auf meine grüne XML menü umschreiben lassen bitte die korrigierte hier posten (=B)

zu A:
Code:
//A variable to refer to this timeline
var home:MovieClip = this;

//The XML object
var xml:XML = new XML();
//Ignore all the white spaces in the XML file so the file is read correctly
xml.ignoreWhite = true;

//Nr of Buttons read from the XML file
var numOfButtons:Number;


//Array for button names
var btnNames:Array = new Array();
//Array for button links
var btnLinks:Array = new Array();

//Width of a button
var btnWidth:Number = 100;

//The function that is executed when the XML file is read
xml.onLoad = function(loaded) {
	if (loaded) {
		//Determine the number of buttons in the XML file.
		//It counts the number of <button></button> tags (childnodes) in between the <menu></menu> tags(firstchild).
		numOfButtons = this.firstChild.childNodes.length;

		//Store the name and link of each button from the XML file in the arrays
		for (var i = 0; i<numOfButtons; i++) {
			//The first set of tags (childnodes[0]) in between each set of <button></button> tags are the <name></name> tags
			btnNames[i] = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
			//The second set of tags (childnodes[1]) in between each set of <button></button> tags are the <link></link> tags
			btnLinks[i] = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
		}
		
		//Let's attach an instance of the main bar and give it the same width as the stage
		var bar = home.attachMovie("bar", "bar", home.getNextHighestDepth());
		bar._width = Stage.width;
		//And add the light effect to the bar
		var light = home.attachMovie("light", "light", home.getNextHighestDepth());
		light._width = Stage.width;
		
		//Let's determine where to start adding the buttons
		//We want the center of the menu to be at the center of the stage
		var menuLength:Number = numOfButtons*btnWidth;
		var startX:Number = Stage.width/2-menuLength/2;

		//Let's add the buttons
		for (var i = 0; i<numOfButtons; i++) {
			//Add an instance of the button mc to the stage
			btn = home.attachMovie("btn", "btn"+i, home.getNextHighestDepth());
			//Set its position
			btn._x = i*btnWidth + startX;
			//Set the button's name
			btn.txt.text = btnNames[i];
			//Set the button's roll over state
			btn.onRollOver = function() {
				this.gotoAndPlay(2);
			}
			//Set the button's roll out state
			btn.onRollOut = function() {
				this.gotoAndPlay(16);
			}
			//Set the link to the button
			btn.link = btnLinks[i];
			//Set the button's on release state
			btn.onRelease = function() {
				//Loads the swf on the holder mc instance on the _root stage. 
				//The holder has to be given an instance name!! Done on the properties tab on the left
				loadMovie(this.link, _root.holder);
				//You could also load in URL's, then you would use something like:
				//getURL(this.link,_blank);
				//Of course without the // and _self in stead of _blank to load it in the same window instead of a new window
			}
		}
			
		//Now let's add the borders
		for (var i = 0; i<numOfButtons+1; i++) {
			//Add an instance of the borderL mc to the stage
			//There is a border for each alignment, cause the border mc's are aligned differently as well.
			border = home.attachMovie("border", "border"+i, home.getNextHighestDepth());
			//Set its position
			border._x = i*btnWidth + startX;
		}
	}
}

//Load in the XML file
xml.load("menu.xml");

und zu B:

Code:
stop();
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.load("menu.xml");

onEnterFrame = function(){
	if(auto_center_x=="1"){
	_x = (Stage.width/2 - (_width/2));
		}
	/*if(auto_center_y=="1"){
	_y = (Stage.height/2 - (_height/2));
		}*/
	}
	
my_xml.onLoad = function(success){
	if (success){
		settings = my_xml.firstChild.childNodes[0].attributes;
		menu_count = Number(settings.menu_count);
		auto_center_x = Number(settings.auto_center_x);
		auto_center_y = Number(settings.auto_center_y);
		
		submenu = my_xml.firstChild.childNodes[1].attributes;
		sub = String(submenu.cap);
		
		for(i=1;i<=menu_count;i++){
			duplicateMovieClip("menu","menu"+i,i);
			eval("menu"+i)._x = 0 + (120*i) - 105;
			sm = my_xml.firstChild.childNodes[i].attributes;
			eval("menu"+i).label = sm.cap;
			eval("menu"+i).menu_url = sm.menu_url;
			eval("menu"+i).menu_load_movie = sm.menu_load_movie;
			eval("menu"+i).window = sm.menu_url_window;
			eval("menu"+i).level = sm.menu_load_movie_level;
			eval("menu"+i).target = sm.menu_load_movie_mctarget;
			
			//Action for button
			eval("menu"+i).onRelease = function(){
				trace(this.target);
				if(this.menu_url<>""){
					getURL(this.menu_url,this.window);
				}else if(this.menu_load_movie<>""){
					eval(this.target).loadMovie(this.menu_load_movie,this.level);
				}
			}
				
			eval("menu"+i).onRollOver = function(){
				this.gotoAndStop(2);
			}
				
			eval("menu"+i).onRollOut = function(){
				this.gotoAndStop(1);
			}
			right_rounded._x = eval("menu" + menu_count)._x + 120;
			left_rounded._x = eval("menu1")._x;
			
			
		}
	}
		
}
 
Hi hornmartin,

Ich hab deinen Thread mal in das XML-Forum verschoben - vielleicht bekommst du dort besser Hilfe.

Grüße und viel Erfolg,
Markus
 

Neue Beiträge

Zurück