flash + xml求职简历的制作(二)
第二部分(flash):
class JobView extends MovieClip {
//
//属性
private var bg_mc:MovieClip;
private var txt:String;
private var _id:Number;
private var _currY;
//
//构造函数
private function JobView() {
bg_mc.onRollOver = function() {
_alpha = 30;
};
bg_mc.onRollOut = function() {
_alpha = 20;
};
_y = 0;
}
//
//公共方法
public function moveDown(posY:Number):Void {
_currY = posY;
this.onEnterFrame = function() {
var currY:Number = _y;
var diffY:Number = posY-currY;
var moveY:Number = diffY/5;
if (moveY>0.1) {
_y = currY+moveY;
} else {
_y = posY;
}
};
}
public function moveUp(posY:Number):Void {
_currY = posY;
this.onEnterFrame = function() {
var currY:Number = _y;
var diffY:Number = Math.abs(currY)-Math.abs(posY);
var moveY:Number = diffY/5;
if (moveY>0.1) {
_y = currY-moveY;
} else {
_y = posY;
}
};
}
//
//隐式设置/获取方法
public function get id():Number {
return _id;
}
public function set id(para:Number):Void {
_id = para;
}
public function get currY():Number {
return _currY;
}
public function set currY(para:Number):Void {
_currY = para;
}
}
class UnitView extends JobView {
//
//属性
private var unit_txt:TextField;
private var bg_mc:MovieClip;
//
//构造函数
private function UnitView() {
_x = 130;
bg_mc.useHandCursor = false;
var ss:TextField.StyleSheet = new TextField.StyleSheet();
ss.load("styles.css");
unit_txt.styleSheet = ss;
}
}
class ItemView extends JobView {
//
//属性
private var _openFlag:Number;
private var unitNum:Number;
private var bg_mc:MovieClip;
public var addListener:Function;
public var removeListener:Function;
private var broadcastMessage:Function;
private static var _mixin = AsBroadcaster.initialize(ItemView.prototype);
//
//构造函数
private function ItemView() {
_x = 100;
_openFlag = 1;
unitNum = 0;
var owner = this;
bg_mc.onRelease = function() {
owner.broadcastMessage("onClick", owner._id);
};
}
//
//隐式设置/获取
public function set units(para:Number):Void {
unitNum = para;
}
public function get units():Number {
return unitNum;
}
public function set openFlag(para:Number):Void {
_openFlag = para;
}
public function get openFlag():Number {
return _openFlag;
}
}
import JobXMLModel;
class JobPresenter extends MovieClip {
//
//属性
private var initY:Number = 30;
private var currentY:Number;
private var jobModel:JobXMLModel;
private var itemID:Number = 0;
private var unitID:Number = 0;
private var unitNumA:Array;
private var closeItemArr:Array;
private var closeBottom:Number;
//
//构造函数
private function JobPresenter() {
closeItemArr = new Array();
currentY = initY;
jobModel = new JobXMLModel();
jobModel.load("job.xml");
jobModel.addListener(this);
}
//
//事件函数
private function onXMLLoaded():Void {
unitNumA = [jobModel.basicInfo.length, jobModel.whatJob.length, jobModel.judgeOfMe.length, jobModel.otherInfo.length, jobModel.contactMe.length, jobModel.myWorks.length];
var tmpA:Array = [jobModel.basicInfo, jobModel.whatJob, jobModel.judgeOfMe, jobModel.otherInfo, jobModel.contactMe, jobModel.myWorks];
var tmpL:Number = tmpA.length;
for (var i:Number = 0; i<tmpL; i++) {
loadItem(i);
loadUnit(tmpA[i], i);
}
loadHeadAndBottom();
var tmpY:Number = initY+5;
for (var i:Number = 0; i<tmpL; i++) {
closeItemArr.push(tmpY);
tmpY += 32;
}
closeBottom = tmpY;
}
//
//私有函数
private function loadHeadAndBottom():Void {
var tmpMC:MovieClip;
tmpMC = attachMovie("itemView", "head", 300);
tmpMC._x -= 30;
tmpMC._y = -10;
tmpMC.id = 300;
tmpMC.moveDown(5);
tmpMC.item_txt.htmlText = "求职简历";
//
tmpMC = attachMovie("unitView", "unit"+unitID, 400);
tmpMC.id = 400;
tmpMC._x -= 30;
tmpMC._y = 700;
tmpMC.moveUp(currentY+5);
tmpMC.bg_mc.onRollOver = function() {
};
tmpMC.unit_txt.htmlText = "<a href='http://eidiot.net/article.asp?id=183' target='_blank'>→ 给我留言</a>";
tmpMC.unit_txt.htmlText += "<span class='line'> | </span>";
tmpMC.unit_txt.htmlText += "<a href='http://eidiot.net/job/uml.jpg' target='_blank'>→ 查看UML图</a>";
tmpMC.unit_txt.htmlText += "<span class='line'> | </span>";
tmpMC.unit_txt.htmlText += "<a href='http://eidiot.net/job/job.rar' target='_blank'>→ 下载源文件</a>";
tmpMC.unit_txt.htmlText += "<span class='line'> | </span>";
tmpMC.unit_txt.htmlText += "<a href='http://eidiot.net' target='_blank'>→ VISIT MY BLOG</a>";
tmpMC.unit_txt.htmlText += "<span class='line'> | </span>";
tmpMC.unit_txt.htmlText += "2006-2-25";
}
private function clickHead():Void {
for (var i:Number = 0; i<itemID; i++) {
var tmpMC:MovieClip = this["item"+i];
tmpMC.moveUp(closeItemArr[i]);
tmpMC.openFlag = 0;
tmpMC.arrow_mc.gotoAndStop("closed");
}
for (var i:Number = 0; i<unitID; i++) {
var tmpMC:MovieClip = this["unit"+i];
tmpMC.unit_txt._visible = false;
tmpMC.currY -= 25;
tmpMC.onEnterFrame = function() {
var diffY:Number = Math.abs(this._y)-Math.abs(this.currY);
var moveY:Number = diffY/5;
if (moveY>1 || _alpha<10) {
_y -= moveY;
_alpha -= 10;
} else {
_y = this.currY;
_visible = false;
}
};
}
this["unit"+unitID].moveUp(closeBottom);
}
private function loadItem(i:Number):Void {
var itemL:Number = jobModel.itemArr.length;
var itemMC:MovieClip;
itemMC = attachMovie("itemView", "item"+i, 200-i);
itemMC.units = unitNumA[i];
itemMC.id = i;
itemID++;
itemMC._y = -currentY;
itemMC.moveDown(currentY+5);
currentY += itemMC.bg_mc._height+10;
itemMC.item_txt.htmlText = jobModel.itemArr[i];
itemMC.addListener(this);
}
private function loadUnit(unitArr:Array, itemNum:Number):Void {
var unitL:Number = unitArr.length;
var unitMC:MovieClip;
for (var i:Number = 0; i<unitL; i++) {
unitMC = attachMovie("unitView", "unit"+unitID, 100-unitID);
unitMC.id = unitID;
unitID++;
unitMC._y = 2*currentY;
unitMC.moveUp(currentY);
currentY += unitMC.bg_mc._height+5;
var unitTxt:String;
if (itemNum == 5) {
unitTxt = "<a href='"+unitArr[i].url+"' target='_blank'>"+unitArr[i].name+"</a>";
unitTxt += "<span class='line'> | </span>"+unitArr[i].desc+"<span class='line'> | </span>";
unitTxt += "<a href='"+unitArr[i].url+"' target='_blank'>→ 浏览</a>";
} else if (itemNum == 1 || itemNum == 2) {
unitTxt = unitArr[i].content;
} else {
unitTxt = "<span class='title'>"+unitArr[i].title+"</span>"+"<span class='line'> | </span>"+unitArr[i].content;
}
unitMC.unit_txt.htmlText = unitTxt;
}
}
private function onClick(id:Number):Void {
if (id == 300) {
clickHead();
} else {
var beginMove:Number = 0;
if (id == 0) {
beginMove = 0;
} else {
for (var i:Number = 0; i<id; i++) {
beginMove += this["item"+i].units;
}
}
var clickMC:MovieClip = this["item"+id];
var tmpMC:MovieClip;
if (clickMC.openFlag) {
clickMC.openFlag = 0;
clickMC.arrow_mc.gotoAndStop("closed");
moveThem(id, beginMove, "close");
} else {
clickMC.openFlag = 1;
clickMC.arrow_mc.gotoAndStop("opened");
moveThem(id, beginMove, "open");
}
}
}
private function moveThem(clickID:Number, beginMove:Number, dire:String):Void {
var begin:Number = 0;
var end:Number;
var moveNum:Number;
var moveY:Number;
end = this["item0"].units-1;
if (clickID>0) {
for (var i:Number = 0; i<clickID; i++) {
begin += this["item"+i].units;
}
end = begin+this["item"+clickID].units-1;
}
moveNum = end-begin+1;
moveY = moveNum*25;
if (dire == "close") {
for (var i:Number = begin; i<=end; i++) {
closeUnit(this["unit"+i], clickID);
}
if (clickID<itemID-1) {
for (var i:Number = itemID-1; i>clickID; i--) {
this["item"+i].moveUp(this["item"+i].currY-moveY);
}
for (var i:Number = end+1; i<=unitID; i++) {
this["unit"+i].moveUp(this["unit"+i].currY-moveY);
}
} else {
this["unit"+unitID].moveUp(this["unit"+unitID].currY-moveY);
}
} else {
openUnit(begin, end, clickID);
if (clickID<itemID-1) {
for (var i:Number = itemID-1; i>clickID; i--) {
this["item"+i].moveDown(this["item"+i].currY+moveY);
}
for (var i:Number = end+1; i<=unitID; i++) {
this["unit"+i].moveDown(this["unit"+i].currY+moveY);
}
} else {
this["unit"+unitID].moveDown(this["unit"+unitID].currY+moveY);
}
}
}
private function closeUnit(who:MovieClip, item:Number):Void {
who.unit_txt._visible = false;
var owner = this;
who.onEnterFrame = function() {
_y -= 5;
_alpha -= 10;
if (_y-22<owner["item"+item]._y) {
removeMovieClip(this);
}
};
}
private function openUnit(begin:Number, end:Number, itemNum:Number):Void {
var currentYSec:Number = this["item"+itemNum]._y+27;
var unitIDSec:Number = begin;
var tmpA:Array = [jobModel.basicInfo, jobModel.whatJob, jobModel.judgeOfMe, jobModel.otherInfo, jobModel.contactMe, jobModel.myWorks];
var unitArr:Array = tmpA[itemNum];
var unitMC:MovieClip;
for (var i:Number = 0; i<end-begin+1; i++) {
unitMC = attachMovie("unitView", "unit"+unitIDSec, 100-unitIDSec);
unitMC.id = unitIDSec;
unitIDSec++;
unitMC._y = this["item"+itemNum]._y+20;
unitMC.moveDown(currentYSec);
currentYSec += unitMC.bg_mc._height+5;
var unitTxt:String;
if (itemNum == 5) {
unitTxt = "<a href='"+unitArr[i].url+"' target='_blank'>"+unitArr[i].name+"</a>";
unitTxt += "<span class='line'> | </span>"+unitArr[i].desc+"<span class='line'> | </span>";
unitTxt += "<a href='"+unitArr[i].url+"' target='_blank'>→ 浏览</a>";
} else if (itemNum == 1 || itemNum == 2) {
unitTxt = unitArr[i].content;
} else {
unitTxt = "<span class='title'>"+unitArr[i].title+"</span>"+"<span class='line'> | </span>"+unitArr[i].content;
}
unitMC.unit_txt.htmlText = unitTxt;
}
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |