On Wed, Jan 6, 2016 at 8:54 PM, Alex Harui <aha...@adobe.com> wrote:

> On 1/6/16, 6:35 PM, "Andy Dufilie" <andy.dufi...@gmail.com> wrote:
>
> >button is null because document.createElement("button") is not an instance
> >of MyButton.
>
> Andy is right.  We have not tried to extend the type system into the
> built-in classes.  Not sure we could guarantee that would work.  More
> below...
>
>
> >Is this supposed to work?
> >
> >MyButton.as
> >package {
> >public class MyButton extends HTMLButtonElement {
> >public function MyButton() {
> >super();
> >this.addEventListener("click", button_clickListener, false);
> >}
> >private function button_clickListener(event : MouseEvent) : void {
> >alert("Hello World");
> >}
> >}
> >}
> >
> >WebProject1.as
> >package {
> >public class WebProject1 {
>
> 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?

Thanks,
Om

Reply via email to