Вопрос

I've followed this awesome tutorial for creating an interactive legend to hide and display a chart series.

The problem is the legend items do not react to touch events for mobile.

I've tried all of these.

itemMouseDown="clickLegend(event)"  itemMouseOver="clickLegend(event)" itemMouseUp="clickLegend(event)"
                       itemClick="myLegend_itemClickHandler(event)"

How do I determine which legend item was touched? Should I overlay invisible buttons?

Это было полезно?

Решение

You should add a TOUCH_TAP event listener to each legend item, as displayed in the function MyLegendItem() for mouse down event. Just add this line to the constructor:

addEventListener(TouchEvent.TOUCH_TAP,handleEvent);

You will have to change the event type on handleEvent declaration to Event instead of MouseEvent, because TouchEvent and MouseEvent are not directly related.

Also, the syntax you've tried is not AS3, but rather JS or AS1 instead. You should first search for proper AS3 syntax to try.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top