I'm coding with FlashDevelop. Here's what I do for initializing the connection:
API.debugMode = API.RELEASE_MODE;
API.addEventListener(APIEvent.API_CONNECTED, onConnected);
API.connect(root, myApiID, myEncryptionKey);
The "onConnected" doesn't seem to be called in the game page, but it's always called when I debug in FlashDevelop.
Maybe someone that uses Flash Develop could bring more insight as I haven't made there switch to that yet (very soon tho). However, I did code everything with NG's API rather than using the components on stage.
I didn't bother setting the debug mode like you did - I just omitted it which I assume just leaves it in its default state. I also didn't do: PI.addEventListener(APIEvent.API_CONNECTED, onConnected); like you did - left that out as well.
I just added all the necessary imports for NG's API at the top of my game manager class and did
API.connect(root, myApiID, myEncryptionKey); like you did in the constructor.
Then simply did API.unlockMedal("medal name"); where a medal needed to be unlocked.