Why this code is just showing black screen to my band. Can you please help me #116
-
What are my errors. Please help me .at first Answer 1 was working flawlessly but when I add Answer 2 and 3 it began by showing black screen. Please help me by pasting in answer the correct code please. function randomNum(lowerInteger, upperInteger) {
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, you are declaring the variable Answer1 and Answer2 twice: var Answer1=["I am calledra, how can i b at service.","I am s you?","I am "] and const Answer1 = hmUI.createWidget(hmUI.widget.BUTTON, { this is not possible. I recommend using the simulator or check the log in the zepp app. This code should work: function randomNum(lowerInteger, upperInteger) {
let choices = upperInteger - lowerInteger + 1;
return Math.floor(Math.random() * choices + lowerInteger);
}
var Answer3=["Um sorry ","Sorry "]
var Answer2=["A human ."," made "]
var Answer1=["I am calledra, how can i b at service.","I am s you?","I am "]
const BtnAnswer1 = hmUI.createWidget(hmUI.widget.BUTTON, {
x: 10,
y: 100,
text: 'you',
w: 120,
h: 50,
radius: 20,
normal_color: 0x195aea,
press_color: 0xffffff,
click_func: ()=>{
hmUI.showToast({
text: Answer1[randomNum(1, Answer1.length)]
})
}
})
const BtnAnswer2 = hmUI.createWidget(hmUI.widget.BUTTON, {
x: 10,
y: 160,
text: 'ou?',
w: 120,
h: 50,
radius: 20,
normal_color: 0x195aea,
press_color: 0xffffff,
click_func: ()=>{
hmUI.showToast({
text: Answer2[randomNum(1, Answer2.length)]
})
}
})
hmUI.createWidget(hmUI.widget.BUTTON, {
x: 10,
y: 220,
text: 'iend?',
w: 120,
h: 50,
radius: 20,
normal_color: 0x195aea,
press_color: 0xffffff,
click_func: ()=>{
hmUI.showToast({
text: Answer3[randomNum(2, Answer3.length)]
})
}
}) |
Beta Was this translation helpful? Give feedback.
Hi, you are declaring the variable Answer1 and Answer2 twice:
and
this is not possible. I recommend using the simulator or check the log in the zepp app. This code should work: