16/07/2009, 21:46
|
| | | Fecha de Ingreso: junio-2005
Mensajes: 35
Antigüedad: 19 años, 5 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();
}
}
|