Second experiment with floodFill and tolerance
improve algorithm (sssspeeeeddddd)
Monday, September 11, 2006
New security model - Flash 9
Flash 9 Player introduce a new security model, the basic concepts are:
- Resources in the same security sandbox (local or network) can always access each other .
- Resources in a remote sandbox can never access local resources
Now the flash player checks for "exact domain" so:
http://a.com
http://www.a.com
http://www.a.b.com
https://www.a.com
are different sandbox.
You can bypass the sandbox using cross domain xml and Security.allowDomain() method
source:
http://www.adobe.com/devnet/flashplayer/articles/flash_player_9_security.pdf
- Resources in the same security sandbox (local or network) can always access each other .
- Resources in a remote sandbox can never access local resources
Now the flash player checks for "exact domain" so:
http://a.com
http://www.a.com
http://www.a.b.com
https://www.a.com
are different sandbox.
You can bypass the sandbox using cross domain xml and Security.allowDomain() method
source:
http://www.adobe.com/devnet/flashplayer/articles/flash_player_9_security.pdf
Thursday, September 07, 2006
CreaAvatar - Make your Avatar with Flash
After 2 months of work, finally is online
creaAvatar
With this application you can create your avatar and then generate the image file (jpeg).
creaAvatar
With this application you can create your avatar and then generate the image file (jpeg).
Flash + Ajax Fjax
Fjax puts a Flash engine to handle realtime XML/HTML content loading, instead using XMLHttpRequest.
Tuesday, August 22, 2006
Upload File AS3 PHP
Example for upload file with As3.
- Open a new document with Flash 9 and assign as document class [your package].Example
- Create in your package the file Example.as and add this code:
package com.duemas.leonardo{
import flash.display.MovieClip;
import flash.events.*;
import com.duemas.leonardo.io.FileManager;
public class Example extends MovieClip{
public const IMPORT_IMAGE:String="importImage";
private var fileManager:FileManager;
public function Example(){
createInstance();
registerListeners();
startApp()
}
private function createInstance(){
fileManager =new FileManager();
}
private function registerListeners(){
this.addEventListener(IMPORT_IMAGE,fileManager.importImage);
fileManager.addEventListener(fileManager.ON_IMPORT_IMAGE,onImport);
}
private function onImport(ev:Event):void{
var f:FileManager=FileManager(ev.target);
var img_uploaded:String=f.lastFileSelect;
trace("image uploaded: "+img_uploaded);
}
private function startApp(){
var e =new Event(IMPORT_IMAGE);
dispatchEvent(e);
}
}
} - Create in your package the file FileManager.as and add this code:
package com.duemas.leonardo.io
{
import flash.events.*;
import flash.net.*;
import com.duemas.leonardo.constant.Constant;
import flash.events.*
public class FileManager
{
public const ON_IMPORT_IMAGE:String="OnImportImage";
private var f:FileReference;
public var lastFileSelect:String;
private var imagesFilter:FileFilter;
public function FileManager()
{
super();
imagesFilter= new FileFilter("Images", "*.jpg;*.gif;*.png")
}
public function importImage(ev:Event){
f=new FileReference();
f.addEventListener(Event.SELECT,onFileSelect);
f.addEventListener(IOErrorEvent.IO_ERROR,errorFile);
f.addEventListener(Event.COMPLETE, uploadComplete);
f.browse([imagesFilter])
}
private function errorFile(e:IOErrorEvent){
trace("error "+e.toString())
}
private function uploadComplete(e:Event){
lastFileSelect=f.name;
var ev:Event=new Event(ON_IMPORT_IMAGE);
dispatchEvent(ev);
}
private function onFileSelect(e:Event):void{
var file:FileReference = FileReference(e.target);
trace("selectHandler: " + file.name );
var uploadUrl:URLRequest = new URLRequest();
uploadUrl.url = Constant.SERVER_URL+Constant.PHP_URL+Constant.UPLOAD_URL;
file.upload(uploadUrl)
}
}
} - Create in your package the file Constant.as and add this code:
package com.duemas.leonardo.constant
{
public class Constant
{
public static const SERVER_URL:String="http://localhost/leonardo/";
public static const PHP_URL:String="php/";
public static const UPLOAD_URL:String="upload.php";
public static const IMAGE_FOLDER:String="img/";
}
} - Create in path SERVER_URL + PHP_URL the file upload.php open and close php tags and add this code:
$destination_dir = '../img/';
if(
isset($_FILES['Filedata']) &&
is_array($_FILES['Filedata']) &&
isset(
$_FILES['Filedata']['tmp_name'],
$_FILES['Filedata']['name'],
$_FILES['Filedata']['size'],
$_FILES['Filedata']['error']
) &&
intVal($_FILES['Filedata']['error']) === 0
) {
if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $destination_dir.$_FILES['Filedata']['name'])) {
$result = "
Date: ".date('Y-m-d H:i:s')."
File: {$_FILES['Filedata']['name']}
Size: {$_FILES['Filedata']['size']}
Successfull uploaded.
";
}
else {
$result = "
Date: ".date('Y-m-d H:i:s')."
File: {$_FILES['Filedata']['name']}
Size: {$_FILES['Filedata']['size']}
Error: {$_FILES['Filedata']['error']}
Unable to move file.
";
}
if(@$fp = fopen($destination_dir.'upload.txt', 'w')) {
fwrite($fp, $result);
fclose($fp);
}
}
Load and Display with as3
Forget loadMovie, now for load image u use Loader class
package{
import flash.display.*;
import flash.events.*;
import flash.net.URLRequest;
public class Example extends Sprite {
function Example(){loadImage("bdog.jpg");}
public function loadImage(u:String){
var _loader:Loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
var request:URLRequest = new URLRequest(u);
_loader.load(request);
addChild(_loader);
}
private function onComplete(ev:Event):void{
var loader:LoaderInfo = LoaderInfo(ev.target);
}
}
}
How waste your time - Compiling AS3
I waste a lot of time with a compiling error:
Error #1046: Type was not found or was not a compile-time constant: DataManager.
private var dm:DataManager;
With the new virtual machine u must declare public the class!!!
public class DataManager extends UIObject
Error #1046: Type was not found or was not a compile-time constant: DataManager.
private var dm:DataManager;
With the new virtual machine u must declare public the class!!!
public class DataManager extends UIObject
Subscribe to:
Posts (Atom)