On 1/6/16, 11:36 PM, "omup...@gmail.com on behalf of OmPrakash Muppirala"
<omup...@gmail.com on behalf of bigosma...@gmail.com> wrote:

>>
>> Add the following as the ASDoc for the WebProject1() method, then it
>> should work:
>>
>> /**
>>  * @flexjsignorecoercion MyButton
>>  */
>> >public function WebProject1() {
>> >var button : MyButton = document.createElement("button") as MyButton;
>> >button.innerHTML = "Press Me";
>> >document.body.appendChild(button);
>> >}
>> >}
>> >}
>>
>
>That kind of worked.  Compiles fine and creates the button.  But
>MyButton's
>constructor does not get called.  Any code I write inside MyButton.as
>seems
>to be moot.
>
>I'm wondering if document.createElementNS might be useful here?

Well, I doubt it.  IMO, you are trying to mix scripting APIs with
object-oriented APIs.  Just like you wouldn't create a plain button by
calling "new HTMLButtonElement()", you have to pick a pattern and stick
with it.

The FlexJS framework components internally call createElement for you and
wrap the HTMLButtonElement since you can't actually subclass it and
instantiate it.  If HTML had an extensible component/element API we
probably wouldn't have bothered to create FlexJS.

Then you can use all object-oriented APIs/patterns since that's what we're
used to in ActionScript/Flash.  I suppose you could create another
component set that even more thinly wraps HTMLButtonElement than we do
already, and then make "new HTMLButtonElement()" work.  I've chosen to
pack a bit more in org.apache.flex.html.Button so it can have more
Flex-like APIs

-Alex

Reply via email to