You can move out of EES/EU, make your tax returns in Sweden and the other tax residency country for a few years (5-7), and Sweden will release you from taxing in Sweden. This works even if you own the stocks in a Swedish AB and sit in the board.
During the time you are a tax resident in Sweden and before you move out, it is important to choose your new tax residency country wisely, for example outside of EU/EES and with a tax treaty that will server your purpose.
If you want to, you could create a holding company in a different EU country,︀ sell your stocks to that company and transfer any (taxed) dividend profits there (but beware,︁ this is becoming a limited option as well, check for yourself, don't trust anyone on︂ this). The reason for doing this is that you found a tax treaty between your︃ new tax residency country and the EU country that will lower the taxes on the︄ dividends paid out. Either to yourself as a person or another company (holding). Do an︅ excel table and setup countries, check taxes, etc. Don't forget to check on the "bang︆ for buck" tax concept - what do you get for the taxes, although paying less,︇ in your new tax residency - better or not?
The cost of all this is︈ that once you leave EU and Sweden your possibility to be in control of the︉ company/companies through the board of directors will be limited. You will have to rely on︊ other people that are living in Sweden (and EU) to be on the board.
As a FOREIGN owner (UBO) of a Swedish AB the Swedish banks will f**k you so︋ hard and after that thank you by closing your company accounts - and you will︌ need to look into other banks outside of Sweden (and forget about bankgiro). Unless you︍ have a lot of dough to deposit or find some smaller Swedish bank that needs︎ your revenue, it may be very cumbersome.
The politicians in EU (and very much so️ in Sweden) will do everything to squeeze out any additional tax income and money leaking out of the country by using the banks, hiding behind the "money laundry"-concept and through in some stupid terrorism financing concept. The bank systems are just used by the politicians to get at the "little man" - I still have not heard of any of the big banks in Sweden that have not performed or are not performing money laundry. It's a joke (although not funny one).
It's definitely possible, but be aware of loosing your hair (unless you lost it already) ;-) And regarding accountants and tax lawyers -︀ you need a good one in each country and you should be very good at︁ asking the right questions (eg. don't trust them).
But once you arrive where you want︂ to be, it can be a pretty nice place to be in (compared to Sweden)︃ 😎