Official Example Works. But I'm getting onValueChangedObservable issue, know why?

Please do not forget to add a link to a Playground to get a faster answer:

Here is the code I’m using. sliderX (Slider) is true, I’m able to Console.log() with it.

What am I missing?
Error in the Console: “Property ‘onValueChangedObservable’ does not exist on type ‘Control’.ts(2339)”

sliderX?.onValueChangedObservable.add(function(value: any) {
    // header.text = "Y-rotation: " + (Tools.ToDegrees(value) | 0) + " deg";
    if (blenderCube) {
        blenderCube.rotation.y = value;
    }
  });

I’ve got to be overlooking something simple.

Thanks for anyone that can point out what I’m doing incorrect. :weary:

On PG it works when you cast sliderX as GUI.Slider:

let sliderX = <BABYLON.GUI.Slider> advancedTexture.getControlByName("RotationXSlider");
4 Likes

I’ll try that in my code, thanks.

let sliderX = <GUI.Slider> advancedTexture.getControlByName("SliderX");

Based on your suggestion @Takemura, this line of code now works as expected.

Thank you!

1 Like