function isValidEmail(email:String):Boolean
{
var emailExpression:RegExp = /([a-z0-9._-]+?)@([a-z0-9.-]+)\.([a-z]{2,4})/i;
return emailExpression.test(email);
}
import com.adobe.images.JPGEncoder;
function createJPG(mc:MovieClip, n:Number, fileName:String) {
var jpgSource:BitmapData = new BitmapData (mc.width, mc.height);
jpgSource.draw(mc);
var jpgEncoder:JPGEncoder = new JPGEncoder(n);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
//Make sure to use the correct path to jpg_encoder_download.php
var jpgURLRequest:URLRequest = new URLRequest ("download.php?name=" + fileName + ".jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
var loader:URLLoader = new URLLoader();
navigateToURL(jpgURLRequest, "_blank");
}
//createJPG(movieClip, quality, fileName);
createJPG(myMovieClip, 90, "myDog");
///////////////////////////////////////////////////////////////
//This is an Example of the Server-side that will return the JPEG
///////////////////////////////////////////////////////////////
/*
<?php
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
// get bytearray
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
// add headers for download dialog-box
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $im;
} else echo 'An error occured.';
?>
*/