Codice PHP:
#include "mc_tween2.as"
import flash.filters.DropShadowFilter;
var loader:Object = new MovieClipLoader();
loader.onLoadStart = function (t:MovieClip) {
t._parent.loader_mask._width = 0;
t._parent.loader_mask._height = items[t._parent.index].dim.height;
t._parent.pct_field.alphaTo(100, 0.5);
}
loader.onLoadProgress = function (t:MovieClip, bl:Number, bt:Number) {
var p:Number = Math.floor((bl/bt)*100);
t._parent.pct_field.label.text = p+"%";
}
loader.onLoadComplete = function (t:MovieClip) {
t.setMask(t._parent.loader_mask);
var w = items[t._parent.index].dim.width;
t._parent.loader_mask.tween("_width",w,1,"easeOutExpo",0.2);
t._parent.pct_field.alphaTo(0, 0.5);
}
function burnBox (t:MovieClip, n:String, l:Number, w:Number, h:Number, b:Number):MovieClip {
var m:MovieClip = t.createEmptyMovieClip(n, l); // return
m.childCollection = []; // child collection
m.childCollection.push(m.createEmptyMovieClip("background", 0)); // background
m.childCollection.push(m.createEmptyMovieClip("back_text", 1)); // back_text
m.childCollection.push(m.createEmptyMovieClip("back_content", 2)); // back_content
m.childCollection.push(m.attachMovie("field", "title_field", 3, {_x:4, _y:4})); // title_field
m.childCollection.push(m.createEmptyMovieClip("loader", 4)); // loader
m.childCollection.push(m.createEmptyMovieClip("loader_mask", 5)); // loader_mask
m.childCollection.push(m.attachMovie("field", "pct_field", 6, {_x:4, _y:31, _alpha:0})); // pct_field
m.childCollection[0].drawRect(w+4, h+31, 0xFFFFFF); m.childCollection[0].filters = [new DropShadowFilter(5, 45, 0, .2)];
m.childCollection[1].drawRect(w, 25, 0x000000); m.childCollection[1]._x = m.childCollection[1]._y = 2; m.childCollection[1]._alpha = 0;
m.childCollection[2].drawRect(w, h, b); m.childCollection[2]._x = 2; m.childCollection[2]._y = 29;
m.childCollection[3].label.text = n.toUpperCase();
m.childCollection[4]._x = 2; m.childCollection[4]._y = 29;
m.childCollection[5].drawRect(w, h, 0); m.childCollection[5]._x = 2; m.childCollection[5]._y = 29; m.childCollection[5]._width = 0;
return m;
}
MovieClip.prototype.drawRect = function (w:Number, h:Number, c:Color) {
this.beginFill(c, 100);
this.lineTo(w, 0);
this.lineTo(w, h);
this.lineTo(0, h);
this.lineTo(0, 0);
this.endFill();
}
var wdt:Number = 75;
var hgt:Number = 70;
var items:Array = [];
items.push({mc: burnBox(this, "MOTTA", 1, wdt, hgt, 0xCCCCCC), ext: "ext01.swf", dim: {width: 300, height:200}});
items.push({mc: burnBox(this, "RINALDI", 2, wdt, hgt, 0xCCCCCC), ext: "ext02.swf", dim: {width: 350, height:220}});
items.push({mc: burnBox(this, "TVERDE", 3, wdt, hgt, 0xCCCCCC), ext: "ext03.swf", dim: {width: 200, height:400}});
items.push({mc: burnBox(this, "TRICOLOR", 4, wdt, hgt, 0xCCCCCC), ext: "ext04.swf", dim: {width: 400, height:500}});
items[0].mc._x = 10;
for (var i:Number=0; i<items.length; i++) {
items[i].mc._y = 10;
items[i].mc.index = i;
items[i].mc.onRollOver = function () {
this.childCollection[0].tween(["_width","_height"],[wdt+24,hgt+41],0.3,"easeOutBack");
this.childCollection[2].tween(["_width","_height"],[wdt+20,hgt+10],0.3,"easeOutBack")
this.childCollection[1].tween("_width",wdt+20,0.3,"easeOutBack")
this.childCollection[1].alphaTo(100,0.3);
this.childCollection[3].label.colorTo("0xFFFFFF",0.3,"easeOutExpo")
}
items[i].mc.onRollOut = function () {
this.childCollection[0].tween(["_width","_height"],[wdt+4,hgt+31],0.5,"easeOutBack");
this.childCollection[2].tween(["_width","_height"],[wdt,hgt],0.5,"easeOutBack")
this.childCollection[1].tween("_width",wdt,0.5,"easeOutBack")
this.childCollection[1].alphaTo(0,0.5);
this.childCollection[3].label.colorTo("0x000000",0.5,"easeOutExpo")
}
items[i].mc.onRelease = function () {
this.enabled = false;
var w = items[this.index].dim.width;
var h = items[this.index].dim.height;
var u = items[this.index].ext;
this.childCollection[0].tween(["_width","_height"],[w+4,h+31],0.5,"easeOutBack");
this.childCollection[2].tween(["_width","_height"],[w, h],0.5,"easeOutBack")
this.childCollection[1].tween("_width",w,0.5,"easeOutBack")
this.childCollection[1].alphaTo(100,0.5);
this.childCollection[3].label.colorTo("0xFFFFFF",0.5,"easeOutExpo");
loader.loadClip(u, this.childCollection[4]);
resetAll(this.index);
}
}
function resetAll (index) {
for (var j:Number=0; j<items.length; j++) {
if (j != index) {
items[j].mc.enabled = true;
items[j].mc.onRollOut();
loader.unloadClip(items[j].mc.childCollection[4]);
items[j].mc.childCollection[5]._width = 0;
}
}
}
this.onEnterFrame = function() {
for (var k:Number=1; k<items.length; k++) {
var l = k-1;
items[k].mc._x = items[l].mc._x+items[l].mc.childCollection[0]._width+10;
}
}
Il clip in libreria ha un textfield dinamico dentro, con nome "label" e una riga di codice nel primo ed unico frame:
Codice PHP:
items.push({mc: burnBox(this, "MOTTA", 1, wdt, hgt, 0xCCCCCC), ext: "ext01.swf", dim: {width: 300, height:200}});
items.push({mc: burnBox(this, "RINALDI", 2, wdt, hgt, 0xCCCCCC), ext: "ext02.swf", dim: {width: 350, height:220}});
items.push({mc: burnBox(this, "TVERDE", 3, wdt, hgt, 0xCCCCCC), ext: "ext03.swf", dim: {width: 200, height:400}});
items.push({mc: burnBox(this, "TRICOLOR", 4, wdt, hgt, 0xCCCCCC), ext: "ext04.swf", dim: {width: 400, height:500}});
Ogni riga aggiunta creerà un nuovo pulsante a cui potrai dare le varie caratteristiche (dovrebbero essere facilmente comprensibili guardando il file originale).