Skip to main content
Participant
October 9, 2017
Answered

change instance by using string

  • October 9, 2017
  • 1 reply
  • 295 views

hi everyone,

Im trying to change the alpha of an instance by code

I did this code (and many many others but it doesn't work)

//global Var

var logoName = "";

//open popup window

this.WazeBtn.addEventListener("click", WazeText.bind(this));

function WazeText(event){

logoName = "WazeXY";

this.PopUp.WazeXY.alpha = 1;

}

//hide instance in popup window

this.PopUp.Exit.addEventListener("click", PopUp_close.bind(this));

function PopUp_close() {

this.PopUp.logoName.alpha = 0; // this line doesn't work

}

I will love some help with this problem

many thanks.

This topic has been closed for replies.
Correct answer Colin Holgate

It will work like this:

function PopUp_close() {

  this.PopUp[logoName].alpha = 0; // this line doesn't work

}

1 reply

Colin Holgate
Colin HolgateCorrect answer
Inspiring
October 9, 2017

It will work like this:

function PopUp_close() {

  this.PopUp[logoName].alpha = 0; // this line doesn't work

}

Participant
October 9, 2017

Colin thank you vary much!! I struggled with this line for hours

Legend
October 10, 2017

You're actually changing an instance by using a variable, not a string (literal).