Instances problem

  • To workaround with the crossdomain police of sprite´s load image, I´m developing a plugin that create a HTML img element.

    instanceProto.onCreate = function()
    	{
    		theInstance = this;
    		this.url = this.properties[0];
    		
    		this.img = document.createElement("img");
    		this.img.src = this.url;
    		this.img.id = "img"+this.uid;
    		this.img.style.position = "absolute";
    		this.img.height = "100";
    		this.img.width = "100";
    		this.img.style.zIndex = 3;
    		jQuery(this.img).appendTo(this.runtime.canvasdiv ? this.runtime.canvasdiv : "body");
    		
    		this.updatePosition();
    	};
    
    	Acts.prototype.LoadImage = function (url)
    	{
    		theInstance.url = url;
    		theInstance.img.src = url;
    	};
    
    	Exps.prototype.URL = function (ret)	// 'ret' must always be the first parameter - always return the expression's result through it!
    	{
    		ret.set_string(theInstance.url);		// for ef_return_string
    	};[/code:2p8ilawl] 
    
    Problem:
    [img="http://fabiocolombini.comli.com/img/loadimgBug.jpg"]
    
    if I click on the first image
    [img="http://fabiocolombini.comli.com/img/loadimgBug2.jpg"]
    
    it brings the correct UID but the worng URL
    [img="http://fabiocolombini.comli.com/img/loadimgBug3.jpg"]
    
    and loads the image in the last instance, the wrong instance
    [img="http://fabiocolombini.comli.com/img/loadimgBug4.jpg"]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here is an <Img> plugin made by Pode

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)