feathersui / feathersui-starling-sdk

SDK for building Feathers UI (AS3/Starling) applications with MXML
https://feathersui.com/learn/as3-starling/sdk/
Apache License 2.0
42 stars 13 forks source link

[Bindable] on Class throws Flex error #44

Closed mphkz closed 7 years ago

mphkz commented 7 years ago

Hi,

I created a Flex Library Project, and added some classes. I referenced the project on the Feathers SDK project.

If I add the metatag [Bindable] to the Class or to some var, will throw this error: 1046: Type was not found or was not a compile-time constant: [flash.events]::IEventDispatcher. Unknown Flex Problem

What can I do? should I reference some FlexSDK swc?

Kind regards

joshtynjala commented 7 years ago

Is your library project compiled with the Feathers SDK too?

should I reference some FlexSDK swc?

No, that's not necessary.

mphkz commented 7 years ago

No Josh, is compiled with AIR SDK 23.

I'm seeing this forum post: http://forum.starling-framework.org/topic/eventdispatcher-conflict

I think is the same problem 😢

joshtynjala commented 7 years ago

AIR SDK does not support [Bindable]. You should compile your library project with the Feathers SDK if you want to add [Bindable] to anything in that project.

mphkz commented 7 years ago

I'm sorry Josh, I de-referenced the library project, and copied all folder inside the feathers app, so that way is compiled with Feathers SDK.

Then throw the error Description Resource Path Location Type Class must extend the required base class starling.events.EventDispatcher. So then I extended the Class from starling.events.EventDispatcher and I hit the wall of the RemoteObject invalid request 😭

I guess I will have to deal Bindables with RobotLegs or my own BindingUtil?

joshtynjala commented 7 years ago

You can extend flash.events.EventDispatcher instead. The compiler suggests starling.events.EventDispatcher because that's better most of the time, but both are allowed.

joshtynjala commented 7 years ago

By the way, if you want the code to be in a library project, create a Flex library project and tell it to use the Feathers SDK instead of the Flex SDK.

mphkz commented 7 years ago

Seems like I was already building with Feathers SDK, on the properties only show AIR 23 but I remember this FB workspace was created only with this SDK.

Extending flash.events.EventDispatcher worked! I didn't know that I had to extend it explicitly (I was not used to it on Flex and I thought was by default). My intention is to use the same Flex Library for all company apps.. and there are many ^^

Anyway, thank you very much! another problem solved 😄

joshtynjala commented 7 years ago

The reason that you need to extend flash.events.EventDispatcher explicitly is that Feathers is built on Starling, and so starling.events.EventDispatcher is preferred. Ideally, when you add [Bindable] to a class, the compiler should have automatically made the class extend starling.events.EventDispatcher, similar to how the Flex SDK automatically does it automatically with Flash's EventDispatcher, but I couldn't make that work. That's why there's the "Class must extend the required base class starling.events.EventDispatcher" compiler error.

Anyway, since Starling classes get priority, when you want to use Flash events with binding instead, you need to explicitly extend flash.events.EventDispatcher (or one of its subclasses). This isn't really documented because people should use starling.events.EventDispatcher most of the time. However, I definitely want to be sure that both types of events are always supported for binding.