Adding action to XML Menu
Hello,
I was wondering if anybody would be kind enough to assist me with my actionscript problems. I have acquired a component XML Menu from a site and a tutorial on preloading and transitioning dynamic files. The problem that I am having is that I have no idea on how to link these two items. On the tutorial page, they tell me to make an actions layer and add the following code:
code:
b1.onRelease = function() {
if (_root.section != "profile.swf") {
_root.section = "profile.swf";
_root.transition.gotoAndPlay("closing");
}
};
b2.onRelease = function() {
if (_root.section != "gallery.swf") {
_root.section = "gallery.swf";
_root.transition.gotoAndPlay("closing");
}
};
b3.onRelease = function() {
if (_root.section != "photos.swf") {
_root.section = "photos.swf";
_root.transition.gotoAndPlay("closing");
}
};
That code obviusly is for the basic buttons on the tutorial but I what I need is for the tutorial's loading and transitioning to be triggered by the XML Menu.
Here is the code for the XML menu (theres more but I believe this is the only relevant part):
code:
//--------------------------------------------------
#initclip 1
CollapseButtonClass = ProtoLinkClass();
CollapseButtonClass.inheritFrom(MovieClip);
Object.registerClass("CollapseButton", CollapseButtonClass);
CollapseButtonClass.prototype.init = function() {
if (!this.alpha) {
this.alpha = {start:0, top:100, bottom:0};
}
this.yinactive = this._y;
this.y = this.yinactive;
this.bgObjParams = {width:this.parent._width_, height:this.parent._height_, colour:(this.butType == 'secondary') ? (this.parent.sColour) : (this.parent.pColour), alpha:this.alpha.top, resize:false, applyColour:true};
this.txtObjParams = {x:1, y:1, w:this.parent._width_ - 20, h:this.parent._height_ - 0, applyBground:false, applyFocus:true, title:String(this._name), applyIndent:(this.butType == 'secondary') ? (true) : (false)};
this.id = this.attachMovie("Rectangle", "bg", 1, this.bgObjParams);
this.id = this.attachMovie("TextBox", "txt", 2, this.txtObjParams);
this.active = false;
this.enabled = true;
};
CollapseButtonClass.prototype.onSignal = function() {
if (this.enabled) {
if (!this.active) {
this.butType == 'secondary' ? this.bg.setColour(this.parent.sColour) : this.bg.setColour(this.parent.pColour);
var newOpacity = Mouse.isWithin(this, true) ? this.alpha.top : this.alpha.bottom;
this.bg._alpha = Math.approach(this.bg._alpha, newOpacity);
} else {
this.bg.setColour(this.parent.aColour);
}
if (this._y <> this.y) {
this._y = Math.approach(this._y, this.y);
}
}
};
CollapseButtonClass.prototype.onMouseUp = function() {
if (Mouse.isWithin(this, true)) {
this.parent.sID.playSound(this.butType);
if (this.butType == 'primary') {
this.parent.activateObj(this.uid);
if (this.butAction != null) {
trace("Action specified in XML: " + this.butAction);
}
} else if (this.butType == 'secondary') {
trace("Action specified in XML: " + this.butAction);
}
}
};
#endinitclip
//==================================================
I am not sure if it will be helpful but, here is the sample XML file:
Quote:
<menu>
<item name="Menu1" action="loadClip">
</item>
<item name="Menu2" action="loadClip">
<sub name="SubMenu1" action="loadClip"></sub>
<sub name="SubMenu2" action="loadClip"></sub>
</item>
<item name="Menu3" action="loadClip">
<sub name="SubMenu3" action="loadClip"></sub>
<sub name="SubMenu4" action="loadClip"></sub>
<sub name="SubMenu5" action="loadClip"></sub>
<sub name="SubMenu6" action="loadClip"></sub>
<sub name="SubMenu7" action="loadClip"></sub>
</item>
<item name="Menu4" action="loadClip">
<sub name="SubMenu8" action="loadClip"></sub>
<sub name="SubMenu9" action="loadClip"></sub>
</item>
<item name="Menu5" action="loadClip">
</item>
<item name="Menu6" action="loadClip">
</item>
</menu>
Thanks in advance to anybody willing to help.