00:00
00:00
Newgrounds Background Image Theme

Snooze34 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Newgrounds Wiki: Connecting to the API

Adobe Flash

Flash users should follow the instructions on Using the API with Flash. The API Connector component will connect to the API if your API info has been entered into the connector parameters.

Code-based workflows

Code-based workflows should connect to the API using API.connect(). This call should be made before any other features of the API are used.
import com.newgrounds.*;
API.connect(root, "Your API ID", "Your Encryption Key");
Note that API.connect requires root, so it's best to avoid calling it in a constructor where root can be null. Instead, listen for the ADDED_TO_STAGE event before calling connect.

When the API has connected, it will fire the API_CONNECTED event.
import com.newgrounds.*;
API.addEventListener(APIEvent.API_CONNECTED, onAPIConnected);
API.connect(root, "Your API ID", "Your Encryption Key");

function onAPIConnected(event:APIEvent):void { if(event.success) { trace("The API is connected and ready to use!"); } else { trace("Error connecting to the API: " + event.error); } }
You are ready to go! You can now use the various API features in your movie. Try out some of the following features: