Solved

Flash variable to javascript URGENT!!!!!!

Posted on 2011-03-03
6
185 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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 use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now