custom classes with jeash

Asked by ajerinic

Hi

I'm trying to extend Sprite class with some public properties and methods, and then call them from Main class (NME ofcourse):
/////////////////////////////////////////////
var item = new FilmstripItem("abc");
stage.addChild(item);
item.addEventListener(MouseEvent.CLICK, item_click);
...
private function item_click(e:MouseEvent):Void {
var a:FilmstripItem;
a = cast e.target;
trace(e.target.url);
}
/////////////////////////////////////////////
and the custom FilmstripItem class:
/////////////////////////////////////////////
import nme.display.Sprite;

class FilmstripItem extends Sprite{

public var url : String;

public function new(url:String) {
this.url = url;
super();
}
}
/////////////////////////////////////////////
it works fine when I build it for flash output, but, in html5 the value is null. I also tried with the method inside of FilmstripItem class, but it gives me error (the popup comes out with script error message boot_closure@67)

Is it possible to do it?

thanks

Question information

Language:
English Edit question
Status:
Solved
For:
jeash Edit question
Assignee:
No assignee Edit question
Solved by:
ajerinic
Solved:
Last query:
Last reply:
Revision history for this message
Niel Drummond (niel-drummond) said :
#1

Can't reproduce... sorry.

My test case is:

http://smoke.jeash.com/bugs/MouseSprite.hx
http://smoke.jeash.com/bugs/MouseSprite.html

and works fine.

Revision history for this message
ajerinic (ajerinic) said :
#2

Well, the problem was in bitmap, I added on sprite to be clickable, and the e.target was bitmap, not my class that extended sprite class. Now I'm using currentTarget, and it works fine (capture phase...)

thanks for your help