Flash XML Menu

Hi,

I just made a menu in FMX based on the following XML document :

[AS]
<Navigation>
<menu titel=“Home” link=“10”/>
<menu titel=“About us” link=“11”/>
<menu titel=“Services” link=“12”/>
<menu titel=“Contact” link=“13”/>
</navigation>
[/AS]

The attribute link in this code is to navigate in Flash and it’s working very good! I now want the font color of the buttons to change on rollOver. This is the AC i have in my Flash movie:

[AS]stop();
menuXml = new XML();
menuXml.ignoreWhite =true;
menuXml.onload = function(success){
if(success){
menuItem=this.firstChild.childNodes;
for(x=0;x<menuItem.length;x++){
item=_root.attachMovie(“myMovie”,“myMovie”+x,x);
item._root[“myMovie”+x]._x=(x*150)+50;
item._root[“myMovie”+x]._y=50;
item.itemLabel.text=menuItem[x].attributes.titel;
item.myLink = menuItem[x].attributes.link;
item.onRelease = function() {
gotoAndStop(this.myLink);
}

        }

}
}
menuXml.load(“myMenu.xml”);
[/AS]

What do I have to do in my XML and Flash document to make the fonts change color on rollOver?

Thks
Ps. The AS before and after the XML should be XML

You don’t need to do anything to your XML code. Just use the TextFormat() object in Flash to set the color.

[AS]stop();
//create overColor textFormat
overColor = new TextFormat();
//set the color to red
overColor.color = 0xFF0000;
//create standardColor textFormat
standardColor = new TextFormat();
//set the color to black
standardColor.color = 0x000000;
menuXml = new XML();
menuXml.ignoreWhite =true;
menuXml.onload = function(success){
if(success){
menuItem=this.firstChild.childNodes;
for(x=0;x<menuItem.length;x++){
item=_root.attachMovie(“myMovie”,“myMovie”+x,x);
item._root[“myMovie”+x]._x=(x*150)+50;
item._root[“myMovie”+x]._y=50;
item.itemLabel.text=menuItem[x].attributes.titel;
item.myLink = menuItem[x].attributes.link;
//onRollOver of the clip
item.onRollOver = function(){
//set the textformat of the itemLabel textfield to the overColor textformat object
this.itemLabel.setTextFormat(overColor);
}
//onRollOut of the clip
item.onRollOut = function(){
//set the textformat of the itemLabeltextfield back to the original color using the standardColor textformat object
this.itemLabel.setTextFormat(standardColor);
}
item.onRelease = function() {
gotoAndStop(this.myLink);
}

            }
            
    }

}
menuXml.load(“myMenu.xml”);[/AS]

Note: I didn’t test this, but the theory is still there if you want to expand on it.

Hi,

Thks for the code. I never thought of that. It’s working but there is one problem. Only the last one in the line is working, so no mather over witch button I move only the Contact button is getting red and the same happen onRollOut. Is this because I didn’t declared it in XML? In other words it seems to me that the Loop isn’t made and that Flash see Contact as the current element?

Thks,
Donald:q:

Hmm, it should be working for all of them, I don’t see why it wouldn’t.

Can you .zip and post your files as either an attachment or a link to download them (upload to a server) so I can take a look?

Attached you find the test fla. I don’t know how to attach 2 zip files, so I’ll sent the XML zip seperate.

I hope you see what I did wrong!

Thks

And here is the XML zip

Hi,

I just found out that I made a big mistake!

Instead of:

this.itemLabel.setTextFormat(overColor);
and
this.itemLabel.setTextFormat(standardColor);

my script was

item.itemLabel.setTextFormat(overColor);

 and

item.itemLabel.setTextFormat(standardColor);

Now it’s working very good!
Sorry for the inconvenience!

But you know a lot about this subject as I found out. Maybe your willing to help me a little further?

There is one other things I like to do in the menu:

  1. I like to control Sub menu’s with onRollOver and onRollOut;

Thks

Submenus are quite difficult to add. I am sorry, but I don’t have the time to figure out how to do that for you.

However, I did write an XML Menu once, then the flash god Senocular took over and made it able to be “sub-menued”, if you want to check that out you can find it here…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=13697&perpage=15&pagenumber=4

[edit]your .zip file only contained the .xml file :stuck_out_tongue: So I wouldn’t of been able to help much with the text problem anyway so I am glad you figured that out on your own :slight_smile: [/edit]

Your tips helped me a lot!

Thanks for your patience and time. I now gonna have a look at the link you gave me!

Bye