FLASH + XML structure drop-down menu

Source: Internet
Author: User

The code in AS is AS follows:

// Fixed size, disable scaling
Fscommand ("allowscale", "false ");
// Create a new empty XML object
Var my_xml: XML = new XML ();
// Cancel blank node output
My_xml.ignoreWhite = true;
// Load xml
My_xml.load ("http://www.111cn.net/taoshaw/study/xml_listxiala/List.xml ");
// Determine whether the load is successful. If the load is successful, proceed.
My_xml.onLoad = function (OK: Boolean ){
If (OK ){
Xml_Length = my_xml.firstChild.childNodes.length;
// Read the length of the xml subnode
For (I = 0; I <xml_Length; I ++ ){
_ Root. attachMovie ("mc", "mc" + I, I );
_ Root ["mc" + I]. _ y = 100;
_ Root ["mc" + I]. _ x = I * 70 + 110;
_ Root ["mc" policiunc.txt = my_xml.firstChild.childNodes [I]. attributes. nume;
// Read the menu name
    }
// Set the menu based on the subnode
} Else {
Trace ("failed to load XML! ");
  }
};
_ Root. onMouseDown = function (){
For (I = 0; I <xml_Length; I ++ ){
Xml_lengh2 = my_xml.firstChild.childNodes [I]. childNodes. length;
If (_ root ["mc" + I]. hitTest (_ root. _ xmouse, _ root. _ ymouse )){
If (my_xml.firstChild.childNodes [I]. hasChildNodes ()){
For (j = 0; j <xml_leng2; j ++ ){
// Call the sub-menu element
_ Root. attachMovie ("xialamc", "xialamc" + I + j, I + j + 50 );
// Read the sub-menu name
_ Root ["xialamc" + I + j]. subtxt = my_xml.firstChild.childNodes [I]. childNodes [j]. attributes. subnume;
// Set the default coordinates of MC
_ Root ["xialamc" + I + j]. _ x = I * 70 + 168;
_ Root ["xialamc" + I + j]. _ y = j * 30 + 128;
        }
      }
// Otherwise, delete the sub-menu under this menu
} Else {
For (j = 0; j <10; j ++ ){
RemoveMovieClip (_ root ["xialamc" + I + j]);
      }
    }
  }
// Of course, if K is true, open the URL
If (k ){
GetURL (my_urll, _ blank );
  }
};
// The sub-menu of the menu is displayed when the mouse clicks the menu.
_ Root. onMouseMove = function (){
K = false;
// When the mouse clicks the menu, the menu changes color.
For (I = 0; I <xml_Length; I ++ ){
If (_ root ["mc" + I]. hitTest (_ root. _ xmouse, _ root. _ ymouse )){
_ Root ["mc" + I]. gotoAndStop (2 );
} Else {
// Otherwise, it is still the default color
_ Root ["mc" + I]. gotoAndStop (1 );
    }
For (j = 0; j <10; j ++ ){
// The color of the sub-menu is changed when the mouse triggers the sub-menu.
If (_ root ["xialamc" + I + j]. hitTest (_ root. _ xmouse, _ root. _ ymouse )){
_ Root ["xialamc" + I + j]. gotoAndStop (11 );
// Read the url value and assign it to the variable "my_urll"
My_urll = my_xml.firstChild.childNodes [I]. childNodes [j]. attributes. url;
// Set k to true
K = true;
} Else if (_ root ["xialamc" + I + j]. _ currentframe! = 10 & _ root ["xialamc" + I + j]. _ currentframe! = 11 ){
_ Root ["xialamc" + I + j]. play ();
} Else {
// Stop the timeline in xialamc at 10th frames
_ Root ["xialamc" + I + j]. gotoAndStop (10 );
      }
    }
  }
};
Now we can see the effect. Maybe the xml file does not exist.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.