Foros del Web » Creando para Internet » Flash y Actionscript »

Remplazar el GetUrl por GotoandStop en un menu XML

Estas en el tema de Remplazar el GetUrl por GotoandStop en un menu XML en el foro de Flash y Actionscript en Foros del Web. Hola tengo un menu bastante complejo modificable via XML El menu esta planteado de forma que los links apunten a direcciones URL externas. Pero me ...
  #1 (permalink)  
Antiguo 11/07/2009, 07:42
Avatar de NathanFox  
Fecha de Ingreso: junio-2005
Mensajes: 35
Antigüedad: 18 años, 10 meses
Puntos: 0
Pregunta Remplazar el GetUrl por GotoandStop en un menu XML

Hola tengo un menu bastante complejo modificable via XML
El menu esta planteado de forma que los links apunten a direcciones URL externas. Pero me interesaria conseguir que los vinculos linkearan a un frame determinado de la misma pelicula.

El GetUrl que tengo es este:
getURL(menuArray[this._parent._parent.nr].getMenuLink, menuArray[this._parent._parent.nr].getWindow);

Y el fichero XML esto:
<item link="url" window="_self" >LINK 01</item>

Debe de haber una manera para hacer que cada vinculo del menu xml pueda apuntar a un determinado frame de la pelicula y asi usar el menu internamente en el flash.

¿Alguien sabe como ayudarme?
  #2 (permalink)  
Antiguo 11/07/2009, 10:10
Avatar de Lynxcraft  
Fecha de Ingreso: noviembre-2007
Ubicación: yecla murcia
Mensajes: 1.346
Antigüedad: 16 años, 5 meses
Puntos: 51
Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

Código PHP:
if(menuArray[this._parent._parent.nr].getMenuLink=="frame"){
    var 
Frame=menuArray[this._parent._parent.nr].getWindow
    _root
.gotoAndPlay(Frame)
}else{
getURL(menuArray[this._parent._parent.nr].getMenuLinkmenuArray[this._parent._parent.nr].getWindow);

Xml
Código PHP:

<item link="url" window="_self" >LINK 01</item>
<
item link="frame" window="15" >LINK 02</item
__________________
Sobran las ideas cuando faltan ganas de trabajar en ellas
Lynxcraft
  #3 (permalink)  
Antiguo 11/07/2009, 11:02
Avatar de NathanFox  
Fecha de Ingreso: junio-2005
Mensajes: 35
Antigüedad: 18 años, 10 meses
Puntos: 0
Pregunta Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

Gracias Lynxcraft, el caso es que funciona!!!
El problema que tengo ahora es que solo funciona en el nivel base de menu. Los enlaces a los frames en los submenus no van!!

EDIT:
Acabo de darme cuenta de otroGETURL, que creo que sera el de los submenus.
Es este:

getURL(menuArray[oMenu].getSLA[k], menuArray[oMenu].getSWA[k]);

He hecho este codigo basandome en el anterior, pero no me funciona:


k = this._parent._parent.nr;
if(menuArray[k].getMenuLink=="frame"){
var Frame=menuArray[k].getWindow
_root.gotoAndStop(Frame)
}else{
getURL(menuArray[oMenu].getSLA[k], menuArray[oMenu].getSWA[k]);

¡Muchas gracias!
Saludos

Última edición por NathanFox; 20/07/2009 a las 18:08
  #4 (permalink)  
Antiguo 11/07/2009, 11:38
Avatar de Lynxcraft  
Fecha de Ingreso: noviembre-2007
Ubicación: yecla murcia
Mensajes: 1.346
Antigüedad: 16 años, 5 meses
Puntos: 51
Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

coloca todo el código xml y si puedes el código flash
__________________
Sobran las ideas cuando faltan ganas de trabajar en ellas
Lynxcraft
  #5 (permalink)  
Antiguo 14/07/2009, 23:03
Avatar de NathanFox  
Fecha de Ingreso: junio-2005
Mensajes: 35
Antigüedad: 18 años, 10 meses
Puntos: 0
Pregunta Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

Pues al final no me funciona lo del codigo submenu. ¿Alguien podria hecharle un vistazo a esto? no logro que los links direccionen a un frame concreto.

Este es el codigo alrededor del GetURL:
Código:
mcsub._x = sumwSubmenu;
sumwSubmenu += mcsub.mcBackSubmenu._width;
						
mcsub.mcBackSubmenu.but.onPress = function():Void 
{
playSound(clickSound, "click");
};
						
mcsub.mcBackSubmenu.but.onRelease = function():Void  
{
							
k = this._parent._parent.nr;
getURL(menuArray[oMenu].getSLA[k], menuArray[oMenu].getSWA[k]);

mprev = msel;
msel = selectedMenu;
HOME.all["mcBut"+mprev].mcBut.gotoAndStop(1);
HOME.all["mcBut"+mprev].mcTxt.setColor(menuTextColor);
};
						
mcsub.mcBackSubmenu.but.onRollOver = function():Void 
{
playSound(overSound, "over");
this._parent._parent.mcTxt.setColor(overSubmenuTextColor);
this._parent.mcOverSub.fade("in", 25);
};
La función GetUrl es esta:
k = this._parent._parent.nr;
getURL(menuArray[oMenu].getSLA[k], menuArray[oMenu].getSWA[k]);


Y necesito que sea capaz de direccionar a un frame concreto (GotoandStop)
El XML donde se debe dar la orden es así:

Código:
?xml version="1.0" encoding="utf-8"?>
<options>

<menu name="Inicio" link="frame" window="1">

</menu>

<menu name="Cosas" link="frame" window="2" >
	<item link="frame" window="3" >Acción</item>
	<item link="frame" window="4" >Sci-fi</item>
	<item link="frame" window="5" >Fantasia</item>
</menu>
</options>
Lynxcraft me ayudo anteriormente y logre que funcionaran el primer nivel del menu, que son estos: <menu name="Inicio" pero el submenu tiene un codigo aparte, os he pegado el GetUrl más arriba y desconozco como solucionar ese problema!! ya que el codigo es bastante distinto, ya he probado de mil maneras, pero nada.

¡En fin, muchas gracias!
Un saludo,

Última edición por NathanFox; 14/07/2009 a las 23:24
  #6 (permalink)  
Antiguo 16/07/2009, 06:08
Avatar de Lynxcraft  
Fecha de Ingreso: noviembre-2007
Ubicación: yecla murcia
Mensajes: 1.346
Antigüedad: 16 años, 5 meses
Puntos: 51
Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

mm falta saber somo cargas el xml ya que el código que as puesto no lo muestra ya que no se que valor tiene estas variables

Código PHP:
getURL(menuArray[oMenu].getSLA[k], menuArray[oMenu].getSWA[k]); 
__________________
Sobran las ideas cuando faltan ganas de trabajar en ellas
Lynxcraft
  #7 (permalink)  
Antiguo 16/07/2009, 21:46
Avatar de NathanFox  
Fecha de Ingreso: junio-2005
Mensajes: 35
Antigüedad: 18 años, 10 meses
Puntos: 0
Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

Aquí esta el codigo completo en dos partes:

Código:
stop();
Stage.showMenu = false;
Stage.scaleMode = "noScale";
this._lockroot = true;
System.useCodepage = true

var HOME:MovieClip = this;
//var xmlPath:String = "settings.xml";

/********************

	VARIABLES

********************/

var menuArray:Array = new Array();

var delTime:Number = 1;
var nrFrames:Number = 2;
var msel:Number = -1;
var mprev:Number = -1;

var firstTimeMenu:Boolean = true;
var sumw:Number = 0;
var sumwSubmenu:Number = 100;

all.mcButton._visible = false;
createEmptyMovieClip("mousePos", -1);
 

/********************

	SOUND SETTINGS

********************/

// over menu sound
var overMenuSound:Sound = new Sound();

// over sound
var overSound:Sound = new Sound();

// click sound
var clickSound:Sound = new Sound();

//back sound
function playSound(id, mp3):Void 
{
	if (playS == "true")
	{
		id.attachSound(mp3);
		id.start();
	}
}


/********************

	EFFECT: "FADE IN" AND "FADE OUT" IMAGES

********************/

MovieClip.prototype.fade = function(dir:String, addInteger:Number, f):Void  
{
	delete this.onEnterFrame;
	//this.step = (dir == "in") ? 0 : 100;
	this.step = this._alpha;
	this.onEnterFrame = function():Void 
	{
		this.step = (dir == "in") ? this.step+addInteger : this.step-addInteger;
		this._alpha = this.step;
		if (((dir == "in") && this._alpha>=100) || ((dir == "out") && this._alpha<=0))
		{
			delete this.onEnterFrame;
			f();
		}
	};
};


/********************

	CHANGE THE COLOR OF A MOVIECLIP

********************/

MovieClip.prototype.setColor = function(col:String):Void 
{
	this.mycol = new Color(this);
	this.mycol.setRGB(col);
};


/********************

	ELASTIC EFFECT

********************/

MovieClip.prototype.elastic = function(prop:Array, speed:Number, f):Void  
{
	delete this.onEnterFrame;
	this.onEnterFrame = function():Void  
	{
		ok = true;
		for (i in prop)
		{
			if (this[i] != prop[i])
			{
				ok = false;
			}
			if (ok) 
			{
				delete this.onEnterFrame;
				f();
			}
			if (this[i] != prop[i]) 
			{
				if (speed == 0) 
				{
					this[i] = prop[i];
				} 
				else 
				{
					this[i] += (prop[i]-this[i])/speed;
				}
				
				if (Math.abs(this[i]-prop[i])<0.1)
				{
					this[i] = prop[i];
				}
			}
		}
	};
};


/********************

	PARSE XML

********************/

var settingsXML:XML = new XML();
settingsXML.ignoreWhite = true;

if(xmlPath == undefined)
{
	trace("Error! You need to pass the variable xmlPath inside the fla if you want to test it outside the browser, or else test the swf in the browser.");
}
else
{
	settingsXML.load(xmlPath);
}

settingsXML.onLoad = function():Void  
{
	var currentNode:XMLNode = this.firstChild.firstChild;
	var i:Number = 0;
	for (var childNode = currentNode; childNode != null; childNode=childNode.nextSibling, i++)
	{
		var j:Number = 0;
		settingsArray = new Array();
		linkArray = new Array();
		windowArray = new Array();
		for (var stringNode = childNode.firstChild; stringNode != null; stringNode=stringNode.nextSibling, j++)
		{
			settingsArray[j] = stringNode.firstChild.nodeValue;
			linkArray[j] = stringNode.attributes.link;
			windowArray[j] = stringNode.attributes.window;
		}
		
		sTmp = replaceChar("*", "<br>", childNode.attributes.name);
		menuArray[i] = new Menu(sTmp, childNode.attributes.link, childNode.attributes.window, settingsArray, linkArray, windowArray);
		delete settingsArray;
		delete linkArray;
		delete windowArray;
	}
	
	init();
};


/********************

	Init menu

********************/

function init():Void 
{
	for (i=0; i<menuArray.length; i++)
	{
		var mc:MovieClip = all.mcButton.duplicateMovieClip("mcBut"+i, i);
		mc.nr = i;
		mc.mcTxt.txt.htmlText = menuArray[i].getMenuName;
		mc.mcBut._xscale = 100*(mc.mcTxt.txt.textWidth+3+distanceTextMenu);
		mc.mcTxt._x = (mc.mcBut._width-mc.mcTxt.txt.textWidth-3)/2;
		mc.mcTxt.setColor(menuTextColor);
		mc.mcBut.mcShape.setColor(menuColor);
		
		mc._x = sumw;
		sumw += mc.mcBut._width;
		
		mc.mcBut.but.onRelease = function():Void 
		{
			if (menuArray[this._parent._parent.nr].getMenuLink != undefined) 
			{
				mprev = msel;
				msel = this._parent._parent.nr;
				HOME.all["mcBut"+mprev].mcTxt.setColor(menuTextColor);
				
				//getURL(menuArray[this._parent._parent.nr].getMenuLink, menuArray[this._parent._parent.nr].getWindow);
				if(menuArray[this._parent._parent.nr].getMenuLink=="frame"){
                    			var Frame=menuArray[this._parent._parent.nr].getWindow
                    			_root.gotoAndStop(Frame)
                		}else{
                		getURL(menuArray[this._parent._parent.nr].getMenuLink, menuArray[this._parent._parent.nr].getWindow);
                }  
				
			}
		};
		
		mc.mcBut.but.onRollOut = function():Void 
		{
			countTime(this._parent);
		};
		
		mc.mcBut.but.onReleaseOutside = mc.mcBut.but.onRollOut;
		
		mc.mcBut.but.onRollOver = function():Void 
		{
			delete mousePos.onEnterFrame;
			oMenu = (this._parent._parent.nr);
			if (selectedMenu != this._parent._parent.nr) 
			{
				if (firstTimeMenu == true && this._parent._parent.nr != selectedMenuLight) 
				{
					countTime(HOME.all["mcBut"+selectedMenuLight].mcBut);
				}
				sumwSubmenu = 0;
				
				this._parent.mcShape.elastic({_y:0}, speedElastic);
				this._parent._parent.mcTxt.setColor(overMenuTextColor);
				selectedMenu = this._parent._parent.nr;
				l = menuArray[this._parent._parent.nr].submenuNamesArray.length;
				if (l != 0) 
				{
					playSound(overMenuSound, "overMenu");
					
					max = 0;
					for (i=0; i<l; i++) 
					{
						var mcsub:MovieClip = this._parent._parent.mcOver.duplicateMovieClip("mcOver"+i, l-i);
						
						mcsub.nr = i;
						mcsub.mcTxt._y = -30;
						mcsub.mcTxt.txt.htmlText = menuArray[this._parent._parent.nr].getSNA[i];
						mcsub.mcTxt.setColor(submenuTextColor);
						mcsub.mcBackSubmenu.mcBackStroke.setColor(submenuColor);
						mcsub.mcUnder.setColor(submenuColor);
						mcsub.mcBackSubmenu.mcOverSub.setColor(submenuOverColor);
						mcsub.mcBackSubmenu._xscale = 100*(mcsub.mcTxt.txt.textWidth+3+distanceTextSubMenu);
						mcsub.mcMask._width = mcsub.mcBackSubmenu._width;
						mcsub.mcTxt._alpha = 0;
						mcsub.mcTxt._x = (mcsub.mcBackSubmenu._width-mcsub.mcTxt.txt.textWidth-3)/2;
						mcsub.mcTxt.elastic({_y:1, _alpha:100}, 4);
						
						mcsub._x = sumwSubmenu;
						sumwSubmenu += mcsub.mcBackSubmenu._width;
						
						mcsub.mcBackSubmenu.but.onPress = function():Void 
						{
							playSound(clickSound, "click");
						};
						
						mcsub.mcBackSubmenu.but.onRelease = function():Void  
						{
							
                                                        k = this._parent._parent.nr;
							getURL(menuArray[oMenu].getSLA[k], menuArray[oMenu].getSWA[k]);

							mprev = msel;
							msel = selectedMenu;
							HOME.all["mcBut"+mprev].mcBut.gotoAndStop(1);
							HOME.all["mcBut"+mprev].mcTxt.setColor(menuTextColor);
						};
						
						mcsub.mcBackSubmenu.but.onRollOver = function():Void 
						{
							playSound(overSound, "over");
							this._parent._parent.mcTxt.setColor(overSubmenuTextColor);
							this._parent.mcOverSub.fade("in", 25);
						};
						
						mcsub.mcBackSubmenu.but.onRollOut = function():Void
						{
							if (selectedMenuLight != oMenu) 
							{
								this._parent.mcOverSub.fade("out", 50);
								this._parent._parent.mcTxt.txt.htmlText = this._parent._parent.mcTxt.txt.text;
								
								this._parent._parent.mcTxt.setColor(submenuTextColor);
							}
							else
							{
								if (selectedSubmenuLight != this._parent._parent.nr)
								{
									this._parent.mcOverSub.fade("out", 50);
									this._parent._parent.mcTxt.txt.htmlText = this._parent._parent.mcTxt.txt.text;
									this._parent._parent.mcTxt.setColor(submenuTextColor);
								}
							}
							
							l = menuArray[selectedMenu].submenuNamesArray.length;
							if (l != 0)
							{
								for (i=0; i<l; i++)
								{
									this._parent._parent["mcOver"+i].removeMovieClip();
								}
							}
						};
						
						mcsub.mcBackSubmenu.but.onReleaseOutside = mcsub.mcBackSubmenu.but.onRollOut;
						if (i == l-1) 
						{
							mcsub.mcUnder._width = 900;
						}
						if (i == 0) 
						{
							mcsub.mcUnder._width = 900;
							mcsub.mcUnder._x = -900;
						}
					}
					
					if (selectedMenuLight == selectedMenu)
					{
						if (selectedSubmenuLight>=0 && selectedSubmenuLight != undefined) 
						{
							this._parent._parent["mcOver"+selectedSubmenuLight].mcBackSubmenu.but.onRollOver();
						}
					}
					
					smartMath = ( sumwSubmenu - this._parent._parent.mcBut._width )/2;
					var m:MovieClip = this._parent._parent["mcOver"+0];
					
					if (m._x-smartMath+this._parent._parent._x+distanceTextMenu/2>0) 
					{
						if (m._x-smartMath+this._parent._parent._x+sumwSubmenu>900) 
						{
							var h = m._x-smartMath+this._parent._parent._x+sumwSubmenu-900;
							for (j=0; j<l; j++) 
							{
								var p:MovieClip = this._parent._parent["mcOver"+j];
								p._x = p._x-smartMath-h;
							}
						}
						else 
						{
							for (j=0; j<l; j++) 
							{
								var p:MovieClip = this._parent._parent["mcOver"+j];
								p._x = p._x - smartMath - distanceTextMenu/2;
							}
						}
					}
				}
			}
		};
	}
	
	if (selectedMenuLight>=0 && selectedMenuLight != undefined) 
	{
		mprev = msel=selectedMenuLight;
		HOME.all["mcBut"+selectedMenuLight].mcBut.but.onRollOver();
	}
}
  #8 (permalink)  
Antiguo 16/07/2009, 21:49
Avatar de NathanFox  
Fecha de Ingreso: junio-2005
Mensajes: 35
Antigüedad: 18 años, 10 meses
Puntos: 0
Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

Y continua así:
Código:
/********************

	Counter

********************/

function countTime(mc:MovieClip):Void 
{
	var contor = 0;
	delete mc.onEnterFrame;
	mc.onEnterFrame = function() 
	{
		contor++;
		if (contor/nrFrames == delTime)
		{
			deleteMc(mc);
			delete this.onEnterFrame();
		}
	};
}

function deleteMc(mc:MovieClip):Void 
{
	if (mc._parent.hitTest(_xmouse, _ymouse, true) == false)
	{
		mc.mcShape.elastic({_y:25}, speedElastic);
		
		selectedMenu = -1;
		mc._parent.mcTxt.setColor(menuTextColor);
		                                                                                                                                                  
		l = menuArray[mc._parent.nr].submenuNamesArray.length;
		if (l != undefined)
		{
			for (i=0; i<l; i++)
			{
				mc._parent["mcOver"+i].removeMovieClip();
			}
		}
		checkMousePosition(mousePos);
	} 
	else 
	{
		countTime(mc);
	}
}


function replaceChar(c:String, n:String, str:String):String 
{
	var tempArray:Array = str.split(c);
	var str2:String = new String();
	for (var i = 0; i<tempArray.length-1; i++)
	{
		str2 += (tempArray[i]+n);
	}
	
	str2 += tempArray[i];
	return (str2);
}


function checkMousePosition(mc):Void 
{
	var contor = 0;
	delete mc.onEnterFrame;
	mc.onEnterFrame = function()
	{
		contor++;
		if (contor/nrFrames == 2)
		{
			delete this.onEnterFrame();
			
			var isOver = false;
			for (i=0; i<menuArray.length; i++) 
			{
				var mc:MovieClip = HOME.all["mcBut"+i];
				if (mc.hitTest(_xmouse, _ymouse, true) == true)
				{
					isOver = true;
				}
			}
			if (isOver == false) 
			{
				if (selectedMenuLight>=0 && selectedMenuLight != undefined && selectedMenu == -1)
				{
					mprev = msel=selectedMenuLight;
					HOME.all["mcBut"+selectedMenuLight].mcBut.but.onRollOver();
				}
			}
		}
	};
}
Haber si alguien consigue resolver el enigma...
¡Muchas gracias!
  #9 (permalink)  
Antiguo 20/07/2009, 17:43
Avatar de NathanFox  
Fecha de Ingreso: junio-2005
Mensajes: 35
Antigüedad: 18 años, 10 meses
Puntos: 0
Respuesta: Remplazar el GetUrl por GotoandStop en un menu XML

Alguien sabe como sustituir esto:
k = this._parent._parent.nr;
getURL(menuArray[oMenu].getSLA[k], menuArray[oMenu].getSWA[k]);

por un simple GotoandStop a tal frame respecto al xml? Acaso sera imposible? jaja
¡Muchas Gracias!

Última edición por NathanFox; 20/07/2009 a las 18:05
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:42.