Monday, June 27, 2011

inheritance eample using as3


Inheritance in AS3
  • Inheritance allows you to design a class by deriving it from an existing one. 
  • This feature allows you to reuse existing code without doing copy and paste. 
  • AS3 provides the keyword extends for declaring class inheritance
Example

package com.classes{
public class Person {
var name:String;
}
}
//Base class
package com.classes{
public class Consultant extends Person{
var dailyRate:Number;
}
}

//class derived from base class
package com.classes{
public class Employee extends Person{
var salary:Number;
}
}

Encapsulation in AS3


11:35 AM by selva · 0

Friday, May 20, 2011

Paypal link in flash



For  single product
this.buyNow_btn.onPress = function ()
{
        var paypal_lv = new LoadVars();
        paypal_lv.cmd = "_xclick";
        paypal_lv.business = "user@mail.com"; //emailid
        paypal_lv.item_name = "my product"; //product name
        paypal_lv.amount = "1.00"; // your amount
        paypal_lv.no_shipping = "0"; //shipping amount
        paypal_lv.no_note = "1";
        paypal_lv.currency_code = "USD"; //currency code
        paypal_lv.bn = "PP-BuyNowBF";
        paypal_lv.send("https://www.paypal.com/cgi-bin/webscr", "_blank", "POST");
}};

4:20 AM by selva · 0

Thursday, April 28, 2011

sample post



CODE
//Allow this domain
System.security.allowDomain("http://localhost/");
import flash.net.FileReference;
// The listener object listens for FileReference events.
var listener:Object = new Object();

// When the user selects a file, the onSelect() method is called, and
// passed a reference to the FileReference object.
listener.onSelect = function(selectedFile:FileReference):Void {
  //clean statusArea and details area
  statusArea.text = details.text = ""
  // Flash is attempting to upload the image.
  statusArea.text += "Attempting to upload " + selectedFile.name + "\n";
  // Upload the file to the PHP script on the server.
  selectedFile.upload("upload.php");
};

// the file is starting to upload.
listener.onOpen = function(selectedFile:FileReference):Void {
  statusArea.text += "Uploading " + selectedFile.name + "\n";
};
//Possible file upload errors
listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
    imagePane.contentPath = "error";
    imagePane.content.errorMSG.text = "HTTPError number: "+httpError +"\nFile: "+ file.name;
}

listener.onIOError = function(file:FileReference):Void {
    imagePane.contentPath = "error";
    imagePane.content.errorMSG.text = "IOError: "+ file.name;
}

listener.onSecurityError = function(file:FileReference, errorString:String):Void {
    imagePane.contentPath = "error";
    imagePane.content.errorMSG.text = "SecurityError: "+SecurityError+"\nFile: "+ file.name;   
}

// the file has uploaded
listener.onComplete = function(selectedFile:FileReference):Void {
  // Notify the user that Flash is starting to download the image.
  statusArea.text += "Upload finished.\nNow downloading " + selectedFile.name + " to player\n";
  //Show file details
  details.text = ""
  for(i in selectedFile) details.text +="<b>"+i+":</b> "+selectedFile[i]+"\n"
  // Call the custom downloadImage() function.
  downloadImage(selectedFile.name);
};

var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);

uploadBtn.onPress = uploadImage;
imagePane.addEventListener("complete", imageDownloaded);

// Call the uploadImage() function, opens a file browser dialog.
function uploadImage(event:Object):Void {
  imageFile.browse([{description: "Image Files", extension: "*.jpg;*.gif;*.png"}]);
}

// If the image does not download, the event object's total property
// will equal -1. In that case, display am error message
function imageDownloaded(event:Object):Void {
  if(event.total == -1) {
    imagePane.contentPath = "error";   
  }
}

// show uploaded image in scrollPane
function downloadImage(file:Object):Void {
  imagePane.contentPath =  "./files/" + file;
}

stop()

5:25 AM by selva · 0