Custom Rotation for a tilted aircraft flap I've been modeling an F-15, but when I rotate the flaps on Y-Axis the Flaps offset from the wing and they look like they are about to fall out, so I end up correcting it by rotating in the X and Z-axis to align them correctly.

However when I rotate them back from the Y-Axis they look distorted again because I did rotations on the X and Z axis. I tried riding it, no help. I saw something about custom orientation to fix it but that was not clearly explained and it was done on an ideal plane that was (0,0,0); mine is pre-rotated on all axis. 

I'll take scripts if needed and I'm using Blender 2.8.

When I rotate it on the Y-Axis:



Fixing it using X and Z rotation:



Rotating it back on the Y distorted it again:



Here's the wing with ailerons and flaps:
If you do it this way it seems to work:


Create a bone, in the Properties panel > Data > Display, enable X-Ray (called In Front in 2.8).
Put the bone along the aileron's axis. Use the shiftS > Cursor To Selected and the shiftS > Selection To Cursor to make sure the head and tail of the bone are on the exact positions.
If you want the bone to be displayed as B-Bone, go in the Properties panel > Data > Display (altctrlS to change its thickness).
Parent the aileron to the bone With Automatic Weight.
Select the bone, switch to Pose mode, create a first keyframe with i > RotLocScale.
In the Dopesheet go to frame 20, rotate the bone on its Y axis with RYY. Create a second keyframe.
The bone should make the aileron rotate correctly. You'll have to parent the bone to the wing bone (or whatever bone that will make the aileron stick to the plane).