Suggestion regarding @:bind and hxclasses

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Suggestion regarding @:bind and hxclasses

Simon Krajewski
  Hello,

in my current workflow, the designer creates beautifully layouted
MovieClips using the Flash authoring tool. I can then use -swf-lib to
import these clips as classes, everything is typesafe and just nice. I
noticed you don't even have to use --gen-hx-classes at all to get code
completion in FlashDevelop, but I like to use it and modify the
resulting header classes to a @:bind class that has added functionality.

Something that still feels clunky happens if the designer changes one of
the MovieClips, i.e. by adding a new child with an instance name. In
order to get typed access to that child, I have manually create the
property in my @:bind class because --gen-hx-classes would just
overwrite everything.

How about adding a compiler switch like "-base-class-extension _Base"
that makes --gen-hx-classes handle a library class bar.Foo from the .swf
like this:
- create the class it usually creates (minus the extern declaration) in
hxclasses/_Base/bar/Foo_Base.hx
- create class @:bind Foo extends Foo_Base in hxclasses/bar/Foo.hx only
if the file does not exist

This way the classes from the .swf can be regenerated whenever necessary
without affecting functionality modifications and they immediately
provide typed access to new instance members, while you can go nuts on
Foo.hx without being worried about it being overwritten.

Any opinions?

Regards
Simon

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Nicolas Cannasse
Le 10/01/2011 10:20, Simon Krajewski a écrit :

> Hello,
>
> in my current workflow, the designer creates beautifully layouted
> MovieClips using the Flash authoring tool. I can then use -swf-lib to
> import these clips as classes, everything is typesafe and just nice. I
> noticed you don't even have to use --gen-hx-classes at all to get code
> completion in FlashDevelop, but I like to use it and modify the
> resulting header classes to a @:bind class that has added functionality.
>
> Something that still feels clunky happens if the designer changes one of
> the MovieClips, i.e. by adding a new child with an instance name. In
> order to get typed access to that child, I have manually create the
> property in my @:bind class because --gen-hx-classes would just
> overwrite everything.
>
> How about adding a compiler switch like "-base-class-extension _Base"
> that makes --gen-hx-classes handle a library class bar.Foo from the .swf
> like this:
> - create the class it usually creates (minus the extern declaration) in
> hxclasses/_Base/bar/Foo_Base.hx
> - create class @:bind Foo extends Foo_Base in hxclasses/bar/Foo.hx only
> if the file does not exist
>
> This way the classes from the .swf can be regenerated whenever necessary
> without affecting functionality modifications and they immediately
> provide typed access to new instance members, while you can go nuts on
> Foo.hx without being worried about it being overwritten.
>
> Any opinions?

You should be able to do simply extend a class that is defined in the SWF.

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Simon Krajewski
  Am 10.01.2011 10:54, schrieb Nicolas Cannasse:
> You should be able to do simply extend a class that is defined in the
> SWF.

Yes, but that does not affect instances that are already placed in the
swf, which is the whole point (sorry for not being clear on this), so it
could only be used for creating new instances from script.

Let's say the designer creates a MovieClip representing a special kind
of button, exports it as gui.SpecialButton and has it placed in several
other clips. Extending gui.SpecialButton would not affect these placed
instances, would it? I could only @:bind overwrite it, but then the
problem I initially mentioned occurs and design changes require manual
adjustments.

I also tried being tricky with @:native, but it's obviously not possible
for a class to pretend being the class it is extending.

Simon

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Simon Krajewski
  By the way, I remember the concept of generating two files from the
ActiveRecord representation of either Rails or some PHP framework (I
forgot actually). Creating model files from a database would result in
the creation of ModelBase and Model, with the former containing
everything you need to know about the model properties and the latter
extending it, providing a place for the programmer to implement the
model layer logic. A change in the database structure would overwrite
ModelBase, but not affect Model at all.

I just bring this up to show that this idea is a proven concept and the
scenario here is very similar. Database = swf-lib, database table =
exported class in swf-lib, property = property.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Nicolas Cannasse
In reply to this post by Simon Krajewski
Le 10/01/2011 11:25, Simon Krajewski a écrit :
> Am 10.01.2011 10:54, schrieb Nicolas Cannasse:
>> You should be able to do simply extend a class that is defined in the
>> SWF.
>
> Yes, but that does not affect instances that are already placed in the
> swf, which is the whole point (sorry for not being clear on this), so it
> could only be used for creating new instances from script.

Right.

Here's another way : define a simple empty  BaseClass.as and let your
designer extends it instead of MovieClip.

Then you can simply @:bind BaseClass

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Simon Krajewski
  Am 10.01.2011 11:46, schrieb Nicolas Cannasse:
> Right.
>
> Here's another way : define a simple empty  BaseClass.as and let your
> designer extends it instead of MovieClip.
>
> Then you can simply @:bind BaseClass

I don't think the base class in flash is meant for anything other than
MovieClip or Sprite or the like. Setting it to something that extends
MovieClip and clicking OK just makes Flash ignore it and set MovieClip
anyway.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Andy Li
If it doesn't mean anything, why is it there?
Have you really tried?

On Mon, Jan 10, 2011 at 6:56 PM, Simon Krajewski <[hidden email]> wrote:
 Am 10.01.2011 11:46, schrieb Nicolas Cannasse:

Right.

Here's another way : define a simple empty  BaseClass.as and let your designer extends it instead of MovieClip.

Then you can simply @:bind BaseClass

I don't think the base class in flash is meant for anything other than MovieClip or Sprite or the like. Setting it to something that extends MovieClip and clicking OK just makes Flash ignore it and set MovieClip anyway.


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Simon Krajewski
I open the properies and set my base class, also check if the definition is available:
http://simn.de/images/setbaseclass1.jpg
I click ok, click ok and reopen the properties:
http://simn.de/images/setbaseclass2.jpg

I don't know how I could mess this up, but I will look into it again. But even if it works, I don't see the benefits. IconContainer_Base will not know the properties the designer set in IconContainer, right? So if I @:bind it, I won't have any typed properties at all since it's just empty.

Am 10.01.2011 12:04, schrieb Andy Li:
If it doesn't mean anything, why is it there?
Have you really tried?

On Mon, Jan 10, 2011 at 6:56 PM, Simon Krajewski <[hidden email]> wrote:
 Am 10.01.2011 11:46, schrieb Nicolas Cannasse:

Right.

Here's another way : define a simple empty  BaseClass.as and let your designer extends it instead of MovieClip.

Then you can simply @:bind BaseClass

I don't think the base class in flash is meant for anything other than MovieClip or Sprite or the like. Setting it to something that extends MovieClip and clicking OK just makes Flash ignore it and set MovieClip anyway.


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Simon Krajewski
Alright, I got this working (honestly, I think Flash has some sort of bug here. It just started working all of a sudden but occasionally still resets to MovieClip). I'm surprised to see that the properties actually end up as members of IconContainer_Base instead of IconContainer, so I can just @:bind IconContainer and have access to everything. It's still quite a chore to manually set a base class for every class like this and I still think it's something that could be automated, but then again it's working, so thanks for the suggestion!

Simon

Am 10.01.2011 12:30, schrieb Simon Krajewski:
I open the properies and set my base class, also check if the definition is available:
http://simn.de/images/setbaseclass1.jpg
I click ok, click ok and reopen the properties:
http://simn.de/images/setbaseclass2.jpg

I don't know how I could mess this up, but I will look into it again. But even if it works, I don't see the benefits. IconContainer_Base will not know the properties the designer set in IconContainer, right? So if I @:bind it, I won't have any typed properties at all since it's just empty.

Am 10.01.2011 12:04, schrieb Andy Li:
If it doesn't mean anything, why is it there?
Have you really tried?

On Mon, Jan 10, 2011 at 6:56 PM, Simon Krajewski <[hidden email]> wrote:
 Am 10.01.2011 11:46, schrieb Nicolas Cannasse:

Right.

Here's another way : define a simple empty  BaseClass.as and let your designer extends it instead of MovieClip.

Then you can simply @:bind BaseClass

I don't think the base class in flash is meant for anything other than MovieClip or Sprite or the like. Setting it to something that extends MovieClip and clicking OK just makes Flash ignore it and set MovieClip anyway.


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

jlm@justinfront.net
Simon 

flash IDE does have javascript that you can use to automate code, it may even be possible to create with haXe, I think there might be a lib someone made... but probably a lot of hassle.

Cheers

;j
On 10 Jan 2011, at 12:27, Simon Krajewski wrote:

Alright, I got this working (honestly, I think Flash has some sort of bug here. It just started working all of a sudden but occasionally still resets to MovieClip). I'm surprised to see that the properties actually end up as members of IconContainer_Base instead of IconContainer, so I can just @:bind IconContainer and have access to everything. It's still quite a chore to manually set a base class for every class like this and I still think it's something that could be automated, but then again it's working, so thanks for the suggestion!

Simon

Am 10.01.2011 12:30, schrieb Simon Krajewski:
I open the properies and set my base class, also check if the definition is available:
http://simn.de/images/setbaseclass1.jpg
I click ok, click ok and reopen the properties:
http://simn.de/images/setbaseclass2.jpg

I don't know how I could mess this up, but I will look into it again. But even if it works, I don't see the benefits. IconContainer_Base will not know the properties the designer set in IconContainer, right? So if I @:bind it, I won't have any typed properties at all since it's just empty.

Am 10.01.2011 12:04, schrieb Andy Li:
If it doesn't mean anything, why is it there?
Have you really tried?

On Mon, Jan 10, 2011 at 6:56 PM, Simon Krajewski <[hidden email]> wrote:
 Am 10.01.2011 11:46, schrieb Nicolas Cannasse:

Right.

Here's another way : define a simple empty  BaseClass.as and let your designer extends it instead of MovieClip.

Then you can simply @:bind BaseClass

I don't think the base class in flash is meant for anything other than MovieClip or Sprite or the like. Setting it to something that extends MovieClip and clicking OK just makes Flash ignore it and set MovieClip anyway.


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Simon Krajewski
Thanks for the hint, I had a look at the jsfl stuff and it turned out to be fairly easy to write a code generator for base classes. So everything works now.

Simon

Am 10.01.2011 15:17, schrieb [hidden email]
Simon 

flash IDE does have javascript that you can use to automate code, it may even be possible to create with haXe, I think there might be a lib someone made... but probably a lot of hassle.

Cheers

;j
On 10 Jan 2011, at 12:27, Simon Krajewski wrote:

Alright, I got this working (honestly, I think Flash has some sort of bug here. It just started working all of a sudden but occasionally still resets to MovieClip). I'm surprised to see that the properties actually end up as members of IconContainer_Base instead of IconContainer, so I can just @:bind IconContainer and have access to everything. It's still quite a chore to manually set a base class for every class like this and I still think it's something that could be automated, but then again it's working, so thanks for the suggestion!

Simon

Am 10.01.2011 12:30, schrieb Simon Krajewski:
I open the properies and set my base class, also check if the definition is available:
http://simn.de/images/setbaseclass1.jpg
I click ok, click ok and reopen the properties:
http://simn.de/images/setbaseclass2.jpg

I don't know how I could mess this up, but I will look into it again. But even if it works, I don't see the benefits. IconContainer_Base will not know the properties the designer set in IconContainer, right? So if I @:bind it, I won't have any typed properties at all since it's just empty.

Am 10.01.2011 12:04, schrieb Andy Li:
If it doesn't mean anything, why is it there?
Have you really tried?

On Mon, Jan 10, 2011 at 6:56 PM, Simon Krajewski <[hidden email]> wrote:
 Am 10.01.2011 11:46, schrieb Nicolas Cannasse:

Right.

Here's another way : define a simple empty  BaseClass.as and let your designer extends it instead of MovieClip.

Then you can simply @:bind BaseClass

I don't think the base class in flash is meant for anything other than MovieClip or Sprite or the like. Setting it to something that extends MovieClip and clicking OK just makes Flash ignore it and set MovieClip anyway.


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion regarding @:bind and hxclasses

Kelvin Luck
If you are using JSFl you may want to also check out xJSFl:

http://www.xjsfl.com/

Not sure if it is downloadable yet but I bookmarked it a while back, looks like it cleans up the JSFl API quite a bit...

Hope it helps,

Kelvin :)

On 10/01/2011 16:14, Simon Krajewski wrote:
Thanks for the hint, I had a look at the jsfl stuff and it turned out to be fairly easy to write a code generator for base classes. So everything works now.

Simon

Am 10.01.2011 15:17, schrieb [hidden email]
Simon 

flash IDE does have javascript that you can use to automate code, it may even be possible to create with haXe, I think there might be a lib someone made... but probably a lot of hassle.

Cheers

;j
On 10 Jan 2011, at 12:27, Simon Krajewski wrote:

Alright, I got this working (honestly, I think Flash has some sort of bug here. It just started working all of a sudden but occasionally still resets to MovieClip). I'm surprised to see that the properties actually end up as members of IconContainer_Base instead of IconContainer, so I can just @:bind IconContainer and have access to everything. It's still quite a chore to manually set a base class for every class like this and I still think it's something that could be automated, but then again it's working, so thanks for the suggestion!

Simon

Am 10.01.2011 12:30, schrieb Simon Krajewski:
I open the properies and set my base class, also check if the definition is available:
http://simn.de/images/setbaseclass1.jpg
I click ok, click ok and reopen the properties:
http://simn.de/images/setbaseclass2.jpg

I don't know how I could mess this up, but I will look into it again. But even if it works, I don't see the benefits. IconContainer_Base will not know the properties the designer set in IconContainer, right? So if I @:bind it, I won't have any typed properties at all since it's just empty.

Am 10.01.2011 12:04, schrieb Andy Li:
If it doesn't mean anything, why is it there?
Have you really tried?

On Mon, Jan 10, 2011 at 6:56 PM, Simon Krajewski <[hidden email]> wrote:
 Am 10.01.2011 11:46, schrieb Nicolas Cannasse:

Right.

Here's another way : define a simple empty  BaseClass.as and let your designer extends it instead of MovieClip.

Then you can simply @:bind BaseClass

I don't think the base class in flash is meant for anything other than MovieClip or Sprite or the like. Setting it to something that extends MovieClip and clicking OK just makes Flash ignore it and set MovieClip anyway.


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org