// as/navigation.as function initNavigation(name, stat){ trace('InitNavigation: ' + arguments); var w = stat[0] var h = stat[1] var imageWidth = 600; var prop = w/imageWidth var imageHeight = (h/prop) _root.zoomed.cont.stat = stat toggleCurrent( name, [imageWidth,imageHeight] ); // load main image loadNavigator( name, [imageWidth/5, imageHeight/5] ) // load navigator _root.toLoad = 2 preloader._visible = true } /* desaturate current image */ function toggleCurrent( next, stat ){ _root.zoomed.cont.zoom.removeMovieClip(); var current = _root.zoomed.cont.index; var clip = _root.zoomed.cont['img_' + current] if(clip == undefined){ resizeZoomed( next, stat ); return Void; } clip.onEnterFrame = function(){ if(this._alpha < 0){ delete this.onEnterFrame this.removeMovieClip() resizeZoomed( next, stat ); } this._alpha -= 5; } } /** resize the zoomed clip **/ function resizeZoomed( next, stat ){ trace('resizeZoomed: ' + arguments) var cont:MovieClip = _root.zoomed.cont; var sfondo:MovieClip = _root.zoomed.sfondo; sfondo.tw = contentWidth + 20 sfondo.th = contentHeight + 20 cont.onEnterFrame = function(){ var dx = (sfondo.tw - sfondo.bianco._width)/5 var dy = (sfondo.th - sfondo.bianco._height)/5 sfondo.bianco._width += dx sfondo.bianco._height += dy sfondo.sh1._width = sfondo.bianco._width + 1 sfondo.sh2._width = sfondo.bianco._width + 2 sfondo.sh3._width = sfondo.bianco._width + 2 sfondo.sh1._height = sfondo.bianco._height + 1 sfondo.sh2._height = sfondo.bianco._height + 2 sfondo.sh3._height = sfondo.bianco._height + 2 if(Math.abs(dx) < .1 and Math.abs(dy) < .1){ sfondo.bianco._width = sfondo.tw sfondo.bianco._height = sfondo.th delete this.onEnterFrame; loadNextImage(next, stat) } } } /** loadNext Image **/ function loadNextImage(image, stat){ trace('loadNextImage') var str:String = basePath + "?command=thumb&width=" + stat[0] + "&image=" + image var zoom:MovieClip = _root.zoomed zoom.cont.index += 1 zoom.cont.createEmptyMovieClip('img_' + zoom.cont.index, zoom.cont.index); zoom.cont['img_' + zoom.cont.index].loadMovie(str); zoom.cont['img_' + zoom.cont.index]._alpha = 0; zoom.cont.image = image zoom.cont._mc = zoom.cont['img_' + zoom.cont.index] zoom.cont.onEnterFrame = function(){ if(this._mc.getBytesLoaded() >= this._mc.getBytesTotal() and this._mc.getBytesTotal() > 4){ this._parent.mask._width = contentWidth this._parent.mask._height = contentHeight if(this._mc._alpha > 100){ delete this.onEnterFrame _root.toLoad -= 1 if(_root.toLoad <= 0){ preloader._visible = false } resizeMover(this._mc._width, this._mc._height, contentWidth, contentHeight); } this._mc._alpha += 5 } } } /** loadNavigator clip **/ function loadNavigator(image, stat){ var mc:MovieClip = _root.nav; mc._visible = false mc.cont.loadMovie(basePath + "?command=thumb&width=" + stat[0] + "&height=" + stat[1] + "&image=" + image); mc.targetWidth = stat[0] + 10 mc.targetHeight = stat[1] + 10 mc._visible = false; mc.mover._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; 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 this.plus._x = Math.round(this.sfondo_thumb.t_bianco._x + this.sfondo_thumb.t_bianco._width - this.plus._width) this.plus._y = Math.round(this.sfondo_thumb.t_bianco._y + this.sfondo_thumb.t_bianco._height + 5) this.minus._x = this.plus._x this.minus._y = this.plus._y + this.plus._height + 5 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 this.plus._x = Math.round(this.sfondo_thumb.t_bianco._x + this.sfondo_thumb.t_bianco._width - this.plus._width) this.plus._y = Math.round(this.sfondo_thumb.t_bianco._y + this.sfondo_thumb.t_bianco._height + 5) this.minus._x = this.plus._x this.minus._y = this.plus._y + this.plus._height + 5 delete this.onEnterFrame; this.onEnterFrame = function(){ if(this.cont._alpha > 100){ delete this.onEnterFrame _root.toLoad -= 1 if(_root.toLoad <= 0){ preloader._visible = false } nav.mover._visible = true } this.cont._alpha += 5; } } } } } /** activate the mover navigator **/ function resizeMover(w, h, w1, h1){ var mover:MovieClip = _root.nav.mover var controller = _root.nav.sfondo_thumb mover._visible = true trace("resizeMover") if(w != null){ var prop_1 = w/w1 var prop_2 = h/h1 controller.prop_1 = prop_1 controller.prop_2 = prop_2 controller.prop_3 = w/nav.cont._width controller.prop_4 = h/nav.cont._height mover._width = nav.cont._width / prop_1 mover._height = nav.cont._height / prop_2 mover.maxW = mover._width mover.maxH = mover._height mover.rapporto = mover.maxW/mover.maxH nav.piu._visible = true nav.meno._visible = true mover._x = mover._width/2 + 5 mover._y = mover._height/2 + 5 } mover.onPress = function(){ trace("mover OnPress") _root.zoomed.cont.zoom.removeMovieClip(); delete this.onEnterFrame this.startDrag(false, Math.ceil(this._width/2) + 5, Math.ceil(this._height/2) + 5, nav.cont._width - (this._width/2) + 5, nav.cont._height - (this._height/2) + 5) this.onEnterFrame = function(){ invalidate(); updateAfterEvent(); } invalidate() } mover.onRelease = function(){ trace("mover on release") stopDrag(); delete this.onEnterFrame; invalidate(); loadAltererdImage(); } nav.sfondo_thumb.onMouseUp = function(){ if(this._parent.cont.hitTest(_root._xmouse, _root._ymouse) && !this._parent.mover.hitTest(_root._xmouse, _root._ymouse)){ trace("controller onMouseUp") var b = this._parent.cont.getBounds( _root ) moveMover(_root._xmouse - b.xMin, _root._ymouse - b.yMin) } } } /** * invalidate * the main function for navigate large image **/ function invalidate(){ // validate mover position first var bounds:Object = mover.getBounds( nav ) if(mover.yMin < 5){ mover._y = mover._height/2 + 5 } var mover:MovieClip = _root.nav.mover var image = _root.zoomed.cont['img_' + _root.zoomed.cont.index] var x = ((mover._x - 5) - mover._width/2) * nav.sfondo_thumb.prop_3 var y = ((mover._y - 5) - mover._height/2) * nav.sfondo_thumb.prop_4 image._xscale = 100*(mover.maxW/mover._width) image._yscale = 100*(mover.maxW/mover._width) x = x*(image._xscale/100) y = y*(image._yscale/100) image._x = -x image._y = -y } /** zoom plus **/ function zoomPlus(val:Boolean):Void{ var mover:MovieClip = _root.nav.mover var image = _root.zoomed.cont['img_' + _root.zoomed.cont.index] zoomed.cont.zoom.removeMovieClip(); if(val == 1){ mover.onEnterFrame = function(){ mover.targetW = mover._width*0.98 if(mover.targetW < 10){ mover.targetW = 10 } mover.targetH = mover.targetW/mover.rapporto invalidate() mover._width = this.targetW mover._height = this.targetH } } else { delete mover.onEnterFrame invalidate() loadAltererdImage() } } /** zoom minus **/ function zoomMinus(val:Boolean):Void{ var mover:MovieClip = _root.nav.mover var image = _root.zoomed.cont['img_' + _root.zoomed.cont.index] _root.zoomed.cont.zoom.removeMovieClip(); if(val == 1){ mover.onEnterFrame = function(){ mover.targetW = mover._width*1.05 if(mover.targetW > nav.cont._width){ mover.targetW = nav.cont._width } mover.targetH = mover.targetW/mover.rapporto checkMover() // check right position of mover invalidate() mover._width = this.targetW mover._height = this.targetH } } else { delete mover.onEnterFrame invalidate() loadAltererdImage() } } /** check mover **/ function checkMover(){ var a = nav.mover.getBounds( _root) var b = nav.cont.getBounds( _root ) if(a.xMax > b.xMax){ nav.mover._x = nav.cont._x + nav.cont._width - nav.mover._width/2 } if(a.yMax > b.yMax){ nav.mover._y = nav.cont._y + nav.cont._height - nav.mover._height/2 } if(nav.mover._x < nav.mover._width/2 + 5){ nav.mover._x = Math.ceil(nav.mover._width/2) + 5 } if(nav.mover._y < nav.mover._height/2 + 5){ nav.mover._y = Math.ceil(nav.mover._height/2) + 5 } } /** load the zoomed image **/ function loadAltererdImage(alt:String){ _root.zoomed.cont.zoom.removeMovieClip(); var img = zoomed.cont.image if(alt != undefined){ img = alt } var mover:MovieClip = nav.mover if(mover.maxW - mover._width != 0){ var x = (mover._x - mover._width/2 - 5) * nav.sfondo_thumb.prop_3 var y = (mover._y - mover._height/2 - 5) * nav.sfondo_thumb.prop_4 var mc:MovieClip = _root.zoomed.cont['img_' + _root.zoomed.cont.index] x = x * (mc._xscale/100) y = y * (mc._yscale/100) x = x * (_root.zoomed.cont.stat[0] / mc._width) y = y * (_root.zoomed.cont.stat[1] / mc._height) var w = _root.zoomed.cont.stat[0] / nav.cont._width w = w * mover._width var str:String = basePath + "?command=resized&image=" + img + "&width=" + int(w) + "&x=" + int(x) + "&y=" + int(y) + "&contentWidth=" + contentWidth _root.zoomed.cont.createEmptyMovieClip("zoom",999) var clip:MovieClip = _root.zoomed.cont.zoom.createEmptyMovieClip("clip" + new Date().getTime(),1) _root.zoomed.cont.zoom._alpha = 0 _root.preloader._visible = true clip.loadMovie(str) trace("loadAltererdImage: " + str) _root.zoomed.cont.onEnterFrame = function(){ if(clip.getBytesLoaded() >= clip.getBytesTotal() && clip.getBytesLoaded() > 4){ if(this.zoom._alpha >= 100){ delete this.onEnterFrame _root.preloader._visible = false } this.zoom._alpha += 10 } } } }