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
When you try to add a camera by name like this:
1 2
| var cameraName:String = "WebCam";
var cam:Camera = Camera.getCamera(cameraName); |
or like this
1
| var cam:Camera = Camera.getCamera(cameranames[0]); |
both return cam = null
Solution:
You need to add camera index like String in order to work
1 2 3 4 5 6 7 8 9 10 11
| var cameraName:String = "WebCam";
var camera:Camera;
const imax:int = Camera.names.length;
var i:int = 0;
while (i < imax) {
if (Camera.names[i] == cameraName) {
camera = Camera.getCamera(String(i));
break;
}
i++;
} |
or use this function
1 2 3 4 5 6 7 8 9 10 11 12 13
| const camera:Camera = getCamera("webCam");
private static function getCamera($cameraName_:String):Camera {
const imax:int = Camera.names.length;
var i:int = 0;
while (i < imax) {
if (Camera.names[i] == $camName_) {
return Camera.getCamera(String(i));
}
i++;
}
return null;
} |
so now you will have your camera that you wanted:
thank to:
pooja
Hi I will post some code that will make you easier to implement Scan Scout AS3 Overlay.
We have class that hold the needed values:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| package com.stanislavstankov.ss.dto {
public final class ScanScoutAS3OverlayDTO {
private var _partnerId:String;
private var _pageURL:String;
private var _mediaId:String;
private var _mediaURL:String;
private var _mediaTitle:String;
private var _mediaDescription:String;
private var _mediaKeywords:String;
private var _mediaCategories:String;
/*------------------------------------
Constructor
------------------------------------*/
public function ScanScoutAS3OverlayDTO($partnerId_:String, $pageURL_:String, $mediaId_:String, $mediaURL_:String, $mediaTitle_:String, $mediaDescription_:String, $mediaKeywords_:String, $mediaCategories_:String):void {
_partnerId = $partnerId_;
_pageURL = $pageURL_;
_mediaId = $mediaId_;
_mediaURL = $mediaURL_;
_mediaTitle = $mediaTitle_;
_mediaDescription = $mediaDescription_;
_mediaKeywords = $mediaKeywords_;
_mediaCategories = $mediaCategories_;
}
/*------------------------------------
Public methods
------------------------------------*/
public function get partnerId():String {
return _partnerId;
}
public function get pageURL():String {
return _pageURL;
}
public function get mediaId():String {
return _mediaId;
}
public function get mediaURL():String {
return _mediaURL;
}
public function get mediaTitle():String {
return _mediaTitle;
}
public function get mediaDescription():String {
return _mediaDescription;
}
public function get mediaKeywords():String {
return _mediaKeywords;
}
public function get mediaCategories():String {
return _mediaCategories;
}
public function toString():String {
return "[ ScanScoutAS3OverlayDTO partnerId='" + partnerId + "'\n\t pageURL='" + pageURL + "'\n\t mediaId='" + mediaId + "'\n\t mediaURL='" + mediaURL + "'\n\t mediaTitle='" + mediaTitle + "'\n\t mediaDescription='" + mediaDescription + "'\n\t mediaKeywords='" + mediaKeywords + "'\n\t mediaCategories='" + mediaCategories + "'\n ]";
}
}
} |
and manger that do all the work
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
| package com.stanislavstankov.ss.mngrs {
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.TimerEvent;
import flash.net.URLRequest;
import flash.system.Security;
import flash.utils.Timer;
import com.stanislavstankov.videoPlayer.events.VideoEvent;
import com.stanislavstankov.ss.dto.ScanScoutAS3OverlayDTO;
import com.stanislavstankov.videoPlayer.player.Player;
public final class ScanScoutAS3OverlayManager {
private var _ss_ads:*;
//NOTE: Do not append cache-buster. Use this URL as is
private var _ssURL:String = "http://media.scanscout.com/ads/ss_ads3.swf";
private var _ssLoader:Loader;
private var _video:Player;
private var _parent:Sprite;
private var _core:ScanScoutAS3OverlayDTO;
/*------------------------------------
Public methods
------------------------------------*/
/**
* Config the manager
* @param object that hold the needed values
* @param video player
* @param the display object that the ads will be added
*/
public function config($core_:ScanScoutAS3OverlayDTO, $video_:Player, $parent_:Sprite):void {
_core = $core_;
_video = $video_;
_parent = $parent_;
_video.addEventListener(VideoEvent.STARTED, videoStartedHandler);
_parent.stage.addEventListener(Event.RESIZE, resizeHandler);
}
/*------------------------------------
Private methods
------------------------------------*/
//NOTE: ScanScout must not be loaded unless ScanScout is to be used on the particular stream
//Also, do not load ScanScout until the video begins
//These rules are in place to avoid the transfer of assets across the wire unless they are to be used
private function initiateScanscout():void {
Security.allowDomain("*");
_ssLoader = new Loader();
_parent.addChild(_ssLoader);
if (_ssLoader.contentLoaderInfo.bytesLoaded == _ssLoader.contentLoaderInfo.bytesTotal) {
_ssLoader.contentLoaderInfo.addEventListener(Event.INIT, ss_notifyAdsLoad);
} else {
_ssLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, ss_notifyAdsLoad);
}
_ssLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ss_failedAdsLoad);
_ssLoader.load( new URLRequest(_ssURL) );
}
private function init():void {
}
/*------------------------------------
Event Functions
------------------------------------*/
private function resizeHandler(info:Event):void {
if (_ss_ads != null) {
_ss_ads.setSize(_parent.stage.stageWidth, _parent.stage.stageHeight - Controls.HEIGHT);
}
}
private function videoStartedHandler(info:VideoEvent):void {
initiateScanscout();
}
private function ss_failedAdsLoad(e:IOErrorEvent):void {
//handle error
trace(e.text);
}
private function ss_notifyAdsLoad(e:Event):void {
_ss_ads = e.target.content;
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, ss_videoTimeUpdate);
timer.start();
// Set event listeners:
_ss_ads.addEventListener("ss_pause", ss_onPause);
_ss_ads.addEventListener("ss_resume", ss_onResume);
// Set the input parameters for the Ad Rendering Engine:
_ss_ads.setParam("ss_partnerId", _core.partnerId);
_ss_ads.setParam("ss_pageURL", _core.pageURL);
//unique identifier to the video. Can be the mediaURL if that doesn't change on each request
_ss_ads.setParam("ss_mediaId", _core.mediaId);
//http URL to the FLV
_ss_ads.setParam("ss_mediaURL", _core.mediaURL);
//required metadata: should not be the same across all videos
_ss_ads.setParam("ss_mediaTitle", _core.mediaTitle);
_ss_ads.setParam("ss_mediaDescription", _core.mediaDescription);
_ss_ads.setParam("ss_mediaKeywords", _core.mediaKeywords);
_ss_ads.setParam("ss_mediaCategories", _core.mediaCategories);
// Size to fit video screen and place top-left:
_ss_ads.setSize(_parent.stage.stageWidth, _parent.stage.stageHeight - Controls.HEIGHT);
//TODO: set to left-side of video
_ssLoader.x = 0;
//TODO: set to top of video
_ssLoader.y = 0;
//Kick off the ad presentation:
_ss_ads.launch();
}
private function ss_videoTimeUpdate(evt:TimerEvent):void {
//playhead_time should be the video time in seconds
_ss_ads.videoTimeUpdate(_video.time);
}
private function ss_onPause( evtObj:Object ):void {
/* TODO: place a call to your video pause routine here */
_video.pause();
}
private function ss_onResume( evtObj:Object ):void {
/* TODO: place a call to your video resume routine here */
_video.resume();
}
/*------------------------------------
**************************************
ScanScoutAS3OverlayManager Singleton Pattern begins
**************************************
------------------------------------*/
private static var _instance:ScanScoutAS3OverlayManager;
private static var _allowInstance:Boolean = false;
/*------------------------------------
Constructor
------------------------------------*/
public function ScanScoutAS3OverlayManager():void {
if (!_allowInstance) {
throw new Error("This class is Singleton class. Use getInstance method.");
} else {
init();
}
}
public static function getInstance():ScanScoutAS3OverlayManager {
if (_instance == null) {
_allowInstance = true;
_instance = new ScanScoutAS3OverlayManager();
_allowInstance = false;
}
return _instance;
}
/*------------------------------------
**************************************
ScanScoutAS3OverlayManager Singleton Pattern ends
**************************************
------------------------------------*/
}
} |
and you call it like:
1 2
| var sc:ScanScoutAS3OverlayManager = ScanScoutAS3OverlayManager.getInstance();
sc.config(data, player, this); |
hi, I’m posting link to flash banner code because of numerous requests of link to my scripting style.

billboard flash banner
here is the zip file of source files