Is it possible to create a button which when press

2019-09-10 05:39发布

Is it possible to create a button which when pressed it replaces an existing object on the screen to another object in Smartface App Studio?

I've tried using the Onshow event on the text however it wasn't successful.

Thankyou

1条回答
对你真心纯属浪费
2楼-- · 2019-09-10 06:11

It is possible to replace an existing object to another object. You should create objects and add to page both of them but visible property of an object should be false on start and then you can change visible of object when button is pressed.I create a simple example for you:

var btn = new SMF.UI.TextButton({
 top : "80%",
 left : "10%",
 onPressed : page1_btn_onPressed
});
Pages.Page1.add(btn);

var myImage = new SMF.UI.Image({
    top: "20%",
    left: "15%",
    height: "20%",
    width: "70%",
    image: "default.png",
    imageFillType: SMF.UI.ImageFillType.stretch,
    visible : true
});
Pages.Page1.add(myImage);

var myImage2 = new SMF.UI.Image({
    top: "20%",
    left: "15%",
    height: "20%",
    width: "70%",
    image: "icon.png",
    imageFillType: SMF.UI.ImageFillType.stretch,
    visible : false
});
Pages.Page1.add(myImage2);

function page1_btn_onPressed(e) {
  myImage.visible= false;
  myImage2.visible = true;
}
查看更多
登录 后发表回答