Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-11-2004, 08:17 PM   #1
holtzy
Are we there yet...
 
holtzy's Avatar
 
Join Date: Jan 2003
Location: USA
Posts: 201
Talking Automate button press

I have an html page with both a flash movie and an html form included. Is there any possible way to automate pressing a button on the html form when the user clicks a button in the flash movie? Thanks!
__________________
God is Good.
holtzy is offline   Reply With Quote
Old 05-12-2004, 08:46 AM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
Default

Howdy...

I know pretty much zippo about the HTML but here is an idea...
When you create the HTML form, have the submit button execute some JavaScript function as you do with the form validation stuff, and remember what that JavaScript function name is...
And, when you have to emulate the clicking on the button, maybe you could run that JavaScript function via getURL() call from the Flash???
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-12-2004, 09:26 AM   #3
holtzy
Are we there yet...
 
holtzy's Avatar
 
Join Date: Jan 2003
Location: USA
Posts: 201
Talking

Sounds like that just might work. You mean have it setup something like this...
Code:
<SCRIPT language="JavaScript">
function submitform()
{
  document.myform.submit();
}
</SCRIPT>
Then from Flash call the submitform() funtion via getURL, right? I'll give it a shot. Thanks!
__________________
God is Good.
holtzy is offline   Reply With Quote
Old 05-13-2004, 08:45 AM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
Default

Hm... Sounds like I might actually have said something useful... Let me know how it goes and what the exact command was...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-13-2004, 10:39 AM   #5
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,048
Default

what???!!! you mean to say that outta 8973+ posts, this is the first usefull thing you've said??? i'm gonna havfta add you to my ignore list now.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 05-13-2004, 11:14 AM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
Default

Shhhhhh... That's supposed to be one of the secrets in the AS.org...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-13-2004, 08:12 PM   #7
holtzy
Are we there yet...
 
holtzy's Avatar
 
Join Date: Jan 2003
Location: USA
Posts: 201
Default

Ok, evidently I have to use a specific way to upload a file for security reasons. So now I am simply try to detect when the upload button has been pressed. There has to be a simple way to do this. I know when the button is pressed that it is given the value "Upload", so if I can check for this value somehow then I can do it. I found something about
Code:
If Request.Form("submit") = "Upload" then
but i'm not sure if this works in PHP, cause i think this code i found is ASP. Here is the excerpt of code in my php/html page
Code:
<form method=POST action=do_upload.php enctype=multipart/form-data>
<p>Upload Picture:<br>
<input type=file name=img1 size=30><br>
<input type="submit" name="submit" value="Upload"> 
<p><font color=red>(This could take a couple minutes depending on the size of your picture)</font>
<input type=hidden name=VehicleID value="<?php echo $VehicleID ?>">
</form>

I guess I need to know how to refer to the button on the form so i can check for it's value.

If Request.Form("submit") = "Upload" then
     echo "testing";
end if
I guess I need to know how to refer to the form button so i can check it's value cause i can't get Request.Form to work...
__________________
God is Good.

Last edited by holtzy; 05-13-2004 at 08:14 PM..
holtzy is offline   Reply With Quote
Old 05-13-2004, 08:26 PM   #8
petefs
Fried Onions
 
petefs's Avatar
 
Join Date: Apr 2004
Location: Chicago, IL
Posts: 1,328
Send a message via AIM to petefs Send a message via MSN to petefs Send a message via Yahoo to petefs
Default

I've developed a WYSIWYG flash backend for a client's flash site, and what you're doing is possible certainly : )

Is this a file upload? If so, you're going to be restricted to internet explorer only. Mozilla/Netscape, and presumably other browsers (not tested) consider using the javascript element click() method to trigger an upload "Browse" button a security problem. Here's the script from that site:

index.html:

HTML Code:
<html>
<head>
<title>MyClient Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<frameset cols="100%,0" frameborder="NO" border="0" framespacing="0"> 
  <frame name="main" scrolling="AUTO" noresize src="flash.php">
  <frame name="controller" scrolling="NO" noresize src="upload.php">
</frameset>
<noframes><body bgcolor="#FFFFFF" text="#000000">

</body></noframes>
</html>
upload.php:

PHP Code:
<?php
header
("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0"false);
header("Pragma: no-cache");

if(isset(
$_POST['fileup'])==true) {
  require(
"hft_uploader.php");
  require(
"hft_image.php");
  require(
"class.cropcanvas.php");
  
$filenames=array();
  foreach(
$HTTP_POST_FILES as $key=>$value)
  {
    if(
$HTTP_POST_FILES[$key]['tmp_name']!="")
    {
      
$uploader = new hft_uploader($key"../images""image/jpeg image/pjpeg"1000000108);
      
$filename time().rand(1,10).$uploader->original_name;
      
$filenames[] = array($key$filename);
      if(
$uploader->store_upload($filename))
      {
        
$original_image "../images/".$filename;
        switch(
$key)
        {
          case (
"itemFullUF"):
          case (
"diningItemFullUF"):
            
$width 320;
            
$height 240;
            break;
          case (
"catTnUF"):
          case (
"diningItemTnUF"):
            
$width 80;
            
$height 60;
            break;
          default:
            
$width 64;
            
$height 48;
        }
        
$image = new hft_image($original_image);
        
$image->resize($width$height'+');
        
$image->output_resized($original_image"JPEG");
        
$cc = new canvasCrop();
        
$cc->loadImage($original_image);
        
$cc->cropToSize($width,$height,ccCENTRE);
        
$cc->saveImage($original_image);
        
chmod("../images/".$filename0644);
      }
    }
  }
}
?>
<html>
<head>
<title>Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE=JavaScript>
<!--

function upit(fld)
{
  var upObj = eval("document.forms.upload."+fld);
  upObj.click()
  while(upObj.value == "")
  {
    setTimeout(100)
  }
  upControl(fld)
}

function submitIt(){
    document.upload.submit()
}

function upControl()
{
  var obj=parent.main.admin;
  var re = new RegExp("\\\\", "g");
  for (var i=0; i<document.upload.elements.length; i++)
  {
    if(document.upload.elements[i].type=="file" && document.upload.elements[i].value!="")
    {
      var fileval = document.upload.elements[i].value;
      var retSt = fileval.replace(re, "/");
      if (obj) eval('obj.SetVariable("_root."+document.upload.elements[i].name, "' + retSt + '")');
    }
  }
}
<?php
if(count($filenames)>0) {
?>
  var obj=parent.main.admin;
<?
  
foreach($filenames as $key=>$value)
  {
  
?>
  if (obj) eval('obj.SetVariable("_root.<?php echo $filenames[$key][0]; ?>", "<?php echo $filenames[$key][1]; ?>")');
  <?php
  
}
?>
if (obj) eval('obj.SetVariable("_root.UF", "<?php echo $filenames[0][0]; ?>")');
window.location="bounce.php";
<?php
}
?>
//-->
</SCRIPT>
</head>

<body bgcolor="#000000" text="#FFFFFF">
<form name="upload" enctype="multipart/form-data" method="post" action="uploader.php">
  <input type="file" name="catTnUF">
  <input type="file" name="itemTnUF">
  <input type="file" name="itemFullUF">
  <input type="file" name="diningItemTnUF">
  <input type="file" name="diningItemFullUF">
  <input type="hidden" name="fileup" value="yes">
  <input type="submit" value="Submit it">
</form>
</body>
</html>
bounce.php

PHP Code:
<?php
header
("Location: http://www.hostfs.net/lubahati.com/admin/uploader.php");
exit;
?>
flash.php:

HTML Code:
<html>
<head>
<SCRIPT LANGUAGE=JavaScript>
<!--
function upit(fld)
{
  var upObj = eval("parent.controller.document.forms.upload."+fld);
	upObj.click()
	while(upObj.value == "")
  {
    setTimeout(100)
  }
  parent.controller.upControl()
}

function submitIt(){
	parent.controller.document.upload.submit()
}
//-->
</SCRIPT>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#0d155e">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="800" height="650" id="admin" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="admin.swf?<?php echo time(); ?>" />
<param name="quality" value="high" />
<param name="bgcolor" value="#0d155e" />
<embed src="admin.swf?<?php echo time(); ?>" quality="high" bgcolor="#0d155e" width="800" height="650" name="admin" align="middle" swliveconnect=true allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</embed>
</object>
</body>
</html>
Now obviously this is a little more complicated than it should be, but that's because it's meant to handle a variety of different fields smartly from flash. Also the bounce is not necessary, but I use it to make sure if the client uses the 'refresh' button on their browser or hits F5 it doesn't:
A) nag them with the 're-post form data' confirmation
B) re-post the form data!

If you have any problems slimming that code down, or have problems with the flash side, let me know : ) I may be a while, I just got busy and I'm going to be away for the weekend, but that's the general idea!
petefs is offline   Reply With Quote
Old 05-13-2004, 08:56 PM   #9
holtzy
Are we there yet...
 
holtzy's Avatar
 
Join Date: Jan 2003
Location: USA
Posts: 201
Default

Thanks for the info and the sample code, but I'm afraid I can't limit myself to just IE. There has to be a way to detect simply when the button is pressed...doesn't there?
__________________
God is Good.
holtzy is offline   Reply With Quote
Old 05-13-2004, 09:50 PM   #10
petefs
Fried Onions
 
petefs's Avatar
 
Join Date: Apr 2004
Location: Chicago, IL
Posts: 1,328
Send a message via AIM to petefs Send a message via MSN to petefs Send a message via Yahoo to petefs
Default

you can submit the form in any browser, but you cannot click the 'browse' button. mozilla/netscape consider that a security issue so it isn't supported. I'm thinking of trying to write a div layer with document.write and have that div layer positioned on top of the flash file, then you can actually click the button, but I'm not sure the div layer will display over the flash object -- has anybody tried this?
petefs is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:14 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.