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

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The answer to your question is to use an extension… May 16, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer There could be problem with easing. You can try to… May 16, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer If I understand correctly I'd just add the lines if(!RuntimeUp… May 16, 2026 at 3:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Background I'm using UKCrashReporter in my app. I've installed my own Uncaught Exception Handler.
Summary: I want to know if it is possible to do something like this:
Summary: I want to take advantage of compiler optimizations and processor instruction sets, but
I have a iframe and want to either get some of the HTML from
I guess I'm not linking something right? I want to call ABC.cpp which needs
I am working on implementing a function that would execute another function a few
Here is a brief summary of my aims. I have a list of data
I am writing an app that requires the user's current location (lastknownlocation won't be
I have a sortable DatagridView with a summary last row containing sum of some
Summary : I need to authorize pages based upon the data present in the

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.