A counter

Have you come up with a good Moho trick? Need help solving an animation problem? Come on in.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
slowtiger
Posts: 6079
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

A counter

Post by slowtiger »

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
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
User avatar
Víctor Paredes
Site Admin
Posts: 5658
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: A counter

Post by Víctor Paredes »

Haha, clever idea!
Image Image Image Image
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
rocky53204
Posts: 223
Joined: Sat Sep 03, 2011 3:34 am

Re: A counter

Post by rocky53204 »

That technique is also good for casino slot machine reels... substitute symbols for the numbers.
JCook
Posts: 392
Joined: Wed Aug 04, 2004 1:28 pm
Location: Cape Cod, MA

Re: A counter

Post by JCook »

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
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

Re: A counter

Post by Stan »

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
User avatar
slowtiger
Posts: 6079
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: A counter

Post by slowtiger »

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
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

Re: A counter

Post by Stan »

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
User avatar
uddhava
Posts: 315
Joined: Tue Nov 04, 2008 7:24 pm
Location: American back in Hungary

Re: A counter

Post by uddhava »

Nice trick and I could understand how you did it!
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Re: A counter

Post by heyvern »

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.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Re: A counter

Post by heyvern »

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.

:)
User avatar
slowtiger
Posts: 6079
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: A counter

Post by slowtiger »

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
Post Reply