Skip to content

MXML: add implicit data parameter to code-generated Starling event listeners #22

Open
@teotigraphix

Description

@teotigraphix

Edited by @joshtynjala

A second implicit parameter should be available to MXML events. Just like you can reference an event parameter, data would also be available, and you could optionally pass them both to your listener in the Script block. Example:

triggered="buttonGroup_triggeredHandler(event, data)"

Original Post:

Hey,

I have run into something I haven't tried before and just was wonder if I am missing something or it's just not possible.

Adding an event handler for triggered in MXML, there is no way to get that selectedItem in the dataProvider with a one argument event handler the compiler wants.

    <f:ButtonGroup id="buttonGroup"
                   direction="vertical"
                   padding="15" width="300"
                   triggered="buttonGroup_triggeredHandler(event)">
        private function buttonGroup_triggeredHandler(event:starling.events.Event, data:Object):void
        {
            dispatchEventWith(EVENT_BUTTON_TRIGGERED, false, data);
        }

I get a;
Error:(30, 0) [PackageManager]: Error code: 1136: Incorrect number of arguments. Expected 2.

I am only asking because I thought it might just be one of those things IDEA does but, this is an actual compiler error.

So this seems only possible to do in AS right? If so, is there anyway we could make it work in MXML like above?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions