View Full Version : form in layer send var to flash
spacether
09-22-2002, 09:10 PM
I have a form in a layer in my html page:
<div id="Layer1" style="position:absolute; left:132px; top:59px; width:418px; height:58px; z-index:1">
<form name="form1" enctype="multipart/form-data" method="post" action="">
<input type="file" name="myfile" size="45">
</form>
</div>
I want to send the variable myfile to flash.
In my flash movie, I put:
loadVariablesNum("page.html", 0, "POST");
page.html is in the same folder as the flash movie, and contains the form and the flash movie.
The text box in the flash movie that should be loading form var myfile is, type input, its instancename is pathbox, and its var name is myfile
I have tried switching input types to get and post, and have tried changing the textbox type to dynamic, but it still didn't work.
Does anyone know how to make it work? I read the tutorials on passing from forms.
spacether
09-23-2002, 11:13 PM
please, any help you can give is appreciated
Mattarm
09-24-2002, 03:04 AM
I think I get what you are trying to do.
HTML form on page.
flash file on same page.
Have variable in flash form passed to flash file.
Is this correct?
If so you will need to pass the variable from the HTML with javascript.
There was a tute i worked through once on this problem that allowed me to talk to flash files in different frames. The coe could be examined and used as a basis for this type of communication. I'll try to track it down tonight on my other PC.
Cheers,
Matt
spacether
09-24-2002, 06:53 AM
thats exactly what im trying to do, thank you very much:)
spacether
09-25-2002, 02:35 AM
I found out how to do it. I can now browse for any mp3 on my hd, select it, load it into the flash movie and play it. For posterity and anyone who wants the source, here it is:
This is accomplished in 3 sections of code:
WEBPAGE: FILE BROWSING FORM
On the webpage which the flash is on there is a html form which lets the user browse his or her comp for files, in this case mp3s. This can be anywhere in the page, a cell, a layer or just in the normal page. This should be placed in the <body> of the webpage:
<form name="form1" enctype="multipart/form-data" method="post" action="">
<input type="file" name="myfile" size="45" onChange="doPassVar(this)">
</form>
WEBPAGE: JAVASCRIPT FUNCTION
Next there is the javascript function which sends the file path to the flashmovie. This should be placed in the webpage <head>:
<SCRIPT LANGUAGE=JavaScript>
<!--
function doPassVar(args){
var myfile = args.value;
window.document.flashmovie.SetVariable("path", myfile);
window.document.flashmovie.Play();
}
//-->
</SCRIPT>
*Comment: the file's path will be sent to flash as a variable called path. The javascript function plays your movie, moving it foreward, so our next line of code loading the mp3 will be in the second frame of the flash movie. This assumes that the movie starts out stopped and on frame 1.
FLASH SCRIPTS
Flash Frame 2 Script:
Place this script on any layer in the second frame:
_root.song = new Sound();
_root.song.loadSound(_root.path, false);
_root.song.onLoad = function(success) {
gotoAndStop(1);
};
Frame 1:
You can put in a play button and on press or release:
_root.song.start(0,0);
spacether
09-25-2002, 03:13 AM
1 more part, in the flash EMBED tag, you need to add: swliveconnect=true
<EMBED src="movie.swf" quality=high salign=LT wmode=transparent bgcolor=#FFFFFF WIDTH="590" HEIGHT="390" swliveconnect=true
-----------------------------------------------------------
Try my MP3 player ------->HERE (http://www.syntonik.com/justin/mp3player.html)
-----------------------------------------------------------
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.