flump icon indicating copy to clipboard operation
flump copied to clipboard

Custom properties

Open CrazyFlasher opened this issue 8 years ago • 8 comments

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

CrazyFlasher avatar Sep 01 '16 11:09 CrazyFlasher

+1

mathieuanthoine avatar Oct 03 '16 15:10 mathieuanthoine

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

CrazyFlasher avatar Oct 03 '16 19:10 CrazyFlasher

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

tconkling avatar Oct 03 '16 20:10 tconkling

  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 !

mathieuanthoine avatar Oct 03 '16 20:10 mathieuanthoine

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.

CrazyFlasher avatar Oct 04 '16 06:10 CrazyFlasher

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> <DOMSymbolInstance libraryItemName="Bob"> <matrix> <Matrix tx="197.45" ty="159.55"/> </matrix> <transformationPoint> <Point/> </transformationPoint> <persistentData> <PD n="myAlign" v="left"/> </persistentData> </DOMSymbolInstance> </elements>

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

mathieuanthoine avatar Oct 04 '16 08:10 mathieuanthoine

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

mathieuanthoine avatar Oct 09 '16 16:10 mathieuanthoine

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.

jackwlee01 avatar Mar 14 '17 23:03 jackwlee01