Simulating Pencil Tool in AS3



var drawing:Boolean = false;
this.graphics.lineStyle(1, 0x000000);
this.graphics.moveTo(mouseX, mouseY);
this.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onDown, false, 0,true);
stage.addEventListener(MouseEvent.MOUSE_UP, onUp, false, 0, true);

function onDown(evt:MouseEvent):void
{
     drawing = true;
}
function onUp(evt:MouseEvent):void
{
     drawing = false;
}

function onLoop(evt:Event):void
{
     if (drawing)
     {
          this.graphics.lineTo(mouseX, mouseY);
     }
     else
     {
          this.graphics.moveTo(mouseX, mouseY);
     }
}

0 comments :

Get long lived access_token for facebook pages


Facebook API’s allows a developer to update a cover photo of a page through code. I am creating a Live Cover photo change App for One of the client. this apps mechanism is to change cover photo depending on the no of likes of page.

for such type of apps. you need a long lived access_token so you can run a script from server itself.

Following it the step-by-step process.

1)   Make Sure you are the admin of FB Page.
2)   Create a FB App with same user account.
4)   On the Top Right , Select the FB App you created from the "Application" drop down list.
5)   Click "Get Access Token" Button.
    Select Permission Window will open.
6)   Click on "Extended Permission" Tab and Check "manage_pages" permission
7)   type "me/accounts" in FQL Query Box.
    It show you complete listing of page details like category, name, access_token, permissions..
    This Access token is short-lived-token. you have to convert this short live token to long lived token.
8)   https://graph.facebook.com/oauth/access_token?client_id={fb_app id}&client_secret={fb_app_secret}&grant_type=fb_exchange_token&fb_exchange_token={short-lived-access_token}
9)   Grab the new long-lived access token.
10) Make A Graph API call to see your account using the new long-lived access token
      https://graph.facebook.com/me/accounts?access_token={your_long_lived_access_token}
11) Grab the access_token for the page.
12) You can use following link to https://developers.facebook.com/tools/debug/  to get Access Token Info. 
It will provide info like Application ID, Profile ID, User ID, Issued, Expires, Scopes etc.

This step-by-step process will give you Long Lived Access Tokens.


0 comments :