View Full Version : menuBar and XML - I refuse to believe it!
reyco1
03-12-2005, 02:43 PM
I have searched everywhere on the internet, have spoken to friends... I've been everywhere!
I just refuse to believe that there is no way to make a listener which works properly (or works at all) for an XML populated menuBar component!! Is this a bug on MM's side?! :mad: :confused:
hi and welcome to As.Org
didn't hade any problem whit this !??
let's take a look to your code so we can debuge it
reyco1
03-12-2005, 03:13 PM
ok... I populate the menuBar component with teh xmlConnector component. Here's are the contents of the xml file:
<menu>
<menu-title label="Options">
<menu-item label="new" />
<menu-item label="open" />
<menu-item label="print" />
</menu-title>
<menu-title label="edit">
<menu-item label="cut" />
<menu-item label="copy" />
<menu-item label="paste" />
</menu-item>
</menu-title>
</menu>
----------------------------------------------------------------------------------
Here is a sample of the listener I use (which dont work):
var listen = new Object();
listen.change = function(evt){
var menu = evt.menu;
var item = evt.menuItem
if (item == menu.newInstance){
myNew();
trace(item);
}else if (item == menu.openInstance){
myOpen()
trace(item);
}
}
myMenu.addEventListener("change",listen);
-------------------------------------------------------------------------
I'm fairly new to this, please don't scold me if the mistakes are big :smile
Hmmm never used the XMLconnector so not sure about it's peculiarities
this is whit out XMLconnector involwed
xml = new XML('<menu><menu-title label="Options"><menu-item label="new" /><menu-item label="open" /><menu-item label="print" /></menu-title><menu-title label="edit"><menu-item label="cut" /><menu-item label="copy" /><menu-item label="paste" /></menu-item></menu-title></menu>');
L = {};
L.change = function(evt) {
trace(evt.menuBar);
trace(evt.menu);
trace(evt.menuItem);
trace(evt.menuItem.attributes.label);
};
L1 = {};
L1.change = function(evt) {
trace("111111111111");
};
L2 = {};
L2.change = function(evt) {
trace("222222222222");
};
My_Menu_Bar.dataProvider = xml.childNodes[0];
My_Menu_Bar.getMenuAt(0).addEventListener("change", L1);
My_Menu_Bar.getMenuAt(1).addEventListener("change", L2);
My_Menu_Bar.addEventListener("change", L);
it shoud also work whit the connector by SURE to apply the listener after the MenuBar is populated!!!
PLS do NOT PM me !!!
woud i get each time a PM from some body i try to help i woudn't come to help
just read the hole day PM's
reyco1
03-13-2005, 04:19 AM
THanks xeef, i'll try that out. But is there anyone in the world that knows how to make a listener for a menuBar populated using the xmlConnector?
I refuse to believe that no one in the world knows how to do this. I cant be a bug.
apply the listener after this event
"XMLConnector.result" shoud work
reyco1
03-14-2005, 05:00 PM
I have tried xmlConnector.result for the past 24 hrs to no avail :(. Can you please post an example code? I'm dying here :(
sorry but never used the xmlconnector
Hmmm
if you suply the FLA + the www.My.xml wich is working sofare i will try to put the
addEventListener("change") part in
reyco1
03-15-2005, 01:36 AM
Hi Xeef:
The fils are here: http://www.geocities.com/reyco1/xmlMenuBar.zip
You will find 2 files, the .fla and a simple xml file. Place the xml file in your c:\ drive (works locally) and test the fla file. You'll see that the menubar is populated, but then i have no listener for it :(. See what you can do man and thanks alot for your help.
reyco1
03-18-2005, 02:41 AM
I still refuse to believe that there is no way to make a listener which works properly (or works at all) for an XML populated menuBar using the xmlConnector component!!
CyanBlue
03-18-2005, 03:02 AM
Then don't believe it... I don't see any harm on that... ;)
Please use more descriptive topic next time... :(
reyco1
03-18-2005, 03:16 AM
CyanBlue: can you make this work offline? http://www.geocities.com/reyco1/xmlMenuBar.zip
I rest my case..
CyanBlue
03-18-2005, 05:09 AM
Well... It's all yours whether you rest your case or not, but stop refusing it... Accept the fact...
http://www.actionscript.org/forums/showthread.php3?t=67731
reyco1
03-18-2005, 08:49 AM
CyanBlue says: "I just noticed that this is the crosspost... DO NOT CROSSPOST!!!"
...........................
Ok, I sense a lil aggression here. Relax. I just came seeking assistance, not to "crosspost" or what ever; I simply saw a query similar to mine, tried the solution and even then it didnt work for me. Thats one. Two: It may be working perfectly fine for you, but for me, it's not. If you're willing to help me out, then please see if a listener can be made to have tho following work, if not, then that's also fine. Thank you.
http://www.geocities.com/reyco1/xmlMenuBar.zip
as i was saing you need to do it after the "result" event
xmlConnector.trigger();
var res = function (ev) {
trace("!");
L = {};
L.change = function(evt) {
trace(evt.menuBar);
trace(evt.menu);
trace(evt.menuItem);
trace(evt.menuItem.attributes.label);
};
L1 = {};
L1.change = function(evt) {
trace("111111111111");
};
L2 = {};
L2.change = function(evt) {
trace("222222222222");
};
My_Menu_Bar.getMenuAt(0).addEventListener("change", L1);
My_Menu_Bar.getMenuAt(1).addEventListener("change", L2);
My_Menu_Bar.addEventListener("change", L);
};
xmlConnector.addEventListener("result", res);
DON't FORGET to CHANGE the NAMES to your need !
Kyron
04-09-2005, 12:46 AM
I do feel your pain! The examples, etc. that they included for the menu, basically, suck. Here is what I did to get everything wired up [without writing any of that crappy code] in Flash MX Pro 7.2 [i believe]:
0) this was all done with a "Flash Form Application"
1) Create an XMLConnector
2) Set the URL to the correct location of your XML Document that you want to feed your menu.
3) I set it to "receive" only, give it some kind of name
4) Select the connector, select the schema tab of the "Component Inspector" and click the Import a Sample..." button. Find the same XML file and let it import [not 100% sure this is needed)
5) Add a menu bar, call it something. DO NOT freaking delete it
6) Select the xmlconnector again
7) select the Binding tab
8) click the "+"; select the root "results:XML"
9) now the "results" should be added to the bindings; now select "bound to" and find your menubar
10) last [and I would sure hope there is a better way to do THIS], open the "Timeline", select "layer 1:1" and then add "this.xmlMenu.trigger();" where xmlMenu is the name of your connector.
When you run it, it SHOULD populate the menu with all of the menu you desire.
then, just select the menubar, add an "on(change)" event and do your menu handling [I haven't gotten past this point quite yet].
I hope that this helps a little. This drove me crazy.
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.