FLASH + XML Job Resume production tutorial (i)

Source: Internet
Author: User
Tags array length comparison
xml| Tutorial

A friend introduced a company a few days ago. It turns out that three things are missing: a resume, a highly technical work, and self-confidence. So I want to be a "technical resume." This can also some emboldened, more self-confidence. When people ask me if I understand OOP, I don't have to say, "Learning is learning, never doing it".

First, the learned AS2.0 object-oriented programming to digest and absorb, and then use two days to do this resume. Provide the source file download as usual. The first "OOP", wrote the last code a little messy.

These two days write code to write a headache. To borrow a book: "Programming is a very boring and difficult thing for many people, and programming is a very interesting thing when it's a strong interest." "When debugging a Half-day bug finally solves when the complex function finally realizes, that kind of joy is definitely a kind of enjoyment."

This joy is too extravagant for me. I abhor the present system of education, and let me waste my time on things which are of no interest or usefulness, and abhor the morbid society which values such a diploma that I have to bow down to my abhorrence!

  Browsing effects

   Click here to download the source file

When I did this resume, a friend who downloaded the source code of the Fool's tribal home asked me questions about XML. I said you wait, do the things on hand I'll write a tutorial for you. Now take the XML of this resume for example, and say how to parse XML. (→ View xml)

An XML file is like a tree-shaped directory. The first line can be regarded as the "land" in which it takes root.

<?xml version= ' 1.0 ' encoding= ' UTF-8 '?>

The XML file is composed of nodes. Its first node is the "root node." An XML file must have and only one root node, and all other nodes must be its child nodes. When we parse XML using XML objects in Flash, this represents the entire XML file, and its root node is this.firstchild. This.firstChild.childNodes returns an array of nodes consisting of all the child nodes of the root node.

Each child node can have its own child nodes. The node number starts with 0, the first child node of the root node is this.firstchild.childnodes[0], and its child node array is this.firstchild.childnodes[0].childnodes.

Continue deep into a single node without a child node, such as the second child node of the first child node of the root node, this.firstchild.childnodes[0].childnodes[1], which returns an XML object. It should be noted here that the data between the node tags is also considered a node this.firstchild.childnodes[0].childnodes[1].firstchild, not a value.

The ultimate goal of parsing XML, of course, is to get the value of the data: This.firstchild.childnodes[0].childnodes[1].firstchild.nodevalue. Attention! Not This.firstchild.childnodes[0].childnodes[1].nodevalue! Node names are sometimes the data we need: This.firstchild.childnodes[0].childnodes[1].nodename. Note that the comparison obtains the difference between the node name and the node value.

In addition to being a child node, data can also be used as a node property. Node properties are written inside the node tag:< node Property 1 = "Property Value" Property 2 = "Property value" ... > Node value </node >. If the data is full as a property and does not have a node value, it can be written in the form of a < Node property = "Property value"/> Rather than written as a < node property = "Property value" ></node >. Note that the node must be closed, written in < node attribute = "Property value" > is wrong.

All properties of the node return a common object, such as all properties of the third child node of the sixth child node of the root node: this.firstchild.childnodes[5].childnodes[2].attributes. Get the Address attribute: this.firstchild.childnodes[5].childnodes[2].attributes. Address.

In comparison, data is better as a property. The resolution is faster because the files are relatively small and avoid further layers of child nodes.

Below is a resume of the Jobxmlmodel Class (model) to see the specific analysis in Flash. The Jobxmlmodel class inherits the XML class, and first sets the Ignorewhite property to true in the constructor to ignore the extra spaces in the XML file.

Constructors
Public Function Jobxmlmodel () {
Ignorewhite = true;
}
The OnLoad event that overrides the XML class
Private Function OnLoad (): Void {
Variable Tmpa a node array that stores the root node.
var tmpa:array = this.firstChild.childNodes;
The length of the Tmpa is stored in the Tmpl variable.
var tmpl:number = tmpa.length;
As an example of the first and sixth child nodes of the root node, the array length variable is also stored
var basicinfol:number = tmpa[0].childnodes.length;
var myworksl:number = tmpa[5].childnodes.length;
The node name of the root knot node is stored in an array
for (var i:number = 0; i<tmpl; i++) {
List of projects. push (Tmpa[i].nodename);
}
The first child node data as a child node
for (var i:number = 0; i<basicinfol; i++) {
A single node returns an XML object, storing it with a variable tmpo
var tmpo:object = tmpa[0].childnodes[i];
The name and node values of each node are in the array as the properties of the generic Object (object)
Basic information. Push ({title:tmpO.nodeName, content:tmpO.firstChild.nodeValue});
}
Sixth child node data as a node property
for (var i:number = 0; i<myworksl; i++) {
var tmpo:object = tmpa[5].childnodes[i];
Attribute the node name and node attributes as common objects in an array
My work. Push ({url:tmpO.attributes. Address, Name:tmpO.nodeName, desc:tmpO.attributes. description});
}
Broadcast the OnLoad event and receive the data load view class (Jobview) by the Jobpresenter class (the representation)
Broadcastmessage ("onxmlloaded");
}
Implicitly gets a function for the presentation to accept data
Public function Get Basicinfo (): Array {
return basic information;
}



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.