projects & snippets

Multiple ContextMenuItem for different objects

Posted in AS3 optimization, example, projects & snippets on August 11th, 2010 by admin – Be the first to comment

OK here is a simple way to create as many objects as you want context menus:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;


function addContext(sprite_:Sprite):void {
    var menu:ContextMenu = new ContextMenu();
    menu.customItems = [new ContextMenuItem("Select only " + sprite_.name)];
    menu.hideBuiltInItems();
    sprite_.contextMenu = menu;
}

addContext(yellow);
addContext(green);
addContext(red);
addContext(blue);
addContext(this);

note that yellow, green, red, blue are Sprites, but it can be also buttons

Example:

This movie requires Flash Player 10

Nice post about The Right-Click Menu in Flash by Raiyan

SharedObject between 2 movies

Posted in actionscript 3, projects & snippets on January 28th, 2010 by admin – 1 Comment

So lets create 2 files:

setCookies.fla

setCookies.fla flash env with component names

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var date:Date = new Date();
val_ti.text = ">> " +date.time;

setCookie_btn.addEventListener(MouseEvent.CLICK, clickHandler);
show_btn.addEventListener(MouseEvent.CLICK, showHandler);


function clickHandler(info:MouseEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    local_data.data.key = val_ti.text;
    status_txt.text = local_data.flush();
}

function showHandler(info:MouseEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    read_ti.text = local_data.data.key;
}

getCookies.fla

getCookies.fla flash evn with component names

getCookies.fla flash evn with component names

1
2
3
4
5
6
7
8
9
10
11
var timer:Timer = new Timer(500, 0);
timer.addEventListener(TimerEvent.TIMER, checkForCookieHandker);
timer.start();


info_ta.text = "check for cookies every 0.5 sec ... ";
function checkForCookieHandker(info:TimerEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    local_data.flush();
    info_ta.text = "[" + timer.currentCount + "] key: " + local_data.data.key + ", size: " + local_data.size + "\n" + info_ta.text;
}

Demo

Set cookie

This movie requires Flash Player 10

Get cookie

This movie requires Flash Player 10

see also:
where is .sol files in windows 7

source files in flash-cookie.zip

Flash video Player Snapshot

Posted in PHP, actionscript 3, projects & snippets on September 14th, 2009 by admin – Comments Off

Hi I have recently working on saving different format images from flash. My previous work on this script was: Image Encode with Flash and PHP. Here you can create snapshots from video source.

Example

In this example you can save exported images also in your computer. I like this example more, because you can get different images, not boring same image again.

Screenshots:
snapshot file 1
snapshot file 2
snapshot file 3

Custom Flash Video Player

Posted in actionscript 3, projects & snippets on September 14th, 2009 by admin – Comments Off

I created easy to functionality to extend player. Here is the link:
video player

You pass total of 4 flash variables:

1
2
3
4
5
var flashvars = {};
flashvars.videoURL = "running man.mp4";
flashvars.autoPlay = 0;
flashvars.isImage = 1;
flashvars.imageURL = "RunningMan.jpg";

I’m using swfobject ot embed it in page. So lets say little more about variables:
videoURL is link to video location;
autoPlay is flag, if = 1, then video will start automatically playing. If = 0, then will stay stopped until play button is clicked;
isImage is flag, if = 1, them you have to pass image location to imageURL variable, to be loaded.If = 0, then no image is loaded;
isImage is image location;

Note: autoPlay and isImage cannot be 1 at the same time! Player will throw error. Also please use 0 or 1 for flags, not false or true.