Let's see...spend money to spray foam onto flex ducts, or spend money to spray foam onto the roof deck. Hmm...which to do, which to do??
If those were my only two options, in a heartbeat I would foam the roof deck and leave the flex alone.
The foamed deck will return more benefit than the foamed ducts. Again, why? The foamed deck is a continuous benefit, whereas the foamed ducts only benefit when the HVAC is running. And does nothing to reduce heat gain or loss to the house at large. Foaming the deck reduces heat gain/loss to the house AND the ducts.
Building Physics Rule #1: Hot flows to cold.
Building Physics Rule #2: Higher air pressure moves toward lower air pressure
Building Physics Rule #3: Higher moisture concentration moves toward lower moisture concentration.