codice:
// Ho bisogno di 2 clip
// mask = Istanza del clip maskera
// mc = Istanza del clip contenente la foto
mc.setMask(mask)
// limite sinistro maskera
max_sx_mask=mask._x
// limite destro maskera
max_dx_mask=mask._x+mask._width
// limite superiore maskera
max_top_mask=mask._y
// limite inferiore maskera
max_bot_mask=mask._y+mask._height ;
// elocità di spostamente
vel=5 // puoi variare
// Prototypo ugluale per tutti i pulsanti
// devono essre premuti
MovieClip.prototype.test=function(){
this.onMouseDown=function(){
if(this.hitTest(_level0._xmouse,_level0._ymouse,false)){
sopra=true
muovi(this._name)
}
}
this.onMouseUp=function(){
if(this.hitTest(_level0._xmouse,_level0._ymouse,false)){
sopra=false
}
}
}
// assegnazione frecce al prototype
su.test()
giu.test()
sx.test()
dx.test()
//Funziione richiamata dal Mouse Down
function muovi(nome){
switch(nome){
case "su":
this.onEnterFrame=function(){
if(sopra){
if(mc._y+mc._height > max_bot_mask){mc._y-=vel}
}else{delete this.onEnterFrame}
}
break;
case "giu":
this.onEnterFrame=function(){
if(sopra){
if(mc._y < max_top_mask){mc._y+=vel}
}else{delete this.onEnterFrame}
}
break;
case "sx": //<<
this.onEnterFrame=function(){
if(sopra){
if(mc._x < max_sx_mask){mc._x+=vel}
}else{delete this.onEnterFrame}
}
break;
case "dx": //>>
this.onEnterFrame=function(){
if(sopra){
if(mc._x+mc._width > max_dx_mask){mc._x-=vel}
}else{delete this.onEnterFrame}
}
break;
}
}
// Fine