Developers » Flash SDK
Flash SDK
Currently you can use Flash SDK to:
  • Open the following windows: application installation, settings, friend invitation and vote input to pay for services.
  • Receive events after successful installation of the application by the user, change of settings and balance of the user within the application.
  • Send request to VK API.
Flash SDK initialization
To start using Flash SDK, you shall connect vk.APIConnection class (available in https://alliance-tools.ru/source/APIConnection.zip) to your project and create an instance of this class. The only parameter of its constructor is flashVars object.

Assembly guide

Application example for Flash Proxy with open source code:
Application example for Flash Proxy

Code example for application initialization
var flashVars: Object = stage.loaderInfo.parameters as Object;
var VK: APIConnection = new APIConnection(flashVars);


To test the application and make requests to API on a local computer you can add the following temporary values to flashVars:
if (!flashVars.api_id) {
 // -- For local testing enter you test-code here:
 flashVars['api_id'] = 1888171;
 flashVars['viewer_id'] = 66748;
 flashVars['sid'] = "7e22c25d7fece88f2316553937ff24f43e1073ca28e8b4302e65db35fa";
 flashVars['secret'] = "6113n3e4g3";
 // -- //
}


All other actions will be done with VK object.
Client API Calls
To make Client API calls you shall use the function of VK - VK.callMethod(methodName: String, param1, param2 ...) object.

List of Client API methods »
Calling VK API
To call VK API you shall use the function of VK - VK.api(methodName: String, params: Object, [onComplete: Function, OnError: Function]) object.
  • When the request is completed successfully, onComplete function will be called with the object containing the request result.
  • When the request fails, OnError function will be called with the object containing error data.
You can also call API using standard tools, making the request as follows.
Processing Events
While user is acting on the page with the application, VK object creates events which can be tracked and processed with addEventListener function. The below table shows a list of created events.

Each event has params field containing passed parameters.

Event name
Parameters
Description
onApplicationAdded
This event occurs when user adds the application to his/her page.
onSettingsChanged settings: NumberThis event occurs when user changes application settings. settings parameter of the object passed into callback function contains a bit mask of the set settings values. To learn more about application settings see account.getAppPermissions method description.
onBalanceChanged balance: NumberThis event occurs when the user credits or debits application vote balance. balance parameter contains current balance of the user in hundredth of a vote. This parameter can be used only for output for the user. Balance reliability shall always be checked with secure.getAppBalance method.
onOrderCancel
This event occurs when user cancels the purchase.
onOrderSuccessorderId: IntThis event occurs when purchase is completed successfully.
onOrderFail
This event occurs when purchase fails.
onWindowBlur
This event occurs when application window is blurred. For example, when user opens the window with application settings.
onWindowFocus
This event occurs when application window is in focus. For example, when user closes the window with application settings.

Code example of event processing using Actionscript 3:
apiConnection.addEventListener('onSettingsChanged', onSettingsChanged);
...
function onSettingsChanged(e: CustomEvent): void {
var settings: uint = e.params[0];
// do something
}