voici le code du fla
function Item(name,parent,pos,page,trgt) {
this.name = name;
this.deployed = false;
this.page = page;
this.trgt = trgt;
this.arSubItems = new Array();
if (typeof parent == 'object') {
this.parent = parent;
this.root = this.parent.root;
this.level = parent.level+1;
this.id = parent.id + "_" + pos;
} else if (typeof parent == 'movieclip') {
this.parent = parent;
this.root = this;
this.level = 0;
this.id = "0";
}
if (pos != undefined) {
this.pos = pos;
} else {
this.pos = null;
}
this.getDepth = function () {
if (this.level > 0) {
return (this.pos+1)*Math.pow(10,this.level) + this.parent.getDepth();
} else {
return 0;
}
}
this.addSubItem = function(name,page,trgt) {
var newLg = this.arSubItems.push(new Item(name,this,this.arSubItems.length,page,trgt));
return this.arSubItems[newLg-1];
}
this.display = function() {
if (this.level > 0) {
this.root.parent.createEmptyMovieClip("item_" + this.id,100+Number(this.getDepth()));
this.clip = this.root.parent["item_" + this.id];
this.clip._visible = false;
this.clip._x = 0;
this.clip._y = this.root.parent.viewHeight+20;
this.clip.item = this;
this.clip.elasticTo = function(y) {
this.backy = y;
this.onEnterFrame = function() {
this.speedy = Number(this.speedy*this.item.root.parent.ralenti)+Number((this.backy-this._y)*this.item.root.parent.cool);
if (this.item.root.parent.viewHeight != null) {
this._visible = (this._y < this.item.root.parent.viewHeight-this.item.root.parent.itemSpacing);
}
this._y += Number(this.speedy);
if (Math.abs(this.speedy) < 0.1) {
this._y = this.backy;
this.onEnterFrame = null;
}
}
}
this.clip.createEmptyMovieClip("bg",1);
this.clip.bg.beginFill(this.root.parent.itemColor,this.root.parent.itemAlpha);
this.clip.bg.moveTo(0,0);
this.clip.bg.lineTo(this.root.parent.viewWidth,0);
this.clip.bg.lineTo(this.root.parent.viewWidth,20);
this.clip.bg.lineTo(0,20);
this.clip.bg.endFill();
this.clip.createTextField("labelZone",2,5+15*this.level,0,this.root.parent.viewWidth-(5+15*this.level),20);
this.clip.label = this.name;
this.clip.labelZone.selectable = false;
this.clip.labelZone.variable = "label";
this.clip.labelZone.setTextFormat(this.root.parent.unDeployedFormat);
var btParams = new Object();
btParams._alpha = 0;
this.clip.bg.duplicateMovieClip("bt",6,btParams);
this.clip.bt._width = this.root.parent.viewWidth;
this.clip.bt._height = 20;
this.clip.bt.enabled = true;
// Initialise l'action du bouton
if (this.arSubItems.length == 0) {
if (this.page != undefined && this.page != null) {
if (this.trgt == undefined || this.trgt == null) {
this.clip.bt.onRelease = function() {
getURL(this._parent.item.page);
}
} else {
this.clip.bt.onRelease = function() {
getURL(this._parent.item.page,this._parent.item.trgt);
}
}
}
} else {
this.clip.bt.onRelease = function() {
this._parent.item.switchStatus();
}
}
}
for (var i=0;i<this.arSubItems.length;i++) {
this.arSubItems[i].display();
}
}
this.unDeploy = function() {
if (this.deployed) {
for (var i=0;i<this.arSubItems.length;i++) {
this.arSubItems[i].unDeploy();
this.arSubItems[i].clip.elasticTo(this.root.parent.viewHeight+20);
}
this.clip.stClip.gotoAndPlay("undeployed");
this.clip.labelZone.setTextFormat(unDeployedFormat);
this.deployed = false;
this.moveAfter(-1*this.arSubItems.length);
}
}
this.unDeployExcept = function() {
// Si je ne suis pas la racine ....
if (this.level > 0) {
for (var i=0;i<this.parent.arSubItems.length;i++) {
if (i != this.pos) {
this.parent.arSubItems[i].unDeploy();
}
// Et je dis à mon parent de faire la même chose pour lui
this.parent.unDeployExcept();
}
}
}
// Methode qui "déplie" les sous-items d'un menu
this.deploy = function() {
// Si je ne suis pas déplié
if (!this.deployed) {
var supPos = 0;
// Je descends les items qui me suivent du nombre de sous-items
// que je contient
this.moveAfter(this.arSubItems.length);
// Je replie toutes les branches sauf moi
this.unDeployExcept();
// Je calcule la position de départ de mes sous-items
// (la position de mon clip + 1 élément)
if (this.level > 0) {
supPos = this.clip.backy + this.root.parent.itemSpacing;
}
// Je fais venir mes sous-items vers moi
for (var i=0;i<this.arSubItems.length;i++) {
this.arSubItems[i].clip.elasticTo(supPos + i*this.root.parent.itemSpacing);
}
|