Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a share button in AS3

I was wondering if anyone knew a good way of creating an AS3 Facebook share button? I need to be able to customize the title, description and picture. Thanks!

like image 883
alvincrespo Avatar asked Mar 24 '10 22:03

alvincrespo


3 Answers

Look: http://www.facebook.com/facebook-widgets/share.php

http://www.facebook.com/sharer.php?u=<url>&t=<title>

In Flash:

import flash.net.navigateToURL;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;

share_btn.addEventListener(MouseEvent.CLICK, shareClickHandler);

function shareClickHandler(evt:MouseEvent):void
{
    var varsShare:URLVariables = new URLVariables();
    varsShare.u = 'http://domain.com/pageN.html';
    varsShare.t = 'Title Page';

    var urlFacebookShare:URLRequest = new URLRequest('http://www.facebook.com/sharer.php');
    urlFacebookShare.data = varsShare;
    urlFacebookShare.method = URLRequestMethod.GET;

    navigateToURL(urlFacebookShare, '_blank');
}

In order to use a picture add the following Metatags:

<meta name="title" content="my title" />
<meta name="description" content="my description" />
<link rel="image_src" href="images/thumbnail_image.jpg" />

For more info: https://developers.facebook.com/docs/opengraph/

like image 83
Renzo Castro Avatar answered Oct 15 '22 03:10

Renzo Castro


here you go:

redirect_uri is required (and must redirect to your application site as defined in the facebook application settings page)

var req:URLRequest = new URLRequest();
req.url = "http://www.facebook.com/dialog/feed";
var vars:URLVariables = new URLVariables();
vars.app_id = "000000000000"; // your application's id
vars.link = "http://YourSite.com";
vars.picture = "https://www.google.com/intl/en_com/images/srpr/logo3w.png";
vars.name = "name name";
vars.caption = "caption caption caption";
vars.description = "description description description";
vars.message = "message message message message message";
vars.redirect_uri = "http://YourSite.com";
req.data = vars;
req.method = URLRequestMethod.GET;
navigateToURL(req, "_blank");
like image 38
Sagi Avatar answered Oct 15 '22 02:10

Sagi


It depends on what you wish to share.

You can use the following url in a button:

http://www.facebook.com/share.php?u=http://www.mypage.com/

which will pop up a page prompting the user to log in and share whatever they want to share.

Could you be more precise as to what you want to allow your users to share?

like image 30
Christopher Richa Avatar answered Oct 15 '22 02:10

Christopher Richa