Advertisement
Guest User

Untitled

a guest
Nov 30th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.24 KB | None | 0 0
  1. package;
  2.  
  3. import com.poki.*;
  4. import com.stencyl.Engine;
  5. import com.stencyl.event.EventMaster;
  6. import com.stencyl.event.StencylEvent;
  7.  
  8. class PokiFlash
  9. {
  10.     public var PokiSDK:PokiFlashSDK;
  11.    
  12.     //public static function start(instance:Dynamic)
  13.     public function new()
  14.     {
  15.     //I'll do  PokiSDK = new PokiFlashSDK(); here when I'll learn how to make a Singleton
  16.     }
  17.    
  18.     public function start()
  19.     {
  20.         trace ("started");
  21.         PokiSDK = new PokiFlashSDK();
  22.         PokiSDK.Init(openfl.Lib.current);
  23.         PokiSDK.enableLogs = true;
  24.     }
  25.    
  26.     public function getAd(position:String)
  27.     {      
  28.         try {
  29.             if (position == "preroll")
  30.             {
  31.                 PokiSDK.RequestAd(PokiAdPosition.preroll);
  32.                 trace ("preroll add requested");
  33.             }
  34.             else if (position == "midroll")
  35.             {
  36.                 PokiSDK.RequestAd(PokiAdPosition.midroll);
  37.                 trace ("midroll add requested");
  38.             }
  39.             else
  40.                 trace ("Unknown ad requested");
  41.         } catch(e:Dynamic) {
  42.             trace("Error, cannot trigger ad, reason:" + e.message);
  43.         }
  44.     }
  45.    
  46.    
  47.     //public static function addListener(type:String, func:Dynamic):Void
  48.     public function AddListener(type:String, func:Void -> Void):Void
  49.     {
  50.         //PokiSDK.AddEventListener(type, func);
  51.         PokiSDK.AddEventListener(PokiAdEvent.completed, function(){trace ("HELLO!!!");});
  52.     }
  53.    
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement