Prevent loaded XML caching in ActionScript 3

Method 1:

var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("thefiletoload.xml");
req.method = URLRequestMethod.POST;
req.data = true;
loader.load(req);

Method 2:

var userFilePath:String = "thefiletoload.xml";
if(Capabilities.playerType != "StandAlone" || Capabilities.playerType != "External") {
userFilePath += "?rnd=" + Math.random();
}

Mac OS X XAMPP phpMyAdmin error

If your phpMyAdmin gets you the following error message:

Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.

You can try some of these options:

  • Use a different browser; Firefox consistently gave me the error message, but Safari/Chrome did not.
  • Instead of accessing through http://localhost, try the local IP address of the computer.
  • Run the security on xampp (sudo /Applications/XAMPP/xamppfiles/xampp security

I got this error on my Snow Leopard/XAMPP installation, but not on Lion.

Export SWF to PDF

Here’s some code on how to export an entire image/MovieClip/Sprite to a PDF document, using the AlivePDF library.

private function printAsPDF():void {
            trace("CREATE PDF");
            
            var pdf:PDF = new PDF();
            var page:Page = new Page(Orientation.LANDSCAPE, Unit.MM, Size.A4);
            pdf.addPage(page);
            pdf.setMargins(0, 0, 0, 0);
            pdf.setDisplayMode(Display.REAL, Layout.SINGLE_PAGE, PageMode.USE_NONE, 1.0);
            // this is the image/movie clip container we're saving to the PDF
            var img:Sprite = Sprite(Canvas.getInstance());
            
            var bmpData:BitmapData = new BitmapData(img.width, img.height, true, 0xFFFFFF);
            var matrix:Matrix = new Matrix();
            matrix.createBox(2, 2, 0, 100, 100);
            bmpData.draw(img, matrix, null, null, null, true);
            
            var res:Resize = new Resize(Mode.FIT_TO_PAGE, Position.CENTERED);
            pdf.addImage(img);
            
            var f:FileReference = new FileReference();
            f.save(pdf.save(Method.LOCAL), "min_pdf.pdf");
        }