I would like to know how to access and modify the variable a in anonymous functions, i try to put arrow but i get in my browser: undefined
import * as Konva from 'konva';
export class classTest {
public a: number;
access(){
var stage = new Konva.Stage({ container: 'container', width: 400, height: 250 });
var layer1 = new Konva.Layer();
var imageObj = new Image();
var self = this
imageObj.onload = function () {
self.a = 150
var yoda = new Konva.Image({
x: 50,
y: 50,
image: imageObj,
width: 106,
height: 118
});
layer1.add(yoda);
//stage.add(layer1)
};
imageObj.src = '/assets/images/yoda.jpg';
//console.log(a)
If i add in layer1 a rect with width = a it's going to be the same thing as you explained ( i get a line) so how can I do it.
var box = new Konva.Rect({
x: 20, y: 20,
width: this.a,
height: 50,
fill: '#00D2FF', stroke: 'black',
strokeWidth: 4
});
stage.add(layer1)
}