2013-12-23 32 views
0

你好,對不起我的英語不好。我用一個循環「for」創建對象,或多或少有200個對象,它們在具有鼠標懸停和鼠標移動的動態圖像內部。問題是,所有的對象都可以,圖像,問題是,更多的不是很好的鼠標懸停和出,我不知道爲什麼。沒有給我一個錯誤的JavaScript只有一個警告與圖書館。如果任何人都可以用鼠標來查看一組有圖像的對象。MouseOver和Mousedown裏面的物體

CREATE OBJECTS---> 

for (var j=0;j<datos.length;j++){ // 
    iconos[j]= new icono(images._icono,1, datos[j] ,_conv_lat,_conv_long,factor_conversion_mapa,ConvLat,ConvLong,layer_iconos,stage,j,etiquetas); 

FUNCTION ---> 

function icono(icono_mapa,tipo,datos,_conv_lat,_conv_long,factor_conversion_mapa,ConvLat,ConvLong,layer_icono,stage,i,etiquetas){ 
    // DEL PIXEL 679 VA EN NEGATIVO ESTE VALOR (IBIZA-CORUÑA) //Pixel /Grado 
    //this._conv_lat=_conv_lat; 
    this.num=i; 
    // DEL PIXEL 241 VA EN POSITIVO ESTE VALOR 
    //this._conv_long=_conv_long; 
    //this.factor_conversion_mapa= factor_conversion_mapa; 
    this.Datos= new Array(); 
    this.Datos= datos.slice(); 
    this.imagen=icono_mapa; 
    this.Lat=0; 
    this.Long=0; 
    this.ConvLat=ConvLat; 
    this.ConvLong=ConvLong; 
    var _this = this; 
. 
. 
. 
. 
. 
this.base = new Kinetic.Image({x: _this.Long-(_this.size/2.0), y: _this.Lat -(this.size/2.0)+5, image:_this.imagen, width: _this.size, height: _this.size , name: "icono_"+_this.num}); 
this.base.on('mouseover', function(evt) { 
    document.body.style.cursor = 'pointer'; 
    etiquetas[_this.num].labelLeft.setAttr('opacity',1); 
    layer_etiquetas.draw(); 
    evt.cancelBubble = true; 

}); 
this.base.on('mouseout', function(evt) { 
    document.body.style.cursor = 'default'; 
    etiquetas[_this.num].labelLeft.setAttr('opacity',0); 
    layer_icono.draw(); 
    evt.cancelBubble = true; 
}); 

謝謝 如果有人能幫助我。

回答

0

謝謝。

那些我忘記的東西,因爲代碼更大,但這不是問題。此外,我還找到了解決重繪問題的解決方案,並在這一刻工作得很好。

只有一個工具提示對象,這一舉動的位置和不的mouseenter鼠標懸停

var base = new Kinetic.Image({x:Long-(size/2.0), y:Lat -(size/2.0)+5, image:imagen, width:size, height:size , name: "icono_"+num}); 
base.on('mouseenter mousemove', function(evt) { 
     document.body.style.cursor = 'pointer'; 
     tooltip.setPosition(this.getX()+this.getWidth(), this.getY()+this.getHeight()/2); 
     tooltip.setVisible(true); 
     tooltip.getText().setText(Datos[4]); 
     //tooltip.getText()setText(0,Datos[4]); 
     tooltip.moveToTop(); 
     layer.draw(); 

    }); 
base.on('mouseout', function(evt) { 
     document.body.style.cursor = 'default'; 
     tooltip.setVisible(false); 
     layer.draw(); 
    });