Hi all,
im having this Problem for a long time now,
i just have to know how to do this…
im sure its not that hard…
i checkd my ‘Bible’ :hugegrin: “Wiley - Action Script 3.0 Bible”
a very helpfull book, a long one too…
but still didnt find what i was looking for…
im sure its in there somewhere…
so…
saving inside a swf…for simple and short data,
like several lines of text and some numbers.
its posible in as2. cant get myself to see how i do it in as3…
of even beter, using php to save a txt file (XML perhaps) into the flash swf file folder on the server that is stored on…to be read by the flash file again later…
this one kills me even more…
any way…searching for a solution ive acomlished saving files from flash to the users hard drive using php…
i never used php before and i asked a friend to “find” me a code for that…
so here is what i have so far… an image downloader…
not very helpfull but shows that it can be done somehow…
i think the trick is to change the php to save it in the server folder and not in the
users hard drive…
no idea how to do that
stop();
/*
THIS CODE IF FOR DOWNLOADING sketch_mc THAT IS ON THE MAIN TIMELINE.
IN ADITION TO THAT CODE THERE IS A CODE TO PUT ON THE PAGE (PHP CODE).
/////////////////////////////////////////////////////////////////////
///////////////////////////THE PHP CODE//////////////////////////////
/////////////////////////////////////////////////////////////////////
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
// get bytearray
$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
// add headers for download dialog-box
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $jpg;
}
/////////////////////////////////////////////////////////////////////
/////////////////////////END OF CODE/////////////////////////////////
/////////////////////////////////////////////////////////////////////
*/
/*
///////////////////////////////////////////////////
HERE IS THE START OF IMAGES LOADER TO sketch_mc !!
///////////////////////////////////////////////////
*/
var imageLoader:Loader;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest("IMAGE.xml"));
/////
function loadXML(e:Event):void {
var xml=new XML(e.target.data);
var xDoc:XMLDocument = new XMLDocument();
xDoc.ignoreWhite=true;
xDoc.parseXML(xml.toXMLString());
loadImage(xDoc.firstChild.childNodes[0].firstChild);
trace(xDoc.firstChild.childNodes[0].firstChild);
}
function loadImage([url:String):void](http://www.kirupa.com/forum/String):void) {
// Set properties on my Loader object
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
function imageLoaded(e:Event):void {
sketch_mc.addChild(imageLoader);
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
import com.adobe.images.JPGEncoder;
dwn_mc.addEventListener(MouseEvent.MOUSE_DOWN,downloadThis);
function downloadThis (arg:MouseEvent){
var jpgSource:BitmapData = new BitmapData (sketch_mc.width, sketch_mc.height);
jpgSource.draw(sketch_mc);
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("jpg_encoder_download.php?name=sketch.jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "_blank");
}
so if any body has some links or any kind of help i will be very grateful…
thanks stas…