Solved

Flash variable to javascript URGENT!!!!!!

Posted on 2011-03-03
6
188 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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…

840 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