I have being trying to implement this old Hype project from the template library created by @Luckyde. I am getting an error when uploaded to server that causes the project to breakdown.
PROBLEM:
The 3D cube loads perfect locally with no issues but as you can see in the error log on the live demo below this error appears. My thoughts are that some of the code in the project (created in 2015) is obsolete in the latest version of hype.
Error in undefined: TypeError: Cannot read property 'offsetLeft' of null
Thanks thats what I figured but still no closer to solution. Main stage is set in the Head of the document along with other vars. I tried to change this to window.mainStage; but this had no effect.
<script>
var stageLeft;
var stageTop;
var mainStage;
var centreX;
var centreY;
var sides2Left;
var innitialWidth;
var cubeSize = 200;
var cubeOpacity=0.5;
var cube;
</script>
Yes. But “mainStage” has not been assigned anything so it’s just a null variable. So in other words it has been defined hence the error does not show as “undefined” but has not been assigned to anything so it’s “null”. Somewhere else there should be an assignment mainStage = ... for it to no longer be null.
EDIT
Just seen you posted the doc so now I’m on my comp. You need to load the “cubeSetup” script on scene load as this is where the “mainStage” is being assigned (as the hype document container).
trying that i even removed mainStage off the header and it still worked, i’m not getting your error even on publish or you could redeclare it in the 3dSpin function at the top
I think it's because the "cubeSetup" function is being called with a timeline action on the first frame and for this reason I suggest running it on scene load. As this is probably causing it to not run sometimes hence the error.
This is because it still gets assigned in global scope when run in the "cubeSetup" function. (without var an assignment is attached to the higher scope in this case window(global))
Thanks @Luckyde and @DBear for helping me resolve this problem!
This is a great solution Luckyde for creating engaging 3D shapes for teaching children maths…my next problem is how to create a 3D Pyramid using this technique !! Wish me luck, thanks again.