Hey Robert,
First you would create a basic code that would do what you needed to do.
You would then animate the switch.
You would then open the Attach Tool and attach the MouseRect using the code you just created in the ModelDef.XML parts sheet.
Next, you would open the Animation Manager, set your Animation key frames, like zero to 50 (typical for switches) or zero to 100, etc. Find the name of the newly made Animation object code you created in the list in the Animation Manager and click Create.
Done... The switch should now work if everything is done correctly.
There are tons of 'samples' in the ModelDef file, and you can look up the code of what you need in the SDK. (This is all for FSX by the way). But, you can use the FS2004 SDK for the code you'll need to activate what you need.
I am posting an attached 'fictional' switch below that works a fictional heater in the aircraft.
Note: Lag will change 'speed' of the animation. 50 is fast, 160 is slow....... slow slow. 10 would be a blip and 300 would crawl....... really crawl.
You will need to create new GUID's for the top code (which locates in the top portion of the ModelDef parts sheet), and the code block (bottom part) will locate in the bottom portion of the ModelDef file.
The cool thing about the bottom code is that you can re-use it over and over for tons of different things (that are fictional). You just change out the L:var code string, repeat it three times in the code block, make sure its not used again in any other codes, and you just keep going.
Example L:var;
(L:F24 FRONT CABIN HEATER, bool)
Make sure you put something in the TooltipText section. That will be the mouse-over message.
There are tons of things you can do with switches in the ToolTips. You can read more on those in the SDK. I recommend the Prepar3D SDK.
Lastly... Before you do this, make a copy of your ModelDef in case you mess it up. Saves you time. I put all my 'new' codes in the tops of the two sections of the ModelDef. If you mess up your code, it messes up the entire ModelDef, so that when you export a model, 'none' of the animations work. So you need to diagnose your code till it all works. If you do 10 new codes and suddenly it doesnt work (nothing), then you need to go in and do 'alot' of diagnosing to try to find the needle in the haystack that is causing the issue. A single symbol or letter can wreck the XML sheet.
Code:
<Animation name="f24_front_cabin_heater" guid="fc6cf956-db35-4464-8672-4a463cd95f4e" length="100" type="Sim" typeParam2="f24_front_cabin_heater" typeParam="AutoPlay" />
<PartInfo>
<Name>f24_front_cabin_heater</Name>
<Animation>
<Parameter>
<Code>(L:F24 FRONT CABIN HEATER, bool) 100 *</Code>
<Lag>160</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Front Cabin Heater</TooltipText>
<CallbackCode>
(L:F24 FRONT CABIN HEATER, bool) ! (>L:F24 FRONT CABIN HEATER, bool)
</CallbackCode>
</MouseRect>
</PartInfo>
Bill