tconkling / flump

Exports Flash .FLAs to GPU-friendly formats
MIT License
381 stars 70 forks source link

Custom properties #153

Open CrazyFlasher opened 8 years ago

CrazyFlasher commented 8 years ago

Is it possible to add some plain Object to layer in fla, that will contain some custom properties? For example to manually build TextField's

mathieuanthoine commented 8 years ago

+1

CrazyFlasher commented 8 years ago

Currently I use layer name and parse it. Something like this: @tf:tf:#20#0xD4BEA9#Bitter But that's not very comfortable.

tconkling commented 8 years ago

I'm open to this idea - how are you thinking the layer properties would be populated at design time?

mathieuanthoine commented 8 years ago

1) For symbols that we want to get custom Data, change the symbols inheritance by a custom class instead of MovieClip or Sprite that implements CustomFlumpData 2) CustomFlumpData: public interface CustomFlumpData { public function customData () : Object; } 3) In the Exporter: save the customdData object in the description JSon 4) In the Runtime: add a getCustomData method on the FlumpMovie or FlumpSprite that give access to the data. It could be awesome to improve Flump !

CrazyFlasher commented 8 years ago

Well, may be the easiest way (not sure, that it is a clean way) would be to fetch object from first frame in layer timeline. Call it, for exapmple customData. var customData:Object = { myProp:"Hello" }; Exporter will fetch all properties with Object (or just object with customData name?) type and make them available at runtime.

mathieuanthoine commented 8 years ago

May be the most elegant way could be to use persistent data that are stored in the Xfl description files. var elem = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].etPersistentData( "myAlign", "string", "left" );

And in DOMDocument.xml:

`

                               </elements>`

Obviously it would need a custom panel to manage that easily.

mathieuanthoine commented 7 years ago

I've just submit a PR for custom data support : https://github.com/tconkling/flump/pull/157 I hope you'll find it interesting

jackwlee01 commented 7 years ago

This would be an extremely useful feature and would fill a lot of gaps currently in the tool. My company builds games with very heavy UI requirements. I would like to utilise Flump for building UI components, and a feature like this would open up many potential use cases for the tool.