A counter
Moderators: Víctor Paredes, Belgarath, slowtiger
A counter
After wasting half a day on this I found a stupidly simple solution done in just 5 minutes. Go figure.
The problem: I need several counters in a project, they should go up to really high numbers. But I didn't want to change all the numbers by hand. So I first programmed that part in Actionscript in Flash: really nice, with adjustable intervals and so on, adn I was quite proud because I hadn't touched Actionscript for quite some years. Then I tried to export this as a movie.
Flash doesn't export scripted content (stuff that's generated in runtime). Deep down I knew that, I just didn't remember.
Then I remembered that Director could script content creation, and I used that long ago. So I fired up Director 7 on Mac OS 9 (I still have machines running this), and tried to remember Lingo - last time I used this was 15 yrs ago. Fortunately I had saved some old scripts which pointed me into the right direction.
Director crashed. And then it didn't open the file again.
So I went back to AS and tried the text tool, and searching for some script doing the counting. Unfortunately AS only creates the shapes from text input, but doesn't handle any letter as a scriptable item.
What I finally did was a simple switch layer with the 10 numbers in it, cycling through, duplicate it, spaced the switch keys apart, and voila! I really should have saved me this frustrating afternoon!
http://www.slowtiger.de/examples/zaehler.anme.zip
The problem: I need several counters in a project, they should go up to really high numbers. But I didn't want to change all the numbers by hand. So I first programmed that part in Actionscript in Flash: really nice, with adjustable intervals and so on, adn I was quite proud because I hadn't touched Actionscript for quite some years. Then I tried to export this as a movie.
Flash doesn't export scripted content (stuff that's generated in runtime). Deep down I knew that, I just didn't remember.
Then I remembered that Director could script content creation, and I used that long ago. So I fired up Director 7 on Mac OS 9 (I still have machines running this), and tried to remember Lingo - last time I used this was 15 yrs ago. Fortunately I had saved some old scripts which pointed me into the right direction.
Director crashed. And then it didn't open the file again.
So I went back to AS and tried the text tool, and searching for some script doing the counting. Unfortunately AS only creates the shapes from text input, but doesn't handle any letter as a scriptable item.
What I finally did was a simple switch layer with the 10 numbers in it, cycling through, duplicate it, spaced the switch keys apart, and voila! I really should have saved me this frustrating afternoon!
http://www.slowtiger.de/examples/zaehler.anme.zip
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5
- Víctor Paredes
- Site Admin
- Posts: 5658
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
Re: A counter
Haha, clever idea!
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
-
- Posts: 223
- Joined: Sat Sep 03, 2011 3:34 am
Re: A counter
That technique is also good for casino slot machine reels... substitute symbols for the numbers.
Re: A counter
That's brilliant, slowtiger! Thanks for sharing it. I needed to do this last year for an animation and I never thought of switch layers.
jack
jack
Re: A counter
Funny that Mike Kelley made the same thing back in 2009: http://www.kelleytown.com/forum/animato ... OPIC_ID=59
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
Re: A counter
As I said, the solution is so obvious that I cursed myself for not doing it this way right from the start. (I don't read that other forum.)
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5
Re: A counter
Anyway, thank you Slowtiger for sharing your tip. I'm sure it will be useful for many people, and it is also a good reminder for all of us old-timers that asking a question on the forum sometimes can save us from reinventing the wheel.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
Re: A counter
Nice trick and I could understand how you did it!
Re: A counter
Ooooh!
I was wracking my brain for an "easy" scriptable way to pull this off.
I have that cool streamlined simplistic single stroke font I created for my vector bone label script. It's easily accessible to scripting access (in a utility script) so a script could be created to "build" all of the switch layers. This would cut way down on point count (this small amount of text is not really a big issue, but still, any text has a huge amount of wasted points. My simple font has 10 points or less for each letter).
There are a couple of ways to automate this:
1) Fixed Length Counter Solution (menu script)
Set the timing (fps?). Set it for frame count or SMPTE. Set the length of the counter (how many frames to count). Run the script and BANG! auto counter. Script creates all the switch layers and sets the key frames. The length of the counter would be set once. If you needed it to run longer you would have to edit the switch layers by hand to increase the incrementing.
2) Scripted auto solution (better solution)
Switches have no key frames. No keys would be needed at all, just the creation of the switch layers. The switch layers are changed automatically by a layer script. Layer script in the parent counts the frames and automatically increments the switch for each layer based on the frame number. This would be much better, no key framing required it would just simply work for any length animation. Just drop in the switch counter folder, add the layer script, and BINGO! Auto counter. On a side note, there would be no keys for this layer. I know it's a small thing, but keys actually take up space in the file. By scripting the switch layers and removing keys there is no added overhead. Of course this could be modified to force keys if required.
I was wracking my brain for an "easy" scriptable way to pull this off.
I have that cool streamlined simplistic single stroke font I created for my vector bone label script. It's easily accessible to scripting access (in a utility script) so a script could be created to "build" all of the switch layers. This would cut way down on point count (this small amount of text is not really a big issue, but still, any text has a huge amount of wasted points. My simple font has 10 points or less for each letter).
There are a couple of ways to automate this:
1) Fixed Length Counter Solution (menu script)
Set the timing (fps?). Set it for frame count or SMPTE. Set the length of the counter (how many frames to count). Run the script and BANG! auto counter. Script creates all the switch layers and sets the key frames. The length of the counter would be set once. If you needed it to run longer you would have to edit the switch layers by hand to increase the incrementing.
2) Scripted auto solution (better solution)
Switches have no key frames. No keys would be needed at all, just the creation of the switch layers. The switch layers are changed automatically by a layer script. Layer script in the parent counts the frames and automatically increments the switch for each layer based on the frame number. This would be much better, no key framing required it would just simply work for any length animation. Just drop in the switch counter folder, add the layer script, and BINGO! Auto counter. On a side note, there would be no keys for this layer. I know it's a small thing, but keys actually take up space in the file. By scripting the switch layers and removing keys there is no added overhead. Of course this could be modified to force keys if required.
Re: A counter
Oh for goodness sakes.
I soon realized, just as Selgin did, that doing this "by hand" is so easy there is absolutely no reason to script it. You only have to do it once anyway and just import the anime file. <sigh>
Follow my hysterically funny thought process...
So I scripted the automation of the first ten digits. Then realized, you could simply have a cycle animation of the first ten because all animations have at least ten frames. So I only need to script double and tripple frame numbers. Then I thought why bother with the second digit because most animations are going to have frame numbers above 10 anyway...
So I scripted the triple digit counter... and realized... <sigh> what a freaking god forsaken waste of time.
I then thought, I could at least create a script that CREATES the counter switches from scratch with a menu script... and then realized I had the freaking thing sitting there right in front of me all finished and pretty, and could simply stick a copy in the the library or add a copy to all of my templates...
I just laughed at myself for being so silly. Scratching my head and wondering how I thought I could make something so simple easier by making it more difficult.
I soon realized, just as Selgin did, that doing this "by hand" is so easy there is absolutely no reason to script it. You only have to do it once anyway and just import the anime file. <sigh>
Follow my hysterically funny thought process...
So I scripted the automation of the first ten digits. Then realized, you could simply have a cycle animation of the first ten because all animations have at least ten frames. So I only need to script double and tripple frame numbers. Then I thought why bother with the second digit because most animations are going to have frame numbers above 10 anyway...
So I scripted the triple digit counter... and realized... <sigh> what a freaking god forsaken waste of time.
I then thought, I could at least create a script that CREATES the counter switches from scratch with a menu script... and then realized I had the freaking thing sitting there right in front of me all finished and pretty, and could simply stick a copy in the the library or add a copy to all of my templates...
I just laughed at myself for being so silly. Scratching my head and wondering how I thought I could make something so simple easier by making it more difficult.
Re: A counter
I'm so glad that this happens to others as well! Working alone often means running into a dead end, making things much more complicated than necessary, or getting lost in details nobody will even see.
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5