Problem: Don’t want to use timeline, just javascript to move Top and Left of nested item(s) in symbol. Should i have used “Group” instead of “Convert to Symbol” when combining them?
Saola Animate version: 3.01 non trial
OS: Win 11
Notes:
From reading posts and learning the hard way that things are a bit different in Saola Animate than examples from javascript online. For example, using doc instead of document. I have spent DAYS trying to simply get a variable to access a nested thing inside a created symbol.
The following code works. Nothing was nested. the thimble was just one thing at the time (no nesting).
function sceneEventHandler(doc, e) {
// this slider moves the thimbles and spindle of the micrometer
var timelineSlider = doc.getElement('slider').dom.querySelector('.slider');
var output = timelineSlider.value;
doc.getElement("tb").setText(output);
//get initial Top positions for the thimble and spindle
var spinPos = doc.getElement('spindle').dom.offsetTop;
var thimPos = doc.getElement('thimble').dom.offsetTop;
// slider moves spindle and thimble
timelineSlider.oninput = function() {
output = this.value;
doc.getElement("tb").setText(output);
var element = doc.getElement('spindle');
var elementDom = element.dom;
var spin = elementDom.Top;
var elementTop = elementDom.offsetLeft;
// set new position
spin = spinPos - (15 - output);
// elementTop += 10;
element.setPosition( elementTop, spin);
var element2 = doc.getElement('thimble');
var elementDom2 = element2.dom;
var thim = elementDom2.Top;
var elementTop2 = elementDom2.offsetLeft;
// set new position
thim = thimPos - (15 - output);
// elementTop += 10;
element2.setPosition( elementTop2, thim);
}
}
The problem starts when I have things nested in thimble, I want to make something move in it as the whole thimble moves a different way. I don’t want to use the timeline.
I have tried many combinations to access the nested element inside the thimble (now converted to symbol). No matter what i try, there seems to be no access to nested things.
Is it even possible???
Here are things I tried. And a bunch more that i did not keep track of…
//Converted Symbol "thimble" has a shape, a Freeform and symbol called "ThimbleMarks"
//first i tried the dot notation i am use to. Tried many variation of this btw. Nothing worked
var shape = doc.getElement("thimble.KnurledThimble");
var shapeDom = shape.dom;
var sTop = shapeDom.Top;
var sLeft = shapeDom.offsetLeft;
doc.getElement("pos").setText(spinPos + " | " + thimPos+ " - " + sLeft);
**// tried to get class name .thimMarks of nested symbol**
var TMarks = doc.getElement('thimble').dom.querySelector('.thimMarks');
var ThimMarks=TMarks
TMarks.setPosition( 44, 33); //used numbers to eliminate problems using variables
// and even more stuff i tried....so much more with .childeren, nodes etc....ugh
var parentDoc = doc.getDoc();
var tm= parentDoc.getElement(ThimbleMarks);
var TMarks = doc.getElement('thimble').dom.querySelector('.thimMarks');
var ThimMarks=TMarks
var parentt = doc.getElement('thimble').dom.firstElementChild;
var TMarks =doc.getElement('thimble').getSymbol("ThimbleMarks");
var TMarks =doc.getElement('thimble').getSymbolDoc();
var tm = doc.getSymbol("thimble").getElement('ThimbleMarks');
var TMarks=tm.getElement('ThimbleMarks');
TMarks.setPosition( 44, 33);
parentt[2].setPosition( 44, 33);
parentt[0].offsetTop=88;
var tm=getSymbol("thimble");
var tm=doc.getElement('thimble');
TMarks.setPosition( 44, 33);
doc.getElement("pos").setText(spinPos + " | " + thimPos + " - " + tm);