|
-
Combining flash and html form variables possible ?
I hope someone can tell me if it's possible to combine flash and html form variables.
For my online gallery I have a php based managing sysem. Information can be edited with a normal html form. I have created a little flash file that can crop, rotate and change colors of an image. It's my goal to integrate it in the form so that when the submit button of the form is pressed both the form variables and the image correction settings are sent. Does anyone have suggestions how (preferably without javascript) to do this ?
Wilbert
-
KoolMoves Moderator
 Originally Posted by w.brants
I hope someone can tell me if it's possible to combine flash and html form variables.
For my online gallery I have a php based managing sysem. Information can be edited with a normal html form. I have created a little flash file that can crop, rotate and change colors of an image. It's my goal to integrate it in the form so that when the submit button of the form is pressed both the form variables and the image correction settings are sent. Does anyone have suggestions how (preferably without javascript) to do this ?
Wilbert
Without resorting to javascript I'd say you'd have to have the flash sending it's data out to a file that your srever script could read. I started a project like this at one time. What we did was pass the editing data to a PHP script that applied them to the actuall image using GD functions. The project fell through and we never completed the testing but it seemed to be working.
-
KoolMoves Moderator
Fankley now that most browsers support WC3 DOM javascript is a viable language.
You should be able to call the javascipt from you flash.
-
 Originally Posted by blanius
What we did was pass the editing data to a PHP script that applied them to the actuall image using GD functions.
That's exactly what I'm doing 
The ColorMatrixFilter is pretty powerful for color corrections and it wasn't that hard to implement in php using the GD functions. All I need is a way to send the matrix and crop rectangle from the swf file to the php file that handles the editing.
I prefer to integrate the swf into my current editing form because I already have all security functions in place. The management system is used by other users as well that's why I hesitate about using javascript. One user for example is a teacher and I don't know if schools or other public places disable javascript for security reasons. If not I might be able to add a function to the submit button to collect the matrix and crop rectangle from the swf file just befor sending out the data to the php file.
-
up to my .as in code
If the swf saved settings (the crop info and all) are not pushed to the html form, and the form simply adds extra info that is collected with whatever your swf is saving as settings, couldn't you have the swf write a cookie that the html form picks up in it's php coding when it posts it's data?
If it wrote the same cookie everytime, the swf data would always be specific to the swf in the holder...and when they load the next...it overwrites the last cookie and would let you combine all the variables in the POST....no?
If you wrote a small php file just for the swf, you could automate the swf to write the whole cookie routine EVERYTIME they edit the swf (crop,rotate,color) so the cookie is sure to be there when the html form posts. If they load a swf and do nothing....have the swf hit it's backside and write default settings on load or something so it has also written the cookies. That way the user does not have to manually hit a SAVE SETTINGS (because since the html form has a submit button we don't want to make them hit SAVE twice in the same form...one html...one swf) button and would negate any loophole by a user forgetting to save the cookie since it's done each time they manipulate the image. When the html form posts....it picks it all up.
I haven't seen a mockup of your routine so this is just a thought without knowing the actual mechanics.
Last edited by Chris_Seahorn; 01-04-2006 at 04:34 PM.
-
KoolMoves Moderator
No one should need to restrict the use of Javascript anymore, the security issues are pretty much long gone. Frankly the whole AJAX revolution would be for naught if browsers commonly didn't allow javascript. This is probably your best and most reliable bet. use onClick for your submit button and run a javascript function that yanks the data out of the swf.
Last edited by blanius; 01-04-2006 at 05:50 PM.
-
KoolMoves Moderator
-
up to my .as in code
Does anyone have suggestions how (preferably without javascript) to do this
http://sandbox.blogdns.com/wilbert1.php
I'm on a local server and it might not work for you guys but this:
Lets you put as many variables into your html form you want.....anything.......and browse for a file to upload (or code it to choose a filename from a dir)
and submit it.....write a master php file (you've seen me do this...we write a brand new php file)...and if the file type matched your backside filter (currently set for a small size JPG) it will place the image is whatever directory you decide and load a Koolmoves file in that reads the master php....variables, image and all. Then you can apply your new cropping code and all....and send everything out with one pop from Koolmoves (html form variables and all).
Granted this is in reverse of what you are doing...but is a routine from one of my old interfaces and am being lazy. I suppose I could code it in the other direction if I had a cup of coffee or two 
It works here fine.
This way you....initiate the html for the teacher....they fill in your form and choose the picture to edit....it gets sent to your Koolmoves editor with all POST variables (if it meets the criteria as setup in wilbert1.php).....they save the edit and the swf POSTS everything you want out and reloads the form.
Last edited by Chris_Seahorn; 01-04-2006 at 08:40 PM.
-
KoolMoves Moderator
Woah <shakes head>
Chris you lost me, but I bet Wilburt can follow you. (I've seen his AS code)
-
up to my .as in code
It's just the way I'm explaining it. Maybe:
1. User initiates html form...fills out info wilbert is asking for in the form fields.
2. User "browses" for image.
3. On submit, the first backside php checks:
a. file is of right type (extension filter inside backend)
b. is below MAXSIZE (defined in backside)
4. If all is good...the next stage kicks in and the first php grabs the image...puts it in a folder (decided in backside) and creates a php file with all the form data, the image name...and image path.
5. It automatically loads the swf into the page it was in to replace itself.
6. The Fun file (wilberts image editor) loads all the form data and loads the image for editing by reading the php file the first stage created.
7. Once image editing is done and wilberts color info and all have been declared as variables, he can save it all from there to a final php that either enters it in a database or whatever.
8. SWF reloads the form ready for next entry in the page it was just in. A constant rotation.
It sounds more complicated than it is...and hopefully you can use the demo to see (just pick a small size JPG under 200k). It works here locally and I've used tons of backside trickery like this in the past.
-
Bret and Chris,
Thanks a lot for your suggestions.
I can follow you Chris (I think ). The multi step you suggest was my first thought. The problem with it is that it would take me more time to implement (I'm a bit lazy also sometimes). Cookies would be fine if knew how to set one. As far as I know a swf file can only set a LSO cookie or maybe a normal one when using javascript but in that case it may just be as easy to collect the info on submit. Do you know how to process a LSO with php ?
If it is most likely javascript isn't disabled I first am going to try that since it's the fastest way for me to implement. I'll keep you guys posted on the progress.
Wilbert
-
up to my .as in code
Well...i see you mention javascript and html and php so I assume a server. If so, you don't want an LSO, you want an old fashioned set of http cookies. If you were making a flash 8 application that was all flash (if you need the internal uploads for better integration) I would say hell yeah to the LSO. We as admins have shied away from http cookies as users delete them but one for you...where your users won't do that...it's perfect. It would add maybe 10 lines of php code that you have your editor swf pop EVERYTIME a change is made. Flawless. When your html form POSTS...you won't have the extra coding of the second method I posted because the php file for the form can decode the cookie when it does it's thing (shown below).
Have that editor hit a tiny php something like this:
Code:
$hexcolor = $_POST["color"];
$matrixyoffset = $_POST["myy"];
$matrixxoffset = $_POST["mxx"];
$expiryDate = mktime(0, 0, 0, 12, 25, 2030); //you set it bro
setcookie('hexcolor' , $hexcolor, $expiryDate);
setcookie('matrixx', $matrixxoffset, $expiryDate);
setcookie('matrixy', $matrixyoffset, $expiryDate);
and insert a few of these in the html forms php section when it grabs the other post variables and processes them and go nuts:
Code:
$hexcolor= $_COOKIE["hexcolor"];
$matrixxoffset= $_COOKIE["matrixx"];
$matrixyoffset= $_COOKIE["matrixy"];
Only the editor can write the cookie so only the users who use it will create it. It overwrites itself as many times as you will ever need and would be a sweet routine. If you need to blank the cookies...write empty values.This way adds no coding or new fields or visual changes to the frontend of your existing html form and only a couple of lines to it's php section. You already planned on sending out values from the swf so that small php file you create (once) to write the values should take a guy like you about 10 seconds to code.
You can even have the html forms php section write blank cookies after it decodes and processes the last cookie read in one shot.
Last edited by Chris_Seahorn; 01-05-2006 at 02:51 AM.
-
I finally got it to work.
Most times I try not to use cookies only session variables so I first wanted to try another approach. After experimenting some with ExternalInterface (I couldn't get it to work with a swf inside a form) I went back to the easiest solution I could think of and that worked fine. I used a hidden field in my html form and an onRollOut event for a background mc in my swf movie. Each time the onRollOut event occurs, it uses getUrl with one line of javascript to update the hidden field. To press the submit button they have to move away from the swf so the hidden field gets updated in time.
-
Brilliant and simple
I have a very similar problem in these days. Need to send swf vars along with the HTML FORM ones to the php page that comes next (it's a profile creation page where the flash bit plays the role of allow people to create a cartoon personalized char). The HTML form takes care of normal boring data, the swf of cosmetics. Now everything has to be done in just one page. I find your solution of the rollOut dirty but brilliant mate. Have been thinking of complex JS (I don't even know JS that much), SharedObjects but this one...seems really good to me. Could solve my problem as well.
Would you be so kind to post the JS line u used to change the value of the hidden field of the HTML form please?
Cheers
Last edited by svedish72; 12-07-2006 at 03:08 PM.
Reason: typo
-
In my case this is the code I used
Code:
bg.onRollOut = function(){
s = _root.img._rotation + '|' + _root.crop + '|' + _root.matrix.toString();
getUrl('javascript:void(document.forms[0].imgtrans.value="'+s+'")');
}
My background mc is named bg.
s is the string that is made up of the combined values of the variables I need to pass.
The javascript call references the first form on the html page with a hidden field named imgtrans.
-
Is it crossbrowser compatible?
Hi there,
have been testing several things (im my app I need to send variables back and forth and it's really a headache). I tested your approach to actually get variables INTO the swf from the html page (the current URL of the hosting page) and it seems to work fine, BUT I still got loads of problems with Firefox and obv. Netscape.
I know in this thread the point is getting the variables of an swf AND the ones into a form get sent at the same time, but still, I think this is important.
Did you try your code in these browsers and, most important, does it work for you? Cheers
Last edited by svedish72; 12-09-2006 at 01:14 PM.
-
My code works for me in both IE and FireFox.
I have an online galery that is php/MySQL based. The swf is used by the admin interface to crop and rotate an image and to change the brightness, contrast etc of it. Once the user sends the form data, both the edited information and the correction parameters that were set using the swf are send. The php script behind it changes the info in the database and changes the image based upon the parameters set by the swf file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|