Hello Again,
Been struggling with this one all morning, basically I have add a file called Interface.js which is set to include in the header to my resources which has a Function called ShowTeaching(); in it. I have created a new Javascript Function in Hype 3 called ToggleTeacher and I am trying to call the function in Interface.js as per below ;
// interface.js JavaScript Document
function showTeaching()
{
var element = document.getElementById(“showpic”);
element.style.visibility = “visible”;
}
function hideTeaching()
{
var element = document.getElementById(“showpic”);
element.style.visibility = “hidden”;
}
// End
My new Hype Javascript Function ;
Function ToggleTeacher(hypeDocument, element, event) {
$.getScript("${resourcesFolderName}/interface.js", function(){
// Use anything defined in the loaded script…
showTeaching();
});
}
… But Nothing Happens, is this the correct way to Achieve this ?
PART 2
Similar to above, I also have a Javascript file added to Resource which has a variable in it for JSON which is as below, I want to be able to read the “showpic” imgSrc from this file, is that possible to do in Hype ?
Javascript File p3.js
// JavaScript Document
// JSON字符串
var pageJson =
{
“KLHEAD”:
{
“info”:“No.03”,
“title”:“Monkey Fun”,
“css”:[],
“js”:[“p3a.js”,
“p3b.js”,
“anim03.js”]
},
“KLBODY”:
{
“spriteLayer”:
[
{
“name”:“bgb”,
“area”:[0, 0, defWidth, defHeight],
“zIndex”:1002,
“visibility”:1,
“animType”:0,
“imgSrc”:“p3.jpg”
},
{
"name":"monkey1",
"triggerEnable":1,
"triggerRect":[0, 8, 960, 414],
"visibility":1,
"animType":4,
"animData":"monkey1",
"audio":
[
{
"audioPath":"p3.mp3",
"audioTimeDelay":250
},
{
"audioPath":"hanging.mp3"
}
],
"stopPosition":10,
"relatedPartId":"p3",
"relevantFont":["p3"]
},
{
"name":"showpic",
"area":[teacherOffset, 0, teacherWidth, defHeight],
"zIndex":4999,
"visibility":0,
"animType":0,
"imgSrc":"fp03.png"
}
],
"txtLayer":
[
{
"name":"text1",
"frame":[102, 803,1],
"fontSize":46,
"fontFamily":"ITCAvantGardeGothicMedium",
"letterSpacing":3,
"htmlCode":"<p><span id='p1'>I </span><span id='p2'>am </span><span id='p3'>hanging.</span></p>"
}
],
"transLayer":
[
{
"name":"translate",
"txt":"I am hanging.@@我挂在树上。",
"isLeft":1
}
],
"pageCodeLayer":
{
"code":[2,3],
"color":"#627994"
}
}
};
Hype3 Javascript ;
function GetPanelName(hypeDocument, element, event) {
$.getScript("${resourcesFolderName}/p03.js", function(){
// Use anything defined in the loaded script…
var sprites=pageJson.KLBODY.spriteLayer;
alert(sprites[2].name);
});
}
Would really appreciate some help with this, learning all the time…
Regards
JudgeyK