How to insert the Share to Facebook button in Flex?

I am trying to duplicate the behavior of the "Share on Facebook" button with Youtube. Basically, inside the Flex application I will have a button, and when I click on it, I want a pop-up window that allows me to publish something on the wall.

While you can make a javascript call to open a popup, I want to be able to set the images and text of my message.

Do you know how I could set images or text as a parameter in the chat window?

Thanks!

+4
source share
3 answers

It is pretty simple. Youtube uses the Facebook API, which opens a new window ( Facebook API Information ).

To do this in flex,

  • Create a button where onClick will call the javascript method, ExternalInterface.call("fbLink", "www.yahoo.com");
  • In your HTML file (most likely index.template.html) add a JavaScript method, fbLink, which does the following:

    fbLink (url) function {window.popup (" http://www.facebook.com/sharer.php?u= " + url, {height: 440, width: 620, scrollbars: true})}

  • Now when the user clicks the button, they will share the link “yahoo.com” with the facebook account.

+1
source

since I realized that you are asking for some help in accessing js popup on the html page of the facebook share button, so you should use ExternalInterface in this casa and access the DOM node using the getElementById function in your js interface.

In another case, I want to suggest you read a different way http://www.riaxe.com/blog/flex/publish-into-facebook-wall-from-flex/

0
source

It seems that you want to have a button on the flash application, and after clicking on it, the facebook page opens, which separates the video / image related to the button pressed. What you want to do is simply create a button that, when clicked, opens a new website in facebook using its api share, which has the following format:

 var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText"; 

If the parameter u denotes the link that you want to share, and the parameter t denotes the name of the part that you want to share, whether it is an image or video.

You want to add an event listener to MouseEvent.CLICK, which has as a callback function a method that handles opening a facebook page that passes the facebookShare variable, as shown above. To open another page in your browser, you can use this AS3 class called URLNavigator: http://www.danishmetal.dk/project/source/com/zorked/URLNavigator.as

To summarize, something like this:

 var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText"; facebookButton.addEventListener(MouseEvent.CLICK, this._goToUrl(facebookShare)); private function _goToUrl(link:String):Function { var window:String = "_blank", feats = "", thisOverlay:Object = this; // to not lose scope when returning a func return function (e:MouseEvent):void { trace("Opening link to:"+link); try { URLNavigator.ChangePage(link, window, feats); } catch (e:Error) { trace("error launching "+link+" in "+window+" with feature set "+feats); } } } 

Hope this helps. If you have questions regarding the code, please let me know.

0
source

All Articles