Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 698049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:13:56+00:00 2026-05-14T03:13:56+00:00

Summary I want to be able to call a JavaScript function from a Flex

  • 0

Summary
I want to be able to call a JavaScript function from a Flex app using ExternalInterface and pass a reference to a different JavaScript function as an argument.

Base Example
Given the following JavaScript:

function foo(callback)
{
    // ... do some stuff
    callback();
}

function bar()
{
    // do some stuff that should happen after a call to foo
}

I want to call foo from my flex app using ExternalInterface and pass a reference to bar as the callback.

Why
Really,foo is not my function (but, rather, FB.Connect.showBookmarkDialog), which due to restrictions on Facebook iframe apps can only be called on a button click. My button, for design reasons, is in the Flex app. Fortunately, it’s possible to call ExternalInterface.call("FB.Connect.showBookmarkDialog", callback) to display the bookmark dialog. But, FB.Connect.showBookmarkDialog requires a JS callback so, should I want to receive a callback (which I do), I need to pass a reference to a JS function as the single argument.

Real Example

MXML:

<mx:Button click="showBookmarkDialog();" />

ActionScript:

function showBookmarkDialog() : void
{
    ExternalInterface.registerCallback(
        "onBookmarkDialogClosed", 
        onBookmarkDialogClosed
    );
    ExternalInterface.call(
        "FB.Connect.showBookmarkDialog", 
        /* ref to JS function onBookmarkDialogClosed ? */
    );
}

function onBookmarkDialogClosed(success:Boolean) : void
{
    // sweet, we made it back
}

JavaScript:

function onBookmarkDialogClosed()
{
    var success;
    // determine value of success
    getSWF().onBookmarkDialogClosed(success);
}

Failed Experiments
I have tried…

ExternalInterface.call(
    "FB.Connect.showBookmarkDialog", 
    "onBookmarkDialogClosed"
);

ExternalInterface.call(
    "FB.Connect.showBookmarkDialog", 
    onBookmarkDialogClosed
);

ExternalInterface.call(
    "FB.Connect.showBookmarkDialog",
    function() : void
    {
        ExternalInterface.call("onBookmarkDialogClosed");
    }
);

ExternalInterface.call(
    "FB.Connect.showBookmarkDialog",
    function()
    {
        this["onBookmarkDialogClosed"]();
    }
);

Of note:

  1. Passing a string as the argument to an ExternalInterface call results in FB’s JS basically trying to do `”onBookmarkDialogClosed”()` which, needless to say, will not work.
  2. Passing a function as the argument results in a function object on the other side (confirmable with `typeof`), but it seems to be an empty function; namely, `function Function() {}`
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:13:57+00:00Added an answer on May 14, 2026 at 3:13 am

    As always, one need only ask a question for the answer to be revealed…

    Solution

    ExternalInterface.call("FB.Connect.showBookmarkDialog(onBookmarkDialogClosed)");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Devexpress 11.2 In a XtraGridView I want to show Summary SUM
Summary: I want to be able to run a query against an external database
SUMMARY: I have created a SSRS Report. I want to be able to supply
I want to be able to read vCard and vCalendar data using .NET, I
I want to be able to pass in a list of parameters, and ignore
I want to use a RedirectToRouteResult to redirect to a url like /users/4#Summary. Using
I want to be able to grab keys/values from a cookie and use that
Summary: I want a horizontal row of ImageButtons to scale down evenly to fit
Summary: I want to display a value (in a text box) stored in another
Summary: I want the prettiness of Silverlight/WPF in part of my current Winforms application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.