View Full Version : Sen's XML menu - 2 actions?
lunatic
April 4th, 2005, 01:39 PM
Hi all,
I am using Senocular's xml menu from this tutorial:
http://www.kirupa.com/developer/actionscript/xml_dropdown_menu.htm
I have created a couple of my own actions including one that loads an external text file into a dynamic text box.
My question is, is it possible to assign two actions, each with their own variable, to an item in my xml file? So for example if you were to click on a button in the menu it would load a simple message into one textbox using one action/variable combo and also load an external file into another textbox using a different action/variable combo?
How could I achieve this?
thanks :hr:
scotty
April 4th, 2005, 01:49 PM
Create an extra childNode in your xml?
scotty(-:
lunatic
April 4th, 2005, 02:15 PM
Can I do that without having it appear in the menu? I basically new two actions for one button.
:hr:
senocular
April 4th, 2005, 02:30 PM
you will probably have to create a new Action function that will specifically call your two functions. If I remember, the setup of the menu only allows one "variable" to be passed. However, you can pass a list of comma separated parameters that you can use split() with once passed into the double function action. You can then regulate what gets passed where.
variables="1,2,3"
lunatic
April 4th, 2005, 02:51 PM
Okay so for example I've got this right now:
Actions.gotoURL = function(urlVar){
getURL(urlVar, "_blank");
};
Actions.message = function(msg){
message_txt.text = msg;
};
Actions.listURL = function(links){
loadText = new loadVars();
loadText.load(links);
loadText.onLoad = function(success) {
if (success) {
// trace(success);
message_txt.html = true;
message_txt.htmlText = this.linkstxt;
}
}
}
You are saying that I can combine them into one kind of super action that accepts three variables, has three functions (one for each), and then in the xml doc I can just pass any or all of the variables?
:hr:
senocular
April 4th, 2005, 03:00 PM
well for whatever combination you need, you'll need to make a new Action function. Then the variable you pass it will be one single string, but that function will need to divide that string using split so it can extract multiple variables from it. For example
Actions.messageAndGotoURL = function(variableString){
args = variableString.split(",");
message_txt.text = args[0];
getURL(args[1], "_blank");
};
<item name="bob" action="messageAndGotoURL " variables="myMessage,www.kirupa.com"/>
lunatic
April 4th, 2005, 03:16 PM
And so you'd have to have a separate action to do all three? :hugegrin:
Actions.superAction = function(variableString){
args = variableString.split(",");
message_txt.text = args[0];
getURL(args[1], "_blank");
loadText = new loadVars();
loadText.load(args[2]);
loadText.onLoad = function(success) {
if (success) {
// trace(success);
message_txt.html = true;
message_txt.htmlText = this.linkstxt;
}
}
};
<item name="bob" action="superAction" variables="myMessage,www.kirupa.com,files/myfile.txt"/>
Also, by using a comma that means you couldn't have a comma in the myMessage statement eh? Alternatively, can you use anything to split a string? Specify the number 8 or use a * or something?
Sorry for the stupid questions.
:hr:
senocular
April 4th, 2005, 03:22 PM
yeah, you can use anything. a pipe can be common "|" and if you want to be fancy, how about a not "¬" which I use from time to time (usually denotes a new line)
... so long as its a valid character for attributes ;)
lunatic
April 4th, 2005, 03:59 PM
OK, it all makes SENse. Thanks. :love:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.