AlivePDF download and save to server

Today I found myself needing to implement AlivePDF into a project that needs to generate a PDF, save it on the server and download it to the user’s computer.

Since I didn’t find any information about how to do this (and I found some other people trying to find out how it’s done) I thought I should give it a try. I posted the final result below if someone else needs to know how to both save the PDF file on the server and download it to the user’s computer.

ActionScript 3 AlivePDF code:

_pdf.save(Method.REMOTE, "save.php", Download.ATTACHMENT, "MyFile.pdf");

PHP code that will save the file on the server (inside a specified folder) and save it to the user’s computer too:

<?php
 
if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){
	$pdf = $GLOBALS["HTTP_RAW_POST_DATA"];
	$name = $_GET["name"];
	$save_to = "pdf/". $name;
	file_put_contents($save_to, $pdf);
 
	// add headers for download dialog-box
	header('Content-Type: application/pdf');
	header('Content-Length: '.strlen($pdf));
	header('Content-disposition:'.$method.'; filename="'.$name.'"');
	echo $pdf;
 
} else{
	echo "Encoded PDF information not received.";
}
?>
Convert values within a range to values within another range

Today I’m sharing with you a little utility that I find myself using a lot lately. This utility is a value convertor that you can use in those times when you need to make a volume slider or something similar where you’ll need to change a value and a value range.

package com.vamapaull.utils
{	
	public class ValueConvertor
	{
		public static function convertRange(originalStart:Number, 
							originalEnd:Number, 
							newStart:Number, 
							newEnd:Number, 
							value:Number):Number
		{
			var originalRange:Number = originalEnd - originalStart;
			var newRange:Number = newEnd - newStart;
			var ratio:Number = newRange / originalRange;
			var newValue:Number = value * ratio;
			var finalValue:Number = newValue + newStart;
			return finalValue;
		}
	}
}
Control a Flash Game with your iPhone

Some programmers from Germany developed a great Flash game that uses your iPhone/iPod Touch to control the game actions.

The concept is very interesting and I could see this being applied on lots of old-school arcade games that are ported to Flash.

After learning about WebSockets we were eager to build a website around this technology. As we are a bunch of oldschool nerds it was obvious to transform the iPhone into a gamepad controlling a Flash Website.

Source: WeekendContent.com

This is amazing! 3D Flash Game with P2P Multiplayer

I have to say, a Multiplayer 3D Game running in Flash Player is really exciting!
The future of gaming will change from now on. Take a look and tell me what you think ;)

Interesting videos from MAX 2010

I have found some very interesting videos from MAX 2010 and I want to share them with you, I believe you’ll love the new stuff as I do! :D

Video Tapestries:

Read more
Odd or Even number in ActionScript

I was making a project for a client of mine where I had to make a list with two different colors for the items (like the iTunes list) so I started to think of a possible way to make this. It was clear enough I need to know the odd or the even number in order to do that. So I started to do some google search and I got over this blogpost by Keith Peters. I have to say, this is a very interesting way of thinking :D

iseven = ((num & 1) == 0)

Makes sense when you look at binary numbers:

001 = 1
010 = 2
011 = 3
100 = 4
101 = 5

Each of the odd numbers has a 1 in the far right column. The even numbers have 0 there. Mask it with “& 1″ and you can see which it is.

So I made a for loop and used this code. It works exactly how it was intended to work!!
Thanks Keith Peters for your blogpost :D