Flash + XML: Build easy update website

xiaoxiao2021-03-06  57

This article is an XML-based Flash website production tutorial, using XML's most basic language description, plus Flash production dynamic interface, fast and easy development of Flash website, the most important thing is to update the Flash website is very convenient , I can modify the XML file. If you want to develop a Flash website that does not support the database space, or if the amount of data is too small, use the database is too awkward, using XML will be the most convenient method. Over, look at the tutorial first.

The purpose of this example is to use Flash to make a design set set (PORTFILIO), which is the working display commonly used in the personal homepage and design companies. Due to work every day, some new works will be placed in the works, and they can always modify the Flash source file and then use the database to do such a small data access. It is too awkward. Used to XML, do not need a database, no space support, as long as there is flash and XML files ....... First look at the simple data sheet design of your personal work:

Field content

Name Design Work Name

Link of SRC design works

Intro simple description

Category of CATE (Website / Animation / Game / Multimedia ..)

Such a database, add a primary key ID, a bit like a database table, but also the way to record these data, then we build a Data.xml file, and write A data description structure similar to this

// Part's code start START

// The first code end

There are several small problems here:

First, I am using Encoding = 'UTF-8', indicating that the data coding is UTF-8. The main benefit of this method is to facilitate reading data in Flash and operate in any language platform (such as Japanese or other country. The system) can be properly displayed in my Chinese word or other text. Of course, it is also possible to use the Chinese coding method of Encoding = 'GB2312-80', but if so, I have to add a syntax to mark it. Since XML is a tree data structure, his grammar is different from our traditional data sheet, and we define ... and . This tag indicates that I am in the previous data table design, in which some of this identification block, that is, items belonging to this classification. Then define each record in the ... such as

The content of a data.

Ok, let's take a look at the preparation of the Flash interface.

OK! The content on the interface is basically so, if you need more features, you will add a variety of MCs.

We write on the first frame of Flash's key grammatical part

// Second section code start

STOP ();

// Load the data.xml file

Infodefault = "";

Showsrc = "";

NowbTnname = "no";

NOWNUM = 0;

Xmlobj = new XML ();

Xmlobj.ignorawhite = true;

XMlobj.Load ("DATA.XML");

// XML file location

Xmlobj.onLoad = function (Success) {

IF (Success) {

TRACE ("XML is successful!");

Parsexml ();

// Analyze the function of XML files

} Else {

Trace ("XML load failed!");

}

}

/ / Establish three arrays to load data in XML

Arr_web = new array ();

Arr_animation = new array ();

Arr_game = new array ();

// Analyze XML file

Function Parsexml () {

// Data of Web, Animation, Game, load three arrays, arr_game, Arr_Game, respectively

Web = Xmlobj.firstchild.childNodes [0] .childnodes;

For (VAR i = 0; i

Arr_web

= New object (); arr_web.info = web.attributes.name; arr_web.src = web.attributes.src;} animation = xmlobj.firstchild.childNodes [1] .childNodes; for (var i = 0; ianimation.length ; i ) {arr_animation = new Object (); arr_animation.info = animation.attributes.name; arr_animation.src = animation.attributes.src;} game = xmlObj.firstChild.childNodes [2] .childNodes; for (var i = 0; Igame.Length; i ) {arr_game = new object (); arr_game.info = game.attributes.name; arr_game.src = game.attributes.src;} // Process, jump into the display page gotoandplay (2) } // Display icon functions, click on a category on the interface, through this function, will be classified as icon in the picture in the picture in the picture, "Arr _" _ root.currcate .length; IF (NOWNUM! = 0) {// Clear the previous set of icons clearico; Arr _ " cate) .length; i ) {fileicon.duplicatemovieClip (" ICO " i, i); Temp = EVAL (" ICO " i); Temp._x = fileiconx; temp._y = fileicony; Temp_name = evAl ("Arr _" cate); Temp.Vari = Temp_name.info; Temp.src = Temp_name.src; // When each icon ROLLOVER, ROLLOVER = Function () {// rollover = function () {// rollover is displayed in the text box in the text box in the text box, proco.text = this.vari;}; Temp.onRollout = Function () {proInfo.text = infodefault;}; temp.onpress = function () {// Press the button on the left. SWF file loadmovie comes in infodefault = this.vari; showsrc = this.src; loadingContent .loadmovie (showsrc);}; fileiconx = 27; // Set the location of each icon, more than 8, change the line icon IF (I% 9 == 8) {fileiconx = 435; fileicony = 28;

转载请注明原文地址:https://www.9cbs.com/read-90958.html

New Post(0)