Instances problem

For developers using the Construct 2 Javascript SDK

Post » Thu Jan 28, 2016 1:35 pm

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

Code: Select all
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
   };


Problem:
Image

if I click on the first image
Image

it brings the correct UID but the worng URL
Image

and loads the image in the last instance, the wrong instance
Image
B
18
S
4
G
1
Posts: 143
Reputation: 1,868

Post » Sat Jan 30, 2016 2:22 am

Here is an <Img> plugin made by @Pode
B
107
S
25
G
225
Posts: 4,322
Reputation: 128,321


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 2 guests