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?

孤街浪徒 提交于 2019-12-13 05:50:57

问题


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:


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;
}


来源:https://stackoverflow.com/questions/36723564/is-it-possible-to-create-a-button-which-when-pressed-it-replaces-an-existing-obj

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!