|
Add to paypal shopping cart
/* This is an add to paypal cart function. * Created by isaac.levy@gmail.com * donations are welcome. * via paypal to isaac.levy@gmail.com */ function AddToPaypalCart(){ var paypalObj = new Object(); paypalObj["add"] = 1; paypalObj.cmd = "_cart"; paypalObj.business = "mjmspeedwayspares@bigpond.com.au"; //replace with your business name paypalObj.item_name="MJM Speedway Spares"; //replace with your item name. paypalObj.amount="1000.00"; //replace with the price paypalObj.page_style="Primary"; paypalObj.no_shipping="2"; paypalObj.cn="Comment"; paypalObj.currency_code="AUD"; var sUrl = "https://www.paypal.com/cgi-bin/webscr?" for (var o in paypalObj) sUrl += o + "=" + paypalObj[o] + "&"; trace(sUrl); getURL(sUrl,"_cart","POST"); } createEmptyMovieClip("myButton",50) myButton.createTextField("bText",0,0,0,100,100) myButton.bText.text = "Add to Basket"; myButton.onPress = function(){ AddToPaypalCart(); } Posted by: Isaac Levy | website http://www.actionscript.org |
// Short and Unreadable - but it works!
// Inspired by blue
Number.prototype.addZeros = function(p) {
return (new Array(p).join('0') + this).substr((new Array(p).join('0') + this).length - p);
}
// Usage:
points = 20000;
trace(points.addZeros(10));
Posted by: Matthias Kannengiesser | website http://www.flashstar.de |
// Simply paste this text to the first frame of the root
mouseControl = false;// if it's true you can control the MC by mouse
if (mouseControl) {// try to follow the cursor
this.getPosition = function (){
this.whereX = _xmouse;
this.whereY = _ymouse;
}
this.intv = 20;
} else {// move MC randomly
this.getPosition = function (){
this.whereX = ( Math.random()*(right-left+1) )+left;
this.whereY = ( Math.random()*(bottom-top+1) )+top;
}
this.intv = 450;
}
setInterval( this, "getPosition", this.intv );
function atCrsLoaded () { // sets the properties
advance = 0.15; // between 0.01 and 0.20
rotate = 5;
left = 0; // def. affected area
top = 0;
right = 500;
bottom = 500;
radius = 4;
circleColor = [ 0xF0F028, 0xF5D36D ]; // colors
this.createEmptyMovieClip("bg", ++_global.depth);
with (this.bg){ // draw a rectangle for BG
lineStyle (0.5, circleColor, 0);
beginFill (0x000000) ;
moveTo( left, top );
lineTo( right, top);
lineTo( right, bottom);
lineTo( left, bottom);
lineTo( left, top);
endFill();
}
this.createEmptyMovieClip("cursor0", ++_global.depth);
with (this.cursor0){ // draw a circle
alphas = [ 100, 78 ];
ratios = [ 0, 0xFF ];
matrix = { a:radius*2, b:0, c:0, d:0, e:radius*2, f:0, g:10, h:0, i:0 };
lineStyle (0.5, circleColor, 0);
beginGradientFill ( "radial", circleColor, alphas, ratios, matrix ) ;
moveTo( 0, -radius );
curveTo( radius, -radius, radius, 0 );
curveTo( radius, radius, 0, radius );
curveTo( -radius, radius, -radius, 0 );
curveTo( -radius, -radius, 0, -radius );
endFill();
_visible = false;
}
this["cursor0"].follow = function () {
if ( (this._x + (whereX-this._x)*advance>left) and (this._x + (whereX-this._x)*advance<right) ) {
this._x += (whereX-this._x)*advance;
}
if ( ( left<this._x ) and ( this._x<right ) ){
this._x += (whereX-this._x)/100;
}
if ( (this._y + (whereY-this._y)*advance>top) and (this._y + (whereY-this._y)*advance<bottom) ) {
this._y += (whereY-this._y)*advance;
}
if ( (top<this._y) and (this._y<bottom) ) {
this._y += (whereY-this._y)/100;
}
this._rotation += rotate;
}
setInterval( this["cursor0"], "follow", 40 );
for (var i = 20; i>=1; i--) {
duplicateMovieClip("cursor0", "cursor"+i, ++_global.depth);
this["cursor"+i].number = i;
this["cursor"+i]._parent = this;
with (this["cursor"+i]){
_alpha = 100/(.5*i)+3;
_width = i*5;
_height = i*12;
lineStyle (1, 0xFFCC99, 50);
moveTo( 0, -1 );
curveTo( 8, -1, 10, 0 );
curveTo( 8, 1, 0, 1 );
curveTo( -8, 1, -10, 0 );
curveTo( -8, -1, 0, -1 );
}
}
for (var j = 1; j<=20; j++) {
this["cursor"+j].setPosition = function () {
this._y += ( this._parent["cursor"+(this.number-1)]._y-this._y )*advance*5;
this._x += ( this._parent["cursor"+(this.number-1)]._x-this._x )*advance*5;
this._rotation = ( this._parent["cursor"+(this.number-1)]._rotation+1 )
}
setInterval( this["cursor"+j], "setPosition", 40 );
}
this["cursor1"].swapDepths(++_global.depth);
this["cursor0"].swapDepths(++_global.depth);
}
this.onLoad = atCrsLoaded ();
Posted by: Giruna | website http://uimre.fw.hu |
/* AllShoppingCart ** Actionscript 2.0 Class - AllSolutions Internet & Multimedia - www.allsolutions.cl /* Francisco Claude Faust - Enero 2004 / Original Class For PHP 4.x Francisco Aranda Leiva - Octubre 2005 / Adaptation for Actionscript 2.0; faranda@allsolutions.cl */ /*USAGE: * INICIALIZATION * Import the Class and initiate it // See references of importing and using classes in flash * import ShoppingCartClassEn.as * var carr:ShoppingCartClassEn = new ShoppingCartClassEn(0); * FUNCTIONS: * carr.add_item(ID,qty); // add_item a item to de ShoppingCart * carr.qty(ID); // Gives the defined item Quantity * carr.empty_cart(); // empty_cart the ShoppingCart * carr.del_item(ID); // del_itemete an item * carr.mod_item(ID,qty); // mod_itemify an item * carr.save_cart(); // save the ShoppingCart * carr.MyToString(); // Gives an array |itemID:qty| of allitems in the ShoppingCart */ class ShoppingCartClassEn { var items = new Array; var qtyes = new Array; var curr : Number = 0; var max : Number = 0; var str : String = ""; function ShoppingCartClassEn (string) { max = 1; curr = 0; if (string == 0) { string = ""; } else { var i : Number var arr : Array arr = string.split ("|"); var esp : Array; for (i = 0; i < arr.length; i ++) { esp = arr [i].split (":"); if (esp.length == 2) { add_item (esp [0] , esp [1]); } } } } public function add_item(item : Number, qty : Number) { if (curr == 0) { curr = 1; } if (qtyes [item] > 0) { qtyes [item] += qty; } else { items [max] = item; qtyes [item] = qty; max ++; } return 1; } public function MyToString () { str = ""; var i : Number; if (curr == 0) { return str; } for (i = 1; i < max; i ++) { str += items [i] + ":" + qtyes [items [i]] + "|"; } return str; } public function save_cart () { str = MyToString (); return str; } public function del_item (item : Number) { if (curr == 0) { return 1; } var i : Number; var j : Number; for (i = 1; i <= max; i ++) { if (items [i] == item) { qtyes [items [i]] = - 1; for (j = i; j <= items.length - 1; j ++) items [j] = items [j + 1]; if (max == curr) curr --; max --; break; } } return 1; } public function qty (item : Number) { return (((qtyes [item] > 0)) ?qtyes [item] : 0); } public function mod_item (item : Number, qty : Number) { if (qtyes [item] > 0) { return (qtyes [item] = qty); } else { return add_item (item, qty); } } public function empty_cart () { qtyes = ""; items = ""; save_cart (); } } Posted by: Francisco Aranda Leiva | website http://www.allsolutions.cl |
/*This is a Pong game, made entirely with flash's drawing API...
You simply need to make a new movie with a black background.
You can use any framerate you wish, it will still be fluid.
Please leave this copyright note :)
API - Driven PONG by TrashLock
(c)May 2004
*/
Mouse.hide();
//get widht and height of the stage
w = Stage.width;
h = Stage.height;
//set the initial variables
ball_speed = -1.2;
ball_y = 0;
max_speed = 4;
enemy_score_one = 0;
player_score_one = 0;
//this is to determine the virtual framerate, should be 120 or something
fps = 120;
interval = Math.round(1000/fps);
//initiate the playing area (it's just a line, and it requires 7 lines of coding!)
function createArea() {
_root.createEmptyMovieClip("area", 0);
with (_root.area) {
moveTo(w/2, 0);
lineStyle(5, 0xFFFFFF, 80);
lineTo(w/2, h+10);
}
}
//Create those little textboxes
function textBoxes(new_score_p, new_score_e) {
_root.createTextField("player_score", 1, 20, 10, 40, 40);
_root.createTextField("enemy_score", 2, w-60, 10, 40, 40);
score_style = new TextFormat();
score_style.font = "Verdana";
score_style.size = 20;
score_style.bold = true;
score_style.color = 0xFFFFFF;
score_style.align = "center";
player_score.selectable = false;
player_score.text = new_score_p;
player_score.setTextFormat(score_style);
enemy_score.text = new_score_e;
enemy_score.selectable = false;
enemy_score.setTextFormat(score_style);
}
//This is the function to create a player
function createPlayer(instancename, depth) {
_root.createEmptyMovieClip(instancename, depth);
with (_root[instancename]) {
moveTo(0, 0);
beginFill(0xFFFFFF, 100);
lineStyle(0, 0xFFFFFF, 0);
lineTo(10, 0);
lineTo(10, 50);
lineTo(0, 50);
lineTo(0, 0);
}
}
//this one's a bit hard, because it creates a ball
//rather than a square
function createBall() {
_root.createEmptyMovieClip("ball", 5);
with (_root.ball) {
moveTo(0, 0);
lineStyle(0, 0xFFFFFF, 0);
beginFill(0xFFFFFF, 100);
curveTo(0, -5, 5, -5);
curveTo(10, -5, 10, 0);
curveTo(10, 5, 5, 5);
curveTo(0, 5, 0, 0);
}
}
//initiate ball position
function int_stuff() {
_root.ball._x = w/2-5;
_root.ball._y = h/2-5;
_root.enemy._x = w-30;
_root.enemy._y = h/2-30;
}
//show a "click to play" text...or any message.
//doesn't this function rock? ^_^
function click_2_play(message) {
_root.createTextField("click2play", 10, 0, 20, w, 200);
with (_root.click2play) {
text = message;
selectable = false;
setTextFormat(score_style);
}
}
//create a BIG button over the entire stage so we have something to click
function createBigButton() {
_root.createEmptyMovieClip("big_button", 20);
with (_root.big_button) {
beginFill(0x000000, 0);
moveTo(0, 0);
lineTo(w, 0);
lineTo(w, h);
lineTo(0, h);
lineTo(0, 0);
}
}
//execute our onload functions
_root.onLoad=createArea(), createBall(), textBoxes(player_score_one, enemy_score_one), createPlayer("player", 3), createPlayer("enemy", 4), int_stuff(), click_2_play("Click Anywhere To Play"), createBigButton();
//is the big button pressed?
_root.big_button.onPress = function() {
playing = true;
click_2_play("");
};
//control player
function controlPlayer() {
if (playing) {
_root.player._x = 20;
_root.player._y = _root._ymouse-25;
}
updateAfterEvent();
}
//ok, let's do some funky things with the ball.
function moveBall() {
if (playing) {
_root.ball._y += ball_y;
if (_root.ball._y<=0 || _root.ball._y+10>=h) {
ball_y *= -1;
}
_root.ball._x += ball_speed;
if (_root.ball.hitTest(_root.enemy) || _root.ball.hitTest(_root.player)) {
if (ball_speed<max_speed && ball_speed>-max_speed) {
ball_speed *= -1.5;
} else {
ball_speed *= -1;
}
}
if (_root.ball.hitTest(_root.enemy)) {
ball_y = ((_root.ball._y)-(_root.enemy._y+25))*0.2;
}
if (_root.ball.hitTest(_root.player)) {
ball_y = ((_root.ball._y)-(_root.player._y+25))*0.2;
}
//any points scored?
//The enemy has scored
if (_root.ball._x+10<=0) {
enemy_score_one += 1;
click_2_play("Enemy scored. Click to continue.");
textBoxes(player_score_one, enemy_score_one);
playing = false;
_root.ball._x = w/2-5;
_root.ball._y = h/2-5;
ball_y = 0;
ball_speed = 1.2;
}
//The player has scored
if (_root.ball._x>w) {
player_score_one += 1;
click_2_play("You scored! Click to continue.");
textBoxes(player_score_one, enemy_score_one);
playing = false;
_root.ball._x = w/2-5;
_root.ball._y = h/2-5;
_root.ball_speed = -1.2;
ball_y = 0;
}
}
updateAfterEvent();
}
//let's make some AI, shall we?
function enemyMove() {
if (playing) {
stupidity = 7;
//okay, so if the ball is on his side, follow it...
if (_root.ball._x+10>=w/2) {
_root.enemy._y += (_root.ball._y-(_root.enemy._y+25))/stupidity;
}
}
updateAfterEvent();
}
//And at last execute our code
setInterval(moveBall, interval);
setInterval(controlPlayer, interval);
setInterval(enemyMove, interval);
Posted by: TrashLock | website http://www.locklegion.com |

