In your particular example, you have around 25.6% equity when you have a flush draw on the flop and you're up against a set . It is pretty confusing though...
Lets break it down:
You have A♠Q♠
The board on the flop is 2♠4♠8♣
Your opponent has 4♦4♥ for the set.
There are 13 spades total in the deck. You are holding 2 spades and there are 2 spades on the board. There are 9 spades left. The 8♠ will give your opponent a full house, so that doesn't count. On the turn, there are 8 spades in the deck that will give you the flush and not give your opponent a better hand. The chances of you hitting one of those 8 spades on the turn is around 16%.
Let's say you do hit your 16% chance on the turn. It's the 9♠. You're opponent can still beat you if he hits a full house or quads on the river. He can hit a 4♣ (1 out), an 8 (3 outs), a 2 (3 outs) or a 9 (3 outs). He has a total of 10 outs, or a 20% chance of winning. So really, your odds of winning the entire hand if you hit your flush on the turn is around 12.8% (16% * 80%). You multiply by 80% because your opponent will still win 20% of the time (100-20=80).
Now let's say you don't hit your flush on the turn. It's the Q♥. Instead of having 8 outs to hit your flush, you now have 7 because if the Q♠ comes on the river, your opponent will hit a full house and beat your flush. That leaves you with only a 14% chance of improving on the river.
So in total, you have 12.8% + 14% = 26.8%
Our calculations are by 1.2% due to rounding errors, but it's accurate enough for most situations.