in this presentation we give a brief intro to Social Gold, an overview of the in-flash solution architecture followed by a step by step integration example.
39. service = new SocialGoldService(); service.userId = parameters.userId; service.signingKey = parameters.signingKey; service.offerId = ‘yourofferidhere’; // Set a display object container for the buyCurrency UI: service.modalParent = stage; // Pass in ‘sandbox’ or ‘production’ for environment: service.environment = parameters.environment; // Set true to use Flash UI for buyCurrency calls: service.useInAppPayments = true; // (Optional) Set true when debugging: service.debug = (parameters.environment != ‘production’);
41. var request:SocialGoldRequest = service.buyCurrency(); // Called on Success: request.addEventListener(SocialGoldEvent.SUCCESS, buyCurrencySuccessHandler); // Called on Failure: request.addEventListener(SocialGoldEvent.FAILURE, buyCurrencyFailureHandler); // Called after every request: request.addEventListener(SocialGoldEvent.COMPLETE, buyCurrencyCompleteHandler); private function buyCurrencySuccessHandler(event:SocialGoldEvent):void { trace(">> buyCurrency SUCCESS"); } private function buyCurrencyFailureHandler(event:SocialGoldEvent):void { trace(">> buyCurrency FAILURE"); } private function buyCurrencyCompleteHandler(event:SocialGoldEvent):void { trace(">> buyCurrency COMPLETE"); }
43. // Called when UI load starts: request.addEventListener(SocialGoldEvent.UI_LOAD_STARTED, uiLoadStartedHandler); // Called when UI load is complete: request.addEventListener(SocialGoldEvent.UI_LOAD_COMPLETED, uiLoadCompletedHandler); private function uiLoadStartedHandler(event:SocialGoldEvent):void { trace(">> uiLoadStartedHandler"); addChild(yourLoadingAnimationInstance); } private function uiLoadCompletedHandler(event:SocialGoldEvent):void { trace(">> uiLoadCompletedHandler"); removeChild(yourLoadingAnimationInstance); }