Flash+xml realize picture Switching effect

Source: Internet
Author: User
Tags reset

The effect of flash+xml to achieve picture switching effect, most of the use of shading, masking is not difficult. One of the main difficulties here is loading pictures and parsing XML. The others are simpler.
OK, let's take a look at the process.
1, the Flash file size set to 800*230, here is based on what you want to let flash accounted for how large advertising to decide. For example, you want to flash a little larger, you can be larger. On the contrary, you can set a small point. Set the background to black and then change the frame frequency to 60. Here is not much to say, mainly considering the fluency of animation .
2. Create A new component "MY_MC" and set it to be imported in as. That is, tick at the as link.

1,2

4, the code is as follows:

Unified coding
System.usecodepage = true;
Defining XML
var my_xml:xml = new XML ();
Eliminate spaces
My_xml.ignorewhite = true;
Define an array of pictures
var my_arr:array = new Array ();
Load Picture class
var mycl:moviecliploader = new Moviecliploader ();
Set Start position
var begin_x:number = 0;
var begin_y:number = 0;
Define variables for displaying pictures
var next_x:number = begin_x;
var next_y:number = begin_y;
Set Picture size
var pic_width:number = 670;
var pic_heigth:number = 230;
Define the number of lines per line
var my_num:number = 2;
Loading XML
My_xml.load ("Http://www.taoshaw.com/taoshaw/study/text_dong/MyPhoto.xml");
My_xml.onload = function (Ok:boolean): Void {
if (OK) {
Loadstart ();
} else {
}
};
Current movie clips Create an MC
This.createemptymovieclip ("MC", This.getnexthighestdepth ());
function Loadstart (): Void {
Define XML length
var my_len:number = my_xml.firstChild.childNodes.length;
for (var i:number = 0; i<my_len; i++) {
To write received objects into an array
My_arr.push (MY_XML.FIRSTCHILD.CHILDNODES.ATTRIBUTES.SRC);
Duplicatemovieclip (MC, "MC" +i, 3+i);
This["mc" +i]._x = next_x;
Here is the key to show how the picture is arranged on the stage after loading the picture
Next_x + = Pic_width;
This["mc" +i]._y = next_y;
This is also a key point for multiple lines of display
if (((i+1)%my_num) = = 0) {
next_x = begin_x;
Next_y + = Pic_heigth;
}
Mycl.loadclip (My_arr, this["MC" +i));
}
}

The main use of the Moviecliploader class, as well as XML classes. parsed according to XML. Then use the previous one to load multiple pictures. Here, the method that allows the components loaded into the scene to be displayed at different locations is primarily used to allow the _x coordinates to be replaced with a variable, which is invariant accumulator to determine. And let the loaded picture is divided into multiple lines, it is used. When the length of the XML is divided by the set value. If this value is 0, wrap it in another line. Another way to wrap the line. is to reset the value of the _y. Let the value of _y be superimposed.
5, and then create a new script component. It is then used to add code inside. Used to control the position of the MC in the scene movement.

4, the code is as follows:

Unified coding
System.usecodepage = true;
Defining XML
var my_xml:xml = new XML ();
Eliminate spaces
My_xml.ignorewhite = true;
Define an array of pictures
var my_arr:array = new Array ();
Load Picture class
var mycl:moviecliploader = new Moviecliploader ();
Set Start position
var begin_x:number = 0;
var begin_y:number = 0;
Define variables for displaying pictures
var next_x:number = begin_x;
var next_y:number = begin_y;
Set Picture size
var pic_width:number = 670;
var pic_heigth:number = 230;
Define the number of lines per line
var my_num:number = 2;
Loading XML
My_xml.load ("Http://www.taoshaw.com/taoshaw/study/text_dong/MyPhoto.xml");
My_xml.onload = function (Ok:boolean): Void {
if (OK) {
Loadstart ();
} else {
}
};
Current movie clips Create an MC
This.createemptymovieclip ("MC", This.getnexthighestdepth ());
function Loadstart (): Void {
Define XML length
var my_len:number = my_xml.firstChild.childNodes.length;
for (var i:number = 0; i<my_len; i++) {
To write received objects into an array
My_arr.push (MY_XML.FIRSTCHILD.CHILDNODES.ATTRIBUTES.SRC);
Duplicatemovieclip (MC, "MC" +i, 3+i);
This["mc" +i]._x = next_x;
Here is the key to show how the picture is arranged on the stage after loading the picture
Next_x + = Pic_width;
This["mc" +i]._y = next_y;
This is also a key point for multiple lines of display
if (((i+1)%my_num) = = 0) {
next_x = begin_x;
Next_y + = Pic_heigth;
}
Mycl.loadclip (My_arr, this["MC" +i));
}
}

The main use of the Moviecliploader class, as well as XML classes. parsed according to XML. Then use the previous one to load multiple pictures. Here, the method that allows the components loaded into the scene to be displayed at different locations is primarily used to allow the _x coordinates to be replaced with a variable, which is invariant accumulator to determine. And let the loaded picture is divided into multiple lines, it is used. When the length of the XML is divided by the set value. If this value is 0, wrap it in another line. Another way to wrap the line. is to reset the value of the _y. Let the value of _y be superimposed.
5, and then create a new script component. It is then used to add code inside. Used to control the position of the MC in the scene movement.

4, the code is as follows:

Unified coding
System.usecodepage = true;
Defining XML
var my_xml:xml = new XML ();
Eliminate spaces
My_xml.ignorewhite = true;
Define an array of pictures
var my_arr:array = new Array ();
Load Picture class
var mycl:moviecliploader = new Moviecliploader ();
Set Start position
var begin_x:number = 0;
var begin_y:number = 0;
Define variables for displaying pictures
var next_x:number = begin_x;
var next_y:number = begin_y;
Set Picture size
var pic_width:number = 670;
var pic_heigth:number = 230;
Define the number of lines per line
var my_num:number = 2;
Loading XML
My_xml.load ("Http://www.taoshaw.com/taoshaw/study/text_dong/MyPhoto.xml");
My_xml.onload = function (Ok:boolean): Void {
if (OK) {
Loadstart ();
} else {
}
};
Current movie clips Create an MC
This.createemptymovieclip ("MC", This.getnexthighestdepth ());
function Loadstart (): Void {
Define XML length
var my_len:number = my_xml.firstChild.childNodes.length;
for (var i:number = 0; i<my_len; i++) {
To write received objects into an array
My_arr.push (MY_XML.FIRSTCHILD.CHILDNODES.ATTRIBUTES.SRC);
Duplicatemovieclip (MC, "MC" +i, 3+i);
This["mc" +i]._x = next_x;
Here is the key to show how the picture is arranged on the stage after loading the picture
Next_x + = Pic_width;
This["mc" +i]._y = next_y;
This is also a key point for multiple lines of display
if (((i+1)%my_num) = = 0) {
next_x = begin_x;
Next_y + = Pic_heigth;
}
Mycl.loadclip (My_arr, this["MC" +i));
}
}

The main use of the Moviecliploader class, as well as XML classes. parsed according to XML. Then use the previous one to load multiple pictures. Here, the method that allows the components loaded into the scene to be displayed at different locations is primarily used to allow the _x coordinates to be replaced with a variable, which is invariant accumulator to determine. And let the loaded picture is divided into multiple lines, it is used. When the length of the XML is divided by the set value. If this value is 0, wrap it in another line. Another way to wrap the line. is to reset the value of the _y. Let the value of _y be superimposed.
5, and then create a new script component. It is then used to add code inside. Used to control the position of the MC in the scene movement.

10, and then a new mask layer. In which you draw some circle effects with the Ellipse tool. The effect here is to draw casually. As long as the canvas is not completely covered. Because the canvas was completely obscured. Will allow the MC in the scene to not be able to achieve the masking effect

11, here, this meaning to tell you. The main use of the first in the scene to display part of the content. Then we can use the mouse to move the button to the other layer of the MC control. To achieve the purpose of alternating display MC.
12. Right click on this layer, select cover. This means: Use the components in the new layer in step nine to mask the STRIP3.
13, new six button bar. Because only six pictures are made here. And in the XML inside of the picture, there are only six pieces. So only six buttons were made. As for the process of setting up a button, I am no longer stating it. This should be very simple.

14, a new as layer, this time there are two parts need to pay attention to. Home a bit. Drag the component created by the earlier step v into the scene and set the instance name "script."
15, select the key frame, add code:

================ Copyright notice begins ================//
★ Amoy Sand Net: http://www.taoshaw.com
★ All the tutorials in the sand net are welcome to reprint. But please indicate the source when you reprint it. Thank you for your cooperation.
================ Copyright Statement End ================//
Create a New Right button menu
MyMenu = new ContextMenu ();
Hide Right click menu
Mymenu.hidebuiltinitems ();
MyMenu.customItems.push (New Contextmenuitem ("Amoy: http://www.taoshaw.com", PR));
Stage.scalemode = ' Noscale ';
function PR (obj, item) {
GetURL ("http://www.taoshaw.com", "_blank");
}
Give the new menu to the scene
_root.menu = MyMenu;
Stop ();
My_btn1.onrollover = function (): Void {
Script.targetx = 130;
script.targety = 0;
Script.baserate = 2;
Script.gotoandplay (5);
};
My_btn2.onrollover = function (): Void {
Script.targetx = 130;
Script.targety =-230;
Script.baserate = 2;
Script.gotoandplay (5);
};
My_btn3.onrollover = function (): Void {
Script.targetx = 130;
Script.targety =-460;
Script.baserate = 2;
Script.gotoandplay (5);
};
My_btn4.onrollover = function (): Void {
Script.targetx =-540;
script.targety = 0;
Script.baserate = 2;
Script.gotoandplay (5);
};
My_btn5.onrollover = function (): Void {
Script.targetx =-540;
Script.targety =-230;
Script.baserate = 2;
Script.gotoandplay (5);
};
My_btn6.onrollover = function (): Void {
Script.targetx =-540;
Script.targety =-460;
Script.baserate = 2;
Script.gotoandplay (5);
};

At this point, the animation is finished. Because this is the main explanation, how to parse, and how to load pictures, so the other features temporarily. You can try, add a link to the picture, and add the link target through the XML.

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.