Using 2 parameters, ExternalInterface.addCallback

Attempting to pass 2 variables from JavaScript to Flash, I came up with a solution in ActionScript 3 to try and receive them.

ExternalInterface.addCallback("callAs", muscle, tension);

However, this method resulted in an error:

Error: 1137 - Incorrect number of arguments. Expected no more than 2.

Is there a way to send both variables at once instead of making separate calls each time?

Thank you for your help! Resin

Answer №1

Yes, it can be done.

ExternalInterface.addCallback("functionNameJS", functionNameAS);

function functionNameAS(param1:String, param2:String):void {
//perform actions with param1;
//perform actions with param2;

}

Next, in JavaScript, the code would look like this...

<!-- determine if user is on Mac or PC -->
function getFlashObject(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function functionNameJS(swf, param1, param2) {
    getFlashObject(swf).functionNameAS(param1, param2);
}

To trigger this functionality, you would use something similar to this...

<form action="javascript:functionNameJS('yourSWFid', 'param1value', 'param2value')" id="form">
<input type="submit" value="Click Here" />
</form>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The initial dropdown menu in PHP coupled with Javascript fails to retain my chosen option

As a novice PHP programmer, I successfully created a double drop-down list from a MySQL database. The idea is to choose a claims hub in the first box and then select an attorney associated with that specific hub in the second box. However, I am facing an ...

Unable to access remote video streams by directly modifying URL parameters

Recently, I delved into experimenting with the straightforward mediasoup demo available at: https://github.com/Dirvann/mediasoup-sfu-webrtc-video-rooms After setting up the demo, everything seemed to be functioning correctly. The initial task on my agend ...

My Instagram stream using the Ionic framework's infinite-scroll feature is experiencing issues with repeated duplicates in the repeater

I am currently working on developing a mobile app for IOS and Android using the Ionic Framework. The app will feature an Instagram Feed with the Instagram API, displaying all photos shared under a specific hashtag (for example, #chocolat). I am also lookin ...

In order to use the serve command, it is necessary to run it within an Angular project. However, if a project definition cannot be located

An error occurred while running the ng serve command: C:\Mysystem\Programs\myfwms>ng serve The serve command needs to be executed within an Angular project, but a project definition could not be found. I encounter this error when ...

Iterate through a directory on the local machine and generate elements dynamically

I am looking to create a jQuery-UI tabs menu that includes 54 images on each tab. I have a total of 880 images stored in a folder, and it would be very time-consuming to manually insert an <img> tag for each one. Is there a way to dynamically cycle t ...

When trying to fetch JSON data, the outcome is two pending promises: [ Promise { <pending> }, Promise { <pending> } ]

I am struggling to fetch the JSON data from the API endpoint below: https://api.hatchways.io/assessment/blog/posts When using node.js and making HTTPS requests, I keep getting an array of [ Promise { }, Promise { } ]. The challenge is that I can only se ...

Transform an Axios promise into a standard JSON array

I'm encountering some difficulties with a function that is supposed to return data. The function is intended to return JSON data, but instead, it is returning a promise. Below is the code for the function: import axios from 'axios'; cons ...

Adding items dynamically to a React-Bootstrap accordion component can enhance the user experience and provide a

I am retrieving data from a database and I want to categorize them based on "item_category" and display them in a react-bootstrap accordion. Currently, my code looks like this: <Accordion> { items.map((item, index) => ...

Activating a text field using a checkbox with JavaScript

Could you please provide guidance on how to toggle the editability of a text box based on the selection in a combo box? For instance, if the combo box value is set to 1, the text box should be enabled; if it's set to 0, the text box should be disabled ...

What is the best way to modify a function so that it targets the element that called it?

I utilized the following Bootstrap 4 code to implement a functionality where clicking on a video would play/pause it, and simultaneously toggle a speaker image located below the video. I am looking for a way to refactor this function so that it only impac ...

Hide image URL on mobile devices with CSS and JavaScript

Exploring the realm of cross-device magic, I have a challenge on my hands. My goal is to eliminate a slider image for screen widths smaller than 622px. Through experimentation, I have discovered that removing the image URL in CSS achieves the desired effec ...

Loading images lazily using knockout.js

I have been working on implementing lazy loading for images using knockoutjs binding. I previously successfully implemented lazy loading without the knockoutjs framework, but I am unsure of how to achieve this with knockoutjs binding. Below is my HTML code ...

Change the appearance of text with a button click using JavaScript

Currently mastering JavaScript but encountering an issue. How do I change the text to underline when clicking on "Click Me"? <p id="demo" style=" text-decoration:none; ">Hello JavaScript!</p> <button type="button" onclick="document.getE ...

Is there a way to extend the TTL expiresAfterSeconds duration?

Currently, I am working on a simple application and my model looks like this: import mongoose from "mongoose"; const urlSchema = new mongoose.Schema( { originalUrl: { type: String, required: true }, longUrl: { type: String, required: t ...

Using JQuery, we can add CSS to a DIV if it has a specific height

Can this be achieved? If the DIV inside the page is greater than 600 px, change the background color of #TWO to red Using JQuery I tried implementing this but it's not working correctly: <script type="text/javascript> $(document).ready(funct ...

Alert: Ajax encountered an issue with the auto-refreshing field

When running a script I created for a self-updating field, I encountered the following error message: UpdateField.html:37 Uncaught ReferenceError: fieldname is not defined at HTMLInputElement.onchange (UpdateField.html:37) Script: https://i.sstatic.n ...

Using Vue.js and Laravel, you can effectively display values in a dropdown menu

Trying to display a list of countries in a dropdown menu by fetching data from a database using vue.js in laravel 7. However, the countries are not appearing in the dropdown. Code Snippet: <template> <div class="col-md-6 pull-right"> ...

Troubleshooting React/Jest issues with updating values in Select elements on onChange event

I am currently testing the Select element's value after it has been changed with the following code: it("changes value after selecting another field", () => { doSetupWork(); let field = screen.getByLabelText("MySelectField") ...

Navigating Angular with relative paths: A guide to locating resources

Here is the structure of my app: index.html main.ts app |--main.component.html |--main.component.ts |--app.module.ts |--note.png ... etc I am trying to include the note.png file in main.component.html which is located in the same folder. I have att ...

Tips for updating and transferring a variable within a callback function

I have implemented a function using the SoundCloud API that retrieves a song URL, obtains the associated sound ID from the API, and then passes that ID to a callback for streaming purposes and updating the page. The data is successfully retrieved from the ...