Page 1 of 1

A counter

Posted: Thu Jun 06, 2013 12:33 pm
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

Re: A counter

Posted: Thu Jun 06, 2013 12:52 pm
by VĂ­ctor Paredes
Haha, clever idea!

Re: A counter

Posted: Thu Jun 06, 2013 8:18 pm
by rocky53204
That technique is also good for casino slot machine reels... substitute symbols for the numbers.

Re: A counter

Posted: Fri Jun 07, 2013 4:38 am
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

Re: A counter

Posted: Sat Jun 08, 2013 11:29 am
by Stan
Funny that Mike Kelley made the same thing back in 2009: http://www.kelleytown.com/forum/animato ... OPIC_ID=59

Re: A counter

Posted: Sat Jun 08, 2013 2:08 pm
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.)

Re: A counter

Posted: Sat Jun 08, 2013 6:21 pm
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.

Re: A counter

Posted: Sun Jun 23, 2013 1:25 am
by uddhava
Nice trick and I could understand how you did it!

Re: A counter

Posted: Sun Jun 23, 2013 9:55 am
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.

Re: A counter

Posted: Mon Jun 24, 2013 8:45 pm
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.

:)

Re: A counter

Posted: Tue Jun 25, 2013 12:45 am
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.