Q: iAd Producer Switch Object
Hello All,
I'm attempting an iBook for my school, and I would like to add a widget to this book. In this widget I have an anatomical drawing, and I would like to use the switch object to toggle arrows on specific structures. I've been successful in getting the arrow to appear by setting the activated state of the switch to call an action whereby the arrow displays, however, there is no option for me to set the inactivated event, to "un-display" the arrow, on the object.
I need a bit of javascript to determine the state of the switch, so I can call the appropriate action list, but I have absolutely no idea how this is accomplished. I have zero experience with javascript.
any help is most appreciated.
best regards.
Posted on May 6, 2014 2:10 PM
Hello,
Your best option would be to listen to the iAd.Switch onControlValueChange method and check the value of the on attribute to determine whether to show the arrows or not. Pseudocode follows, but you will need to tweak to suit the rest of the widget.
Include in JavaScript for the switch control (click the "Code" button at bottom of iAd Producer with switch selected):
this.onControlValueChange = function (event) {
if (this.on) {
this.viewController.showArrows();
}
else {
this.viewController.hideArrows();
}
};
What the show/hideArrows methods do are up to you. You could grab each of the arrows and change the visibility of the arrow.
Best of luck,
Josh
Posted on May 7, 2014 10:10 AM