// as/flash.as #include "navigation.as" /** load the image list array from server */ function loadImageList(){ var _lv:LoadVars = new LoadVars(); _lv.path = this; _lv.command = "list" _lv.sendAndLoad(basePath, _lv, "GET"); _lv.onLoad = function( success ){ if( success ){ var imageList:Array; imageList = sepySerializer.unserialize( this.output ); this.path.buildThumbs( imageList, 10 ); } else { //trace('failed to load thumb list'); } } } /** build the thumbinails */ function buildThumbs( data:Array, cols:Number){ //preloader._visible = false; this.options = { x: this.t_0._x, y: this.t_0._y, nextHeight : this.t_0._height/1.2, _images : data.length, IntervalIndex : 0 } _root.IntervalID = setInterval(makeThumbs, 500, data, this, cols); } function makeThumbs(data, obj:MovieClip, cols:Number){ var a = obj.options.IntervalIndex; var w:Number; var h:Number; var mc:MovieClip; mc = obj.t_0.duplicateMovieClip("t" + (a+1), (a+1)); mc._visible = true mc.data = data[a]; if( a%cols == 0 and a > 0){ obj.options.x = obj.t_0._x obj.options.y += obj.options.nextHeight + (random(10)-5); } mc.x = mc._x = obj.options.x mc.y = mc._y = obj.options.y + (random(10)-5) w = data[a].stat[0] h = data[a].stat[1] if(w > h){ h = 50 w = data[a].stat[0]/(data[a].stat[1]/h) } else { w = 50 h = data[a].stat[1]/(data[a].stat[0]/w) } mc.cont.loadMovie(basePath + "?command=thumb&width=50&height=50&image=" + data[a].image); trace(basePath + "?command=thumb&width=50&height=50&image=" + data[a].image) mc.targetWidth = w + 10 mc.targetHeight = h + 10 if(mc.targetHeight > obj.options.nextHeight){ obj.options.nextHeight = mc.targetHeight/1.2 } mc._visible = false; mc.sfondo_thumb.t_bianco._width = 0; mc.sfondo_thumb.t_bianco._height = 0; mc.cont._alpha = 0; mc.onEnterFrame = function(){ this._visible = true; this.swapDepths( _root.getNextHighestDepth() ); var dx:Number = (this.targetWidth-this.sfondo_thumb.t_bianco._width)/5 var dy:Number = (this.targetHeight-this.sfondo_thumb.t_bianco._height)/5 this.sfondo_thumb.t_bianco._width += dx this.sfondo_thumb.t_bianco._height += dy this.sfondo_thumb.t_nero._width = this.sfondo_thumb.t_bianco._width + 1 this.sfondo_thumb.t_grigio._width = this.sfondo_thumb.t_bianco._width + 3 this.sfondo_thumb.t_nero._height = this.sfondo_thumb.t_bianco._height + 1 this.sfondo_thumb.t_grigio._height = this.sfondo_thumb.t_bianco._height + 3 if(this.cont.getBytesLoaded() >= this.cont.getBytesTotal() && this.cont.getBytesTotal() > 40 && this.cont._width > 4){ if(Math.abs(dx) < .1 and Math.abs(dy) < .1){ this.sfondo_thumb.t_bianco._width = this.targetWidth this.sfondo_thumb.t_bianco._height = this.targetHeight this.sfondo_thumb.t_nero._width = this.sfondo_thumb.t_bianco._width + 1 this.sfondo_thumb.t_grigio._width = this.sfondo_thumb.t_bianco._width + 3 this.sfondo_thumb.t_nero._height = this.sfondo_thumb.t_bianco._height + 1 this.sfondo_thumb.t_grigio._height = this.sfondo_thumb.t_bianco._height + 3 delete this.onEnterFrame; this.onEnterFrame = function(){ if(this.cont._alpha > 100){ activateButton(this); delete this.onEnterFrame obj.options._images--; if(obj.options._images < 1){ obj.preloader._visible = false; } } this.cont._alpha += 5; } } } // if failed to load the image if(this.cont.getBytesTotal() == -1 and this.cont.getBytesLoaded() == -1){ obj.options._images--; if(obj.options._images < 1){ obj.preloader._visible = false; } delete this.onEnterFrame; } } obj.options.x += (mc.targetWidth/1.2 + (random(10)-5)); obj.options.IntervalIndex++ if(obj.options.IntervalIndex >= data.length){ clearInterval(obj.IntervalID); trace('end interval'); } } // makeThumbs /** activate the thumbinail button */ function activateButton(mc:MovieClip){ mc.onPress = function(){ _root.tooltip.removeMovieClip(); this.swapDepths( _root.getNextHighestDepth() ); this.cont._alpha = 50; this.startDrag(false); this.onMouseMove = function(){ if( this.hitTest( _root.zoomed ) ){ var w = _root.zoomed.sfondo.bianco._width var h = _root.zoomed.sfondo.bianco._height _root.zoomed.sfondo.gotoAndStop(2) _root.zoomed.sfondo.border._width = w + 1 _root.zoomed.sfondo.border._height = h + 1 } else { _root.zoomed.sfondo.gotoAndStop(1) } updateAfterEvent(); } } mc.onRelease = mc.onReleaseOutside = function(){ var loadImage; delete this.onMouseMove; _root.zoomed.sfondo.gotoAndStop(1); stopDrag(); if( _root.zoomed.sfondo.hitTest( this._x, this._y, false)){ var name = this.data.image var stat = this.data.stat trace("stat[0]: " + this.data.stat[0]) initNavigation(name, stat) } this.onEnterFrame = function(){ var dx:Number = (this.x-this._x)/5 var dy:Number = (this.y-this._y)/5 this._x += dx this._y += dy if(Math.abs(dx) < .1 and Math.abs(dy) < .1 and this.cont._alpha > 100){ delete this.onEnterFrame this._x = this.x this._y = this.y } this.cont._alpha += 5 } } mc.onRollOver = function(){ _root.attachMovie('tooltip', 'tooltip', _root.getNextHighestDepth()) var tp:MovieClip = _root.tooltip; tp.label.autoSize = "left"; tp.label.text = this.data.title tp._x = _root._xmouse tp._y = _root._ymouse - 10 tp.sfondo._width = tp.label.textWidth + 15 } mc.onRollOut = function(){ _root.tooltip.removeMovieClip(); } } /** actions */ this.t0._visible = false; loadImageList(); stop();