samedi 11 juin 2016

Actionscript- How to program a touch event that executes code every x amount of clicks?

I want to set up my buttons in my actionscript project to show ads every x amount of clicks. So for instance, a user would click my button and on the 5th click it would display an ad. So far I have

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

button_30.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler);

function fl_TapHandler(event:TouchEvent):void
        AdMob.loadInterstitial("myadunitid", true);

The code executes correctly, but don't know how to make it execute every 5 clicks. So for this I want to

  1. Make the button show an ad every 5 clicks
  2. Apply the same code to other buttons so they share the counter (make them the same instance maybe?)
  3. Have the counter transfer over to other scenes, so if users go to another scene, the counter doesn't reset and every 5th click is guaranteed to show an ad.

I'm also using the Milkman ANE for anyone confused by the interstitial line.

Much help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire