Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BaseMediatorProcessor #18

Open
commovere opened this issue Jan 25, 2013 · 5 comments
Open

Update BaseMediatorProcessor #18

commovere opened this issue Jan 25, 2013 · 5 comments

Comments

@commovere
Copy link

Hi,

In my game I have few subclasses of BasePopup (custom DisplayObject class) and mediator for all my popups.
I have to create [ViewAdded] method for each BasePopup subclass
But I want to do something like this

[ViewAdded]
public function viewAdded(popup:BasePopup):void {
    if(popup is PopupClass1){
        // do something
     } else if(popup is PopupClass2){
        // do something else
     }
}
@commovere
Copy link
Author

I think you can change

if (method.parameters.length == 1 && method.parameters[0].type == ViewClass)

to something like this

if (method.parameters.length == 1 && method.parameters[0].type.prototype.isPrototypeOf (ViewClass.prototype))

@ivan-shaban
Copy link

+1

1 similar comment
@zaidite
Copy link

zaidite commented Feb 6, 2013

+1

@fernandocosta
Copy link

that would be nice feature

@Gohloum
Copy link

Gohloum commented Mar 23, 2017

I wanted to do something similar which was identify some views by the implemented Interface instead of the class itself. Here is what I have done which appears to be working. Hope this helps others:

if (method.parameters.length == 1 && method.parameters[0].type == ViewClass)
{
    target[method.name](view);
} else if (method.parameters.length == 1 && view is method.parameters[0].type)
{
    target[method.name](view);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants