How to copy to clipboard in OpenFL Legacy?

Hi all,

For my game THE MISSION, I added a level editor. A friend of mine suggested the ability to share levels with other players. So what I would like is to convert the level into a string, and then copy that string to clipboard.

But I don’t know how to do it for OpenFL Legacy. It seems easy on OpenFL Next, but I have to remain on Legacy because there are some missing implementations for my game in Next. I looked in the src for Legacy, but nothing stood out to me as an obvious way to do it.

Did anybody work with the clipboard in Legacy and could share how they did it?

Thanks :slight_smile:

#if !mobile
openfl.system.System.setClipboard("your string");
#end

@Thomas_Bernard thanks for the response, but that’s for OpenFL Next, not Legacy :frowning:

No. It works on legacy too. I use it on legacy without any issue.

This is the error I get when I paste in your code above and try to compile:
Class<openfl._legacy.system.System> has no field setClipboard

I’m all up-to-date as well, so I don’t know how it’s working for you on Legacy.

Well I mistaken. I use it on flash and actually, when using openfl legacy, it is only working when targetting flash target (in witch case it uses flash.system.System). So it doesn’t seems to be implemented for openfl legacy System class; my bad. For openfl legacy, you can probably directly access the lime Clipboard Class and set Clipboard.text = yourstring

There is no legacy HTML5 or Flash target :wink: