Solved

Flash variable to javascript URGENT!!!!!!

Posted on 2011-03-03
6
187 Views
Last Modified: 2012-05-11
I'm using this to send my flash variables to javascript:

signup_btn.onRelease = function()
{
	my_vars = new LoadVars();
	my_vars.username = pogu_username_1.text;
	my_vars.pword = pogu_pword_1.text;
	my_vars.gname = pogu_gname_1.text;
	my_vars.lname = pogu_lname_1.text;
	my_vars.gender = pogu_gender_1.text;
	my_vars.contactno = pogu_contactno_1.text;
	my_vars.email = pogu_email_1.text;
	my_vars.dob = pogu_dob_1.text;
	my_vars.addres = pogu_address_1.text;
	my_vars.difficulties = pogu_message_1.text;
	
	
	getURL ("Javascript:submitregdata('my_vars')");
	
	//trace(my_vars);
};

Open in new window


However my javascript function is returning the variables as undefined. Any ideas?
0
Comment
Question by:brettacvh
  • 4
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
ID: 35033602
I use ExternalInterface rather than getURL.

http://www.actionscript.org/resources/articles/638/1/Basics-of-using-the-ExternalInterface/Page1.html

Looks like this to call myJavascriptFunction from FLASH:
:
flash.external.ExternalInterface.call("myJavascriptFunction", arg1, arg2);

Open in new window

0
 

Author Comment

by:brettacvh
ID: 35033639
Is that relevant for AS2?
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35033653
Absolutely.  I'm still stuck back in the dark ages with AS2 myself.  :)
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
LVL 16

Assisted Solution

by:sjklein42
sjklein42 earned 500 total points
ID: 35033654
You need to include this header line:

import flash.external.ExternalInterface

Open in new window

0
 

Author Comment

by:brettacvh
ID: 35033672
Actually what seems to be working now is with  the '+' concatenation:

signup_btn.onRelease = function()
{
	my_vars = new LoadVars();
	my_vars.username = pogu_username_1.text;
	my_vars.pword = pogu_pword_1.text;
	my_vars.gname = pogu_gname_1.text;
	my_vars.lname = pogu_lname_1.text;
	my_vars.gender = pogu_gender_1.text;
	my_vars.contactno = pogu_contactno_1.text;
	my_vars.email = pogu_email_1.text;
	my_vars.dob = pogu_dob_1.text;
	my_vars.addres = pogu_address_1.text;
	my_vars.difficutlies = pogu_difficulties_1.text;





	getURL("Javascript:submitregdata('" + my_vars.username + "','" + my_vars.pword + "','" + my_vars.gname + "','" + my_vars.lname + "','" + my_vars.gender + "','" + my_vars.contactno + "','" + my_vars.email + "','" + my_vars.dob + "','" + my_vars.addres + "','" + my_vars.difficutlies + "')");

//trace(my_vars.difficutlies);
};

Open in new window

0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35033712
What does the code for the Javascript function look like?  (The function we are calling)

We need to make the arguments on the FLASH side match the Javascript.  We may need to adjust code on both the FLASH and the Javascript to make it work easily.  Are you able to change the Javascript, or is that code already done?

Please post (at least) the Javascript source code for the submitregdata function so I can see it.

Thank you.
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sorting a string 1 30
Angular service to share objects between controllers 1 15
jQuery - following an example but can I save data server side? 20 50
JavaScript let vs var 5 26
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question