Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transfering variables from html form to flash

Status
Not open for further replies.

leearach2004

Technical User
Dec 8, 2005
86
GB
Hi there hope somone can help this is realy frustrating me now

I am trying to transfer some text from a html form to a flash movie text area, i havent done thi sbefor ebut i have seen loads of examples on the net and they all say they work but i cant get them 2

my flash file has a:

dynamic text area with the var set to myVar

the code fork the html is below


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns=" xml:lang="en" lang="en">
<head>

<SCRIPT LANGUAGE=JavaScript>
<!--
function doPassVar(args){
var sendText = args.value;
window.document.myFlash.SetVariable("myVar", sendText);
}
//-->
</SCRIPT>



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>javascript_to_flash</title>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<p>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" width="550" height="400" id="myFlash" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="javascript_to_flash.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="javascript_to_flash.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="myFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage=" swLiveConnect="true"/>
</object>
</p>
<form name="form1" id="form1" method="post" action="">
<input type="text" name="sendText" maxlength="45" onChange="doPassVar(this)">
</form>
<p>&nbsp;</p>
</body>
</html>


acording to all the tutorials i have read this should run fine. It doesnt through any errors but after typing into the form text box nothing showsup in the flash files as it is surposed to

hope somone can help me its driving me mad

lee
 
I know this is dumb but I have to ask. . .you have defintely embedded the textfield correct?
 
Hi there thanks for the reply

I have embed the flash movie correctly but what do you mean by embeded the text textfield correctly, its me being dumb not you this is the first time I have tried this

hope you can help

lee
 
If you click on your dynamic textbox on the stage, you will see a button, on the properties panel, that says "Embed. . ." - if you click on that you have the option to embed characters. For dynamic text this is somehting you must do to make sure the font data is exported with the swf. So select you basic latin characters, numerals and punctuation. . .then hit "ok" .

See if this works.
 
hi there first off did you run the html page locally from your c: dive thats what i am doing till i copy it to cd

in my flash file i just have a dynamic text area wich has the var tag set to myVar to display the information from the javascript

hope you can help

lee
 
hi there maybee it was to do with the clicking somwere else on the screen but when i do that i get an error

it says

window.dodcument.myFlash is null or not an object

at least it does somthing now you hgave any idea how to fix this error

proberbly me being stupid i know

hope to here from you soon

lee
 
hi i have no idea whats up it just does nothing when i run it, have i set my flash file right i just added a text field using the text dra tool and then set the type to dynamic and the the var property to myVar have i missed anything

lee
 
Add this alert to the Javascript:
[tt]
function doPassVar(args){
alert(window.document.myFlash);
var sendText = args.value;
window.document.myFlash.SetVariable("myVar", sendText);
}
[/tt]
What do you get?

Kenneth Kawamoto
 
hi there thanks for the reply

I added the alert to my javascript

It opens a alert box after i add some text and click of the area the alert box say......

[object]

and click ok

so i did and nothing happens still

lee
 
You didnt reply, but I guess you check and saw that your textbox was embedded?
 
hi kmobayeni

sorry didnt reply got a few people talking to on same thread applogies i have check the box but cant see anything about embeding it in any option if you could help

lee
 
hi there thanks for the reply i have embed my text now but that didnt fix the problem unfortunatly. kenethkawamoto said he used my web code i posted and it weorked fine for him the only diffrence was he created his own flash file so he thought that i may me my flash thats rong

i have added a dynamic text area using the text tool and added the myVar variable to the var field and thats is supoised to be it but maybee ive missed somthing i dont know as this is the first time i have done this function

can u help

lee
 
Hi there kenthkawamoto did you get my reply to your question response you posted to me i did what you said see above for my answer

hope you can help

lee
 
> It opens a alert box after i add some text and click of the area the alert box say......
>
> [object]

Ok it tells me that the browser has created the Flash object. (And also you're using IE.)

When you run this do you get the error icon on the bottom left corner of the browser? If you click on that what does it say?

Better still, do you have Firefox? If not get it now.

Kenneth Kawamoto
 
hi there thanks for getting back

first off there is no error when i run this even when i cilck ok there is no error

second i need this to run in IE as that is the browser the users all have

i just cant understand why it works for u and not me im think my flash file is o.k its just a dynamic text area create with the text tool and has a var field contaning myVar thats all i need isnt it, should have added any actionscript

hope you can help

lee
 
The reason I said to get Firefox was that Firefox has Javascript debug console, which IE hasn't. So if you can, get it now and run your thing, then open the JS console to see if there are any error messages.

As for Flash file you can try this:

1. Create a new Flash document
2. In the frame 1 of the main timeline type in this code:
[tt]
var myVar:String = "";
this.createTextField("tf", 1, 10, 10, 100, 20);
with (tf) {
border = true;
}
var watchFunction:Function = function (prop, oldVal, newVal, uData):String {
tf.text = newVal;
return newVal;
};
this.watch("myVar", watchFunction);
stop();
[/tt]
3. Create a SWF and name it "javascript_to_flash.swf"

Basically it's the same as creating a TextField and setting the Var to "myVar" manually, but just done in pure ActionScript way. I know this SWF works so just to eliminate the possibility of your SWF is being the culprit.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top