Hello,
I have a pretty simple straight-forward question. I searched the postboards and could not find anything, but I may have over looked it. I have created (or took an already created and modified) an xml drop down menu. I would like my buttons to link with-in my flash file, but I do not believe you can link within flash using xml, but is there something in your actionscript that you could have the buttons link within the flash file. Here is my AS that is on the first frame:
/**************\
Xml Menu_v2
By hga77
20/02/2004
\**************/
stop();
var XMLfile = "xmlstuff/menu.xml";
importXML = new XML();
importXML.varTarget = this;
importXML.ignoreWhite = true;
importXML.onLoad = function (success)
{
if (success)
{
var vt = this.varTarget;
var root = this.firstChild;
vt.menuObj = new Object();
var i;
var j;
var k;
var m;
(i = root.lastChild, j = 1);
while (i != null)
{
vt.menuObj["item" + j] = new Object();
vt.menuObj["item" + j].name = i.attributes.name;
vt.menuObj["item" + j].action = typeof(i.attributes.action) == "undefined" ? null : i.attributes.action;
vt.menuObj["item" + j].sub = false;
if (i.hasChildNodes())
{
vt.menuObj["item" + j].sub = true;
(k = i.lastChild, m = 1);
while (k != null)
{
vt.menuObj["item" + j]["sub" + m] = new Object();
vt.menuObj["item" + j]["sub" + m].name = k.attributes.name;
vt.menuObj["item" + j]["sub" + m].action = k.attributes.action;
(k = k.previousSibling);
m++;
}
}
(i = i.previousSibling);
j++;
}
_global.Number_Items = j - 1;
vt.play();
}
else
{
trace("ERROR PARSING XML");
}
};
importXML.load(XMLfile);
And here is the AS that is on the menu movie clip:
onClipEvent (load) {
function executeAction(action)
{
//loadMovie(action, _parent.contentHolder);
mc.changeAlpha(0, false, action);
//
// Uncomment the above line to get the menu working
// and add a content mc on the stage (with the instance name "content") to
// load in your stuff (swf's, jpg's, etc).
//
}
MovieClip.prototype.changeAlpha = function(alphaTo, theLoader, action)
{
this.onEnterFrame = function()
{
if(this._alpha > alphaTo)
{
this._alpha -= 10;
if(this._alpha <= alphaTo)
{
if(!theLoader)preload(action);
delete this.onEnterFrame;
}
}
else if(this._alpha < alphaTo)
{
this._alpha += 10;
if(this._alpha >= alphaTo) delete this.onEnterFrame;
}
}
}
function preload(thePath)
{
mc.loadMovie(thePath);
_parent.attachMovie("loader", "loader", 101);
_parent.loader._x = 390;//loader x position
_parent.loader._y = 270;//loader y position
this._parent.onEnterFrame = function()
{
l = Math.round(mc.getBytesLoaded());
t = Math.round(mc.getBytesTotal());
getPercent = l/t;
//this._parent.loader.loadText = Math.round(getPercent*100)+"%";
if (l>0 && l>=t)
{
_parent.loader.changeAlpha(0, true);
mc.changeAlpha(100);
delete this.onEnterFrame;
}
}
}
function selectItem(item) {
if (this[item].action != null && curItem != item) {
executeAction(this[item].action);
}
if (this[item].sub == false || curItem == item) {
curItem = null;
removeSub();
} else {
curItem = item;
buildSub(item);
}
}
function buildSub(item) {
var i;
var s;
var j;
var d = 0;
this.attachMovie("subholder", "subholder", 100);
var k = this.subholder;
var total_subs = 0;
var correct_item = (Number_Items-item)+1;
for (i in menuObj["item"+correct_item]) {
if (typeof (menuObj["item"+correct_item]) == "object" && i != "sub" && i != "action") {
total_subs++;
}
}
var Present_sub = total_subs-1;
for (i=1; i<total_subs; i++) {
k.attachMovie("sub", i, d);
s = k*;
s.name = menuObj["item"+correct_item]["sub"+Present_sub].name;
s.action = menuObj["item"+correct_item]["sub"+Present_sub].action;
s._x = 20;
s._y = (s._height+subSpacer)*d;
d++;
Present_sub--;
}
k._y = this[item].basey+this[item]._height+menuSpacer;
var u = 1;
for (i in menuObj) {
j = this[u];
if (this[item]._y<j._y) {
j.target = j.basey+k._height+menuSpacer;
} else {
j.target = j.basey;
}
u++;
}
subs = total_subs;
onenterframe = menuAnimation;
}
function removeSub() {
this.subholder.removeMovieClip();
depth = 1;
for (i in menuObj) {
this[depth].target = this[depth].basey;
depth++;
}
onenterframe = menuAnimation;
}
function menuAnimation() {
var i;
var j;
var k = true;
var depth = 1;
for (i in menuObj) {
j = this[depth];
j._y = j._y+(j.target-j._y)/menuSpeed;
if (menuTolerance<Math.abs(j.target-j._y)) {
k = false;
} else {
j._y = j.target;
}
depth++;
}
if (k) {
onenterframe = null;
if (curItem != null) {
activateSub();
}
}
}
function activateSub() {
var d = 0;
for (i=1; i<subs; i++) {
subholder*.start = getTimer();
subholder*.delay = subDelay*d;
subholder*.gotoAndPlay(2);
d++;
}
}
MovieClip.prototype.activateMenu = function() {
var d = 0;
for (i=1; i<Number_Items+1; i++) {
this*.start = getTimer();
this*.delay = itemDelay*d;
this*.gotoAndPlay(3);
d++;
}
};
mc = _parent.contentHolder;
var menuSpacer = 1;
// sets the vertical space between main items
var subSpacer = 1;
// sets the vertical space between sub items
var menuSpeed = 5;
// sets the menu animation speed
var menuTolerance = 1;
var subDelay = 170;
// set the delay for the sub items entering the stage
var itemDelay = 100;
// set the delay for the main items entering the stage
var curItem = null;
var menuObj = _parent.menuObj;
var onenterframe = null;
var Present_item = Number_Items;
var loop_condition = Number_Items+1;
for (d=1; d<loop_condition; d++) {
this.attachMovie("item", d, d);
k = this[d];
k._x = 20;
k._y = (k._height+menuSpacer)*d;
k.name = menuObj["item"+Present_item].name;
k.action = menuObj["item"+Present_item].action;
k.sub = menuObj["item"+Present_item].sub;
k.basey = k._y;
if (k.sub == false) {
k.icon._visible = false;
}
Present_item--;
}
activateMenu();
//this._parent.contentHolder._alpha = 100;
}
onClipEvent (enterFrame) {
onenterframe();
}
Thanks for your help!