LAZIOMATICA – Guida allo Sviluppo Software

La nuova forma del software su misura…

 

From at Web 09

Dopo 2 anni di assenza torna l’evento Adobe più atteso dagli sviluppatori web,  il 26 e 28 Maggio 2009 a Milano e Roma. Visita il sito http://www.fromatoweb.it per ulteriori informazioni.

Filed under : Actionscript 2,Actionscript 3,AIR,Eventi,Flash CS4,RIA
By admin
On 8 maggio 2009
At 06:47
Comments : 0
 
 

Shared Object in Flash Lite per gestire il seriale di un’applicazione

Sezione per il check  dell’autorizzazione:

function loadCompletePrefs (mySO:SharedObject) {

if (0 == mySO.getSize() ) // non è presente l’oggetto nel dispositivo
{
trace(“NO SHARED FOUND”)
// Se size è uguale a 0, è necessario inizializzare i dati:
gotoAndStop(“serial”) // salto alla sezione per impostare i dati..in questo caso l’inserimento del seriale

}
else
{
//mySO.clear();
// Traccia tutti i dati in mySO:
trace(“SHARED FOUND”)
trace( “Prefs:” );
for (var idx in mySO.data) {
trace( ” ” + idx +”: ” + mySO.data[idx] );
if (idx==”md5″) if( mySO.data[idx]==md5)
{
trace(“Autenticazione OK”)
// continua con elaborazione filmato da utente autenticato o autorizzato
}
else trace (“Autenticazione failed”)

}
}
}

// Istanziamo  l’oggetto condiviso:

var Prefs:SharedObject = SharedObject.getLocal(“Prefs”);

SharedObject.addListener( “Prefs”, loadCompletePrefs );

Sezione di scrittura dello SharedObject:

function saveSeriale (mySO:SharedObject) {
mySO.data.name = “Infodemo”;
mySO.data.email = “info@laziomatica.com”;
mySO.data.serial1 = sn01;
mySO.data.serial2 = sn02;
mySO.data.serial3 = sn03;
mySO.data.md5 = md5v;
mySO.flush();
var flushResult = mySO.flush(); // qui salviamo l’oggetto
switch (flushResult) {
case ‘pending’ :
md5.text += “pending”;
break;
case true :
md5.text += “Data was flushed.”;
break;
case false :
md5.text += “Test failed. Data was not flushed.”;
break;
}

}

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
var keyCodev = Key.getCode();
if (keyCodev == ExtendedKey.SOFT2) {

if (key1.text==sn01 && key2.text==sn02 && key3.text==sn03)
{
md5.text=”OK CHECK”;
_focusRect = false;
//gestiamo lo shared object appena finito il suo recupero…che in questo caso è immediato poichè non esiste

Prefs = SharedObject.getLocal(“Prefs”);

SharedObject.addListener( “Prefs”, saveSeriale );
}
else  md5.text=”NO CHECK”;

}

}

};

// gestore di eventi tastiera
Key.addListener(keyListener);

Questo è tutto.

Filed under : Actionscript 2,Flash CS3,Flash CS4,Flash Lite,MOBILE
By admin
On 28 gennaio 2009
At 13:40
Comments : 0
 
 

Implementing Encryption in AS2 and AS3

download Libreria flashcrypt

Use for MD5:

import be.boulevart.as2.security.Encryption;
import be.boulevart.as2.security.EncryptionTypes;
var e:Encryption;
e = new Encryption(EncryptionTypes.MD5(), “123244″ , null, null, null, null);
e.calculate();

trace(“String after MD5 calculation: ” + e.getInput() + “\n”);

Full original AS3 example:

package be.boulevart.as3 {
/**
* Encodes and decodes a base64 string.
* @authors Sven Dens – http://www.svendens.com
* @version 0.1
*
* Original Javascript implementation:
* Aardwulf Systems, www.aardwulf.com
* See: http://www.aardwulf.com/tutor/base64/base64.html
*/
import flash.display.MovieClip;
import be.boulevart.as3.security.Encryption;
import be.boulevart.as3.security.EncryptionTypes;

public class as3_cryptdemo extends MovieClip {

protected var e:Encryption;
protected var theKey:String = “you’ll never guess”;
protected var str:String = “My super secret string”;

public function as3_cryptdemo()
{
trace(”String before encryption: ” + str + “\n”);

//RC4 encryption
e = new Encryption(EncryptionTypes.RC4(), str , this.theKey, null, null, null);
e.encrypt();
trace(”String after RC4 encryption: ” + e.getInput());
e.decrypt();
trace(”String after RC4 decryption: ” + e.getInput() + “\n”);

//Base8 encryption
e = new Encryption(EncryptionTypes.Base8(), str , null, null, null, null);
e.encode();
trace(”String after Base8 encoding: ” + e.getInput());
e.decode();
trace(”String after Base8 decoding: ” + e.getInput() + “\n”);

//Base64 encryption
e = new Encryption(EncryptionTypes.Base64(), str , null, null, null, null);
e.encode();
trace(”String after Base64 encoding: ” + e.getInput());
e.decode();
trace(”String after Base64 decoding: ” + e.getInput() + “\n”);

//Goauld calculation
e = new Encryption(EncryptionTypes.Goauld(), str , null, null, null, null);
e.calculate();
trace(”String after Goauld calculation: ” + e.getInput() + “\n”);

//MD5 calculation
e = new Encryption(EncryptionTypes.MD5(), str , null, null, null, null);
e.calculate();
trace(”String after MD5 calculation: ” + e.getInput() + “\n”);

//ROT13 calculation
e = new Encryption(EncryptionTypes.ROT13(), str , null, null, null, null);
e.calculate();
trace(”String after ROT13 calculation: ” + e.getInput() + “\n”);

//SHA1 calculation
e = new Encryption(EncryptionTypes.SHA1(), str , null, null, null, null);
e.calculate();
trace(”String after SHA1 calculation: ” + e.getInput() + “\n”);

//LZW compression
/*e = new Encryption(EncryptionTypes.LZW(), str , null, null, null, null);
e.compress();
trace(”String after LZW compression: ” + e.getInput());
e.decompress();
trace(”String after LZW decompression: ” + e.getInput() + “\n”);*/

//TEA encryption
e = new Encryption(EncryptionTypes.TEA(), str , this.theKey, null, null, null);
e.encrypt();
trace(”String after TEA encryption: ” + e.getInput());
e.decrypt();
trace(”String after TEA decryption: ” + e.getInput() + “\n”);

//Rijndael encryption
e = new Encryption(EncryptionTypes.Rijndael(), str , this.theKey, “CBC”, 256, 256);
e.encryptRijndael();
trace(”String after Rijndael encryption: ” + e.getInput());
e.decryptRijndael();
trace(”String after Rijndael decryption: ” + e.getInput() + “\n”);
}
}
}

Full original AS2 example:

import be.boulevart.as2.security.Encryption;
import be.boulevart.as2.security.EncryptionTypes;

class be.boulevart.as2.as2_cryptdemo extends MovieClip
{
private var e:Encryption;
private var theKey:String = “you’ll never guess”;
private var str:String = “My super secret string”;

public function as2_cryptdemo()
{
trace(”String before encryption: ” + str + “\n”);

//RC4 encryption
e = new Encryption(EncryptionTypes.RC4(), str , this.theKey, null, null, null);
e.encrypt();
trace(”String after RC4 encryption: ” + e.getInput());
e.decrypt();
trace(”String after RC4 decryption: ” + e.getInput() + “\n”);

//Base8 encryption
e = new Encryption(EncryptionTypes.Base8(), str , null, null, null, null);
e.encode();
trace(”String after Base8 encoding: ” + e.getInput());
e.decode();
trace(”String after Base8 decoding: ” + e.getInput() + “\n”);

//Base64 encryption
e = new Encryption(EncryptionTypes.Base64(), str , null, null, null, null);
e.encode();
trace(”String after Base64 encoding: ” + e.getInput());
e.decode();
trace(”String after Base64 decoding: ” + e.getInput() + “\n”);

//Goauld calculation
e = new Encryption(EncryptionTypes.Goauld(), str , null, null, null, null);
e.calculate();
trace(”String after Goauld calculation: ” + e.getInput() + “\n”);

//MD5 calculation
e = new Encryption(EncryptionTypes.MD5(), str , null, null, null, null);
e.calculate();
trace(”String after MD5 calculation: ” + e.getInput() + “\n”);

//ROT13 calculation
e = new Encryption(EncryptionTypes.ROT13(), str , null, null, null, null);
e.calculate();
trace(”String after ROT13 calculation: ” + e.getInput() + “\n”);

//SHA1 calculation
e = new Encryption(EncryptionTypes.SHA1(), str , null, null, null, null);
e.calculate();
trace(”String after SHA1 calculation: ” + e.getInput() + “\n”);

//LZW compression
e = new Encryption(EncryptionTypes.LZW(), str , null, null, null, null);
e.compress();
trace(”String after LZW compression: ” + e.getInput());
e.decompress();
trace(”String after LZW decompression: ” + e.getInput() + “\n”);

//TEA encryption
e = new Encryption(EncryptionTypes.TEA(), str , this.theKey, null, null, null);
e.encrypt();
trace(”String after TEA encryption: ” + e.getInput());
e.decrypt();
trace(”String after TEA decryption: ” + e.getInput() + “\n”);

//Rijndael encryption
e = new Encryption(EncryptionTypes.Rijndael(), str , this.theKey, “CBC”, 256, 256);
e.encryptRijndael();
trace(”String after Rijndael encryption: ” + e.getInput());
e.decryptRijndael();
trace(”String after Rijndael decryption: ” + e.getInput() + “\n”);
}
}

Filed under : Actionscript 2,Actionscript 3,Flash CS3,Flash CS4
By admin
On 27 gennaio 2009
At 10:41
Comments : 0
 
 

Using Flex Webservice component in Flash CS4

One of the most common requests for the Flash team is to provide a Webservice component for Actionscript 3.0 like the one Flash has for Actionscript 2.0. Finally, Flash has provided the features in CS4 to allow users to use any Flex components that does not rely on Flex framework such as Flex WebService component and HTTPService.

In the below example am going to demonstrate how users can use Flex WebService in Flash to get countries names and populate them in a Flash DataGrid component.

1. File > New
2. Select “Flash File (Actionscript 3.0)”.
3. Open the Component panel and drag a DataGrid component to the stage and call it “dg”.
5. File > Publish settings and click on “Flash” tab.

6. Click on “Settings” button to launch “Advance Actionscript 3.0 Settings”

7. Click on the “library path” tab

8. Click on “Browse to SWC file” icon and get the “framwork.swc” and “rpc.swc” from the Flex SDK as follow :

You can download FlexSDK and select the above SWC’s from the following location
“sdks/3.0.0/frameworks/libs/”

9. Open the action panel and import the following:

import mx.rpc.soap.*;
import mx.core.*;
import mx.rpc.events.*;
import fl.data.DataProvider;
10. The following 2 lines of code are required if you are using SDK 3.0.0 but not if you are using higher version of SDK

//The following 2 lines to register class for
//Interface”mx.interface::IResourceManager

var resourceManagerImpl:Object = ApplicationDomain.currentDomain.getDefinition(“mx.resources::ResourceManagerImpl”);
Singleton.registerClass(“mx.resources::IResourceManager”, Class(resourceManagerImpl));

11. Now copy the following and paste below the above 2 line of codes

var foo:WebService = new WebService();

foo.addEventListener(“load”, finishedLoading);

foo.loadWSDL(“http://www.webservicex.net/country.asmx?WSDL”);

var myOperation:Operation;

function finishedLoading(evt:LoadEvent):void
{
myOperation = Operation(foo.getOperation(“GetCountries”));
myOperation.addEventListener(“fault”, wsdlFault);
myOperation.addEventListener(“result”, wsdlResult);
myOperation.send();
}

function wsdlFault(evt:FaultEvent):void
{
trace(evt.fault);
}

function wsdlResult(evt:ResultEvent):void
{
trace(evt.result);

var myResult:Object = evt.result;
var len:Number = myResult.length;
var xml:XML = XML(evt.result);
var dp:DataProvider = new DataProvider(xml);
dg.dataProvider = dp;

}

12. Test Movie and you should get a list of all the countries inside the datagrid :

original link

Filed under : Actionscript 2,Actionscript 3,Flash CS4
By admin
On
At 09:14
Comments : 0
 
 

Flash lite packager for Symbian S60 3rd Edition Platform

SWF2Go Professional enables you to create rich, powerful and engaging Flash Lite applications rapidly by combining the power of Python for S60 and Net60. Making professional class deployment packages is now one-click operation with new redesigned and friendlier user interface.

www.swf2go.com

Filed under : Actionscript 2,Flash CS3,Flash CS4,Flash Lite,MOBILE
By admin
On 18 gennaio 2009
At 19:36
Comments : 0