Skip to main content
Inspiring
August 26, 2013
Question

A share in facebook question

  • August 26, 2013
  • 1 reply
  • 1059 views

Guys...

I was looking for a way to share in facebook a score a user can make playing a game...

I found this website: http://www.actionscript.org/resources/blogs/52/Facebook-and-Twitter-buttons-in-Flash-and-Flex.html so I went ahead and copied the code, modified it and placed in my actionscript...

However it shares the webpage I put in the link, but it does not put the text...and, also, what I would like it to say is something like: Can you beat my score of (count)? ...

Now, is it possible with something like this? What should I add?

Here is the code: (count is the var where I have the score made in the game)

if (espanol) addChild(botonface);

if (ingles) addChild(btnface);

btnface.addEventListener(MouseEvent.CLICK, goFace);

botonface.addEventListener(MouseEvent.CLICK, goFace);

function goFace(e:MouseEvent):void {

    btnface.removeEventListener(MouseEvent.CLICK, goFace);

    botonface.removeEventListener(MouseEvent.CLICK, goFace);

    socialUpdate("facebook", "Can you beat my score", "www.google.com");

}

function socialUpdate(site:String, text1:String = "",  link:String = "")

{

    var siteURL:String;

    var maxLength:Number;

    switch (site) {

        case "facebook":

        maxLength = 255;

        break;

        default:

        return;

        break;

    }

  

    var availableTextLength:Number = maxLength - (link.length + 1);

    if (text1.length > availableTextLength) {

        text1 = text1.substr(0, (availableTextLength - 3)) + '...';

    }  

    switch (site) {

        case "facebook":

        siteURL = "http://www.facebook.com/share.php?u=" + encodeURIComponent(link) + "&t=" + encodeURIComponent(text1);

        break;

    }

  

    var urlRequest:URLRequest = new URLRequest(siteURL);

    navigateToURL(urlRequest, "_blank");

}

This topic has been closed for replies.

1 reply

sinious
Legend
August 26, 2013

This isn't really a Flash question but here's an example on SO that's probably best usage IMHO:

http://stackoverflow.com/questions/6952807/facebook-share-with-dynamic-text

The URL decoded structure in that answer for clarity is:

http://www.facebook.com/sharer/sharer.php?s=100&p[title]=Title&p[summary]=Test Summary.&p[url]=http://www.ideocentro.com/&p[images][0]=https://static.e-junkie.com/sslpic/64332.ed95f53b41bc4885dd86e2b485f08a3b.jpg

That points to a specific image and such so be sure to replace relevant content with your own. Click on the link in the answer to see what the user will see.

Consult the Facebook API for more information on share links.

SirMarleyAuthor
Inspiring
August 27, 2013

yup but that would be to change the php file, what I am trying to do is to set it up in actionscript....isnt it possible?

sinious
Legend
August 27, 2013

No php involved here, please read the answer.