If Stage (Init) throws error - actionscript-3

This line throws a Stack Error (FlashDevelop) not compile error. I have other errors but I would thought the others might be flowing from this.
Can anyone get a sense of why its having trouble with this basic part of code?
Which is 1009 when displayed in external error viewer.
lines
if (stage) {init();}
throw this error.
It won't attach the second sprite without error- though it does seem to set on stage- traces don't give any results even they did before (with 4.4.2) however I just updated to 4.4.3.
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType;
import flash.utils.describeType;
import boxsprite;
import flash.net.*;
import flash.display.Stage;
import board;
/**
* ...
* #author Michael
*/
public class Main extends Sprite
{
internal var kanaList:Vector.<String> = new <String>["あ/ア", "あ/ア", "え/え", "え/え", "い/イ", "い/イ", "お/オ", "お/オ", "う/ウ", "う/ウ", "う/ウ", "う/ウ", "か/カ", "か/カ", "け/ケ", "け/ケ", "き/キ", "き/キ", "く/ク", "く/ク", "こ/コ", "こ/コ", "さ/サ", "さ/サ", " し/シ", " し/シ", "す/ス", "す/ス", "そ/ソ", "そ/ソ", "す/ス", "す/ス", "た/タ", "た/タ", "て/テ", "て/テ", " ち/チ", " ち/チ", "と/ト", "と/ト", "つ/ツ", "つ/ツ", "ら/ラ", "ら/ラ", "れ/レ", "れ/レ", "り/リ", "り/リ", "ろ/ロ", "ろ/ロ", "る/ル", "る/ル", "だ/ダ", "で/デ", "じ/ジ", "ど/ド", "ず/ズ", "ざ/ザ", "ぜ/ゼ", "ぞ/ゾ", "な/ナ", "ね/ネ", "に/二", "の/ノ", "ぬ/ヌ", "じゃ/ジャ", "じゅ/ジュ", "じょ/ジョ", "ん/ン", "しゃ/シャ", "しゅ/シュ", "しょ/ショ", "や/ヤ", "ゆ/ユ", "よ/ヨ", "は/ハ", "ひ/ヒ", "ふ/フ", "へ/ヘ", "ほ/ホ", "ば/バ", "ば/バ", "ぶ/ブ", "ぶ/ブ", "び/ビ", "び/ビ", "ぼ/ボ", "ぼ/ボ", "べ/ベ", "べ/ベ", "ぱ/パ", "ぴ/ピ", "ぷ/プ", "ぺ/ペ", "ぽ/ポ", "ま/マ", "み/ミ", " む/ム", "め/メ", "も/モ", "を/ヲ", "みゃ/ミャ", "みゅ/ミャ", "みょ/ミョ", "きゃ/キャ", "きゅ/キュ", "きょ/キョ", "にゃ/ニャ", "にゅ/ニュ", "にょ/ニョ", "びゃ/びゃ", "びゅ/ビュ", "びょ/ビョ", "  ひゃ/ヒャ", "ひゅ/ヒュ", "ひょ/ヒョ", "ぴゃ/ピャ", "ぴゅ/ピュ", "ぴょ/ピョ", "っ/ッ", "っ/ッ"];
internal var valueList:Vector.<uint>= new <uint>[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10, 10, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 20, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1];
// Lists of Kana that can be replaced in the replace mode and the substitute Kana and Values
internal var selectghostList:Vector.<String>=new<String>["ま/マ","む/ム","も/モ","か/カ","く/ク","こ/コ","な/ナ","ぬ/ヌ","の/ノ","ば/バ","ぶ/ブ","ぼ/ボ","は/ハ","ふ/フ","ほ/ホ","ぱ/パ","ぷ/プ","ぽ/ポ"];
internal var selectkanaList:Vector.<String>=new <String>["みゃ/ミャ", "みゅ/ミャ", "みょ/ミョ", "きゃ/キャ", "きゅ/キュ", "きょ/キョ", "にゃ/ニャ", "にゅ/ニュ", "にょ/ニョ", "びゃ/びゃ", "びゅ/ビュ", "びょ/ビョ", "  ひゃ/ヒャ", "ひゅ/ヒュ", "ひょ/ヒョ", "ぴゃ/ピャ", "ぴゅ/ピュ", "ぴょ/ピョ"];
internal var selectghostvalueList:Vector.<uint>=new <uint>[2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2];
//Start list of playerHand contents as I don't know if Null is 0
internal var playernumber:uint;
internal var playerHand:Array = [[0], [0], [0], [0],[0], [0]];
[Embed(source = "C:/Windows/Fonts/Verdana.ttf", fontName = "Verdana", fontWeight = "bold", advancedAntiAliasing = "true", mimeType = "application/x-font")]
public static const VERD:Class;
/*[Embed(source="../lib/StartText.txt",mimeType="application/octet-stream")]
private var myFile:Class;
public var b:ByteArray = new myFile();
public var s:String = b.readUTFBytes(b.length)*/
public function Main():void
{
if (stage) {init();}
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//var board1:Sprite = new board();
//stage.addChild(board1);
//
var boardonScreen:Sprite = new board();
boardonScreen.x = 0;
boardonScreen.y = 0;
addChild(boardonScreen);
var box1:Sprite = new boxsprite();
box1.x = 480;
box1.y = 0;
addChild(box1);
}
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType;
import flash.utils.describeType;
import flash.net.*;
import Set;
import StatusBox;
import Statusx;
import flash.display.InteractiveObject;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import fl.managers.FocusManager;
import flash.display.*;
import flash.display.Stage;
import flash.events.KeyboardEvent;
public class boxsprite extends Sprite
{
[Embed(source="../lib/Box.jpg")]
private var boxspriteClass:Class
internal var mode:uint= 1;
internal var displaytext:String;
internal var setBox:Boolean = false;
internal var onBoard:Array = [0];
internal var playerRound:uint = 1;
internal var round:uint = 1;
public var playernumber:uint;
public function boxsprite():void
{
trace (mode);
init2();
addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
choosetext();
}
private function init2():void
{
var boxsprite2:Bitmap = new boxspriteClass() as Bitmap;
this.addChild(boxsprite2); }
Doesn't matter how I write that part whether init or init()
Errors translated from Japanese with names removed.
null: TypeError: 1009 Error #.
at boxsprite / frontpage () ...Test \ New Project \ src \ boxsprite.as: 168]
at boxsprite / choosetext () ... Games \ Test \ New Project \ src \ boxsprite.as: 132]
at boxsprite () ... Test \ New Project \ src \ boxsprite.as: 53]
at Main / init () ...Test \ New Project \ src \ Main.as: 75]
at Main ().... \ Test \ New Project \ src \ Main.as: 56]
all functions are ():void except for eventlistener associated functions
Look for yourself no uninitialized variables- everything is defined before its used.
It totally fails to create textfields so that's why stage.focus fails.
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType;
import flash.utils.describeType;
import flash.net.*;
import Set;
import StatusBox;
import Statusx;
import flash.display.InteractiveObject;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import fl.managers.FocusManager;
import flash.display.*;
import flash.display.Stage;
import flash.events.KeyboardEvent;
public class boxsprite extends Sprite
{
[Embed(source = "C:/Windows/Fonts/Verdana.ttf", fontName = "Verdana", fontWeight = "bold", advancedAntiAliasing = "true", mimeType = "application/x-font")]
public static const VERD:Class;
[Embed(source="../lib/Box.jpg")]
private var boxspriteClass:Class
internal var mode:uint;
internal var displaytext:String;
internal var setBox:Boolean = false;
internal var onBoard:Array = [0];
internal var playerRound:uint = 1;
internal var round:uint = 1;
internal var playernumber:uint;
internal var myTextBox:TextField = new TextField();
public function boxsprite():void
{mode = 1;
trace (mode);
init2();
this.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
}
private function init2():void
{
var boxsprite2:Bitmap = new boxspriteClass() as Bitmap;
this.addChild(boxsprite2);
choosetext();
}
protected function myKeyDown(e2:KeyboardEvent):void
{if (e2.keyCode ==Keyboard.ENTER)
{
/*mode 2 is beginning mode- setting a tile prompts a Set event which return a StatusBox event which unsets the tile
* mode 3 is return mode- setting a tile prompts a Set event which triggers a change to mode 4
* mode 4 return finish- add more tiles to return and either press Enter to end game and remove tile ID from hand list or double click any tile which trigger Status Box event to unset tiles
* mode 5 exchange simpler- setting a tile prompts a Set event which adds to temp list triggers function replace which a create simpleTile- double click on either triggers StatusBox event which kills the other tile and removes the tile from player list
* mode 6 exchange Kanji- setting a tile prompts Set event which triggers function newKanji which creates a kanjiTile-
* mode 7 set more tiles add to temp remove list double click on any set tile or click on Kanji tile to write Kanji or double click to complete press H to hide other tile to check with other players
* mode 8 end turn- press Enter to end score or press R to return tiles to hand
* mode 9 score
*/
switch (mode)
{ case 1:{mode = 2;
choosetext();
}
case 8:
{ mode = 9;}
case 9:
{mode = 2;
turn1();
}
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
if (setBox == false){
if (onBoard.length>1)
{mode = 8;
choosetext();}}
if (onBoard.length == 1)
{mode = 2;
choosetext();
turn1();
}
else if (setBox == true)
//set SetBox to true only for
{mode += 1;
choosetext();
}
}
}
if (e2.keyCode ==Keyboard.H)
{
navigateToURL(new URLRequest("http://wp.me/P3FUQl-n"));
}
//else if (e.Keycode == Keyboard.Q)
}
internal function choosetext():void
{switch (mode)
{case 1: {myTextBox.text = "";
frontpage();
trace ("mode is one"); }
case 2: {myTextBox.text = "Below are your tiles. Move them onto the board- double click to place. 下記のタイルは場所にボードをダブルクリックにそれらを移動している。"; }
case 3: {myTextBox.text = "Remove from your hand- place tile on the box (double click)- Press Enter when done.ボックス(ダブルクリック)であなたの手の場所のタイルから削除 - 終了したら、Enterキーを押します。";}
case 4: {myTextBox.text = "Press Enter to remove tiles and end your turn or double click any placed tile to not remove.タイルを削除してターンを終了するには、Enterキーを押したり、ダブル削除しないように、任意のタイル配置をクリックします。";}
case 5: {myTextBox.text =  "Place tile on box to get alternate kana tile- double click the one that you want あなたが望むものを得るために別の仮名タイルをダブルクリックを取得するためのボックスの上に置いてタイル" }
case 6: {myTextBox.text = "Place tile on box to get blank tile for writing kanji- click on it. 漢字を書くために空白のタイルを取得するためのボックスの上に置いてタイル. それをクリック";}
case 7: {myTextBox.text = "Place more tiles to form full reading. Press H to (un)hide other tiles so partner can check. Double click on the new or one old to select. 完全読書を形成するために多くのタイルを配置します。パートナーがチェックすることができるように他のタイルを隠すために、Hを押します。選択して新規または1歳をダブルクリックします。"; }
case 8: {myTextBox.text = "Press Enter if you or other players are OK with your word(s) or press R to return tiles. あなたや他のプレイヤーがあなたの言葉でOKであればEnterキーを押すか、タイルを返すためにRを押してください。"; }
case 9: {myTextBox.text = " Your score for this turn is below as calculated is below. Press S to reduce score and A to increase score. このターンのためにあなたのスコアは以下のように下にある計算されます。スコアAを押しますを高めるためにスコアSキーを押しを低減するために、"; }
}
}
protected function frontpage():void
{ //Introduction
trace ("draw");
var playerQ:TextField = new TextField();
playerQ.text = "Number of players 1-6?プレイヤーの数は(1)";
trace (playerQ.text);
playerQ.x = 0;
playerQ.y = 0;
playerQ.width = 64;
playerQ.height = 32;
playerQ.wordWrap = true;
this.addChild(playerQ);
var playernotext:TextField = new TextField();
playernotext.type = TextFieldType.INPUT;
playernotext.x = 0;
playernotext.y = 32;
playernotext.width = 32;
playernotext.height = 32;
playernotext.border = true;
addChild(playernotext);
stage.focus = playernotext;
playernotext.restrict = "1-6";
if (mode!=1){
if (playernotext.text != null)
{
playernumber = Number(playernotext.text); }
else
{playernumber = 1; }}
}
protected function turn1():void
{
if (playerRound > playernumber)
{playerRound = 1;
round += 1;
//create();
//display();
}
}
/*
deal();
}
internal function deal():void
{ var tileattrib:Array;
var kana:String;
var value:uint;
var newTileGroup:Array;
for (var i:uint = 1; i < 8; i += 1)
{
tileattrib = playerHand[playerRound[i]];
var newTile:Sprite = new tile(tileattrib[1],tileattrib[2]);
newTile.x = 15*32;
newTile.y = (15-i)*32;
newTileGroup.push(newTile);
addChild(newTile);}
}*/
protected function display():void
{
var format:TextFormat = new TextFormat("VERD", 20);
format.size = 20;
format.color = 0xFF0000;
format.font = "VERD";
myTextBox.defaultTextFormat = format;
myTextBox.setTextFormat(format);
myTextBox.antiAliasType = AntiAliasType.ADVANCED;
myTextBox.multiline = true;
myTextBox.textColor = 0xFF0000;
myTextBox.background = true;
myTextBox.border = true;
myTextBox.type = TextFieldType.DYNAMIC;
myTextBox.x=4;
myTextBox.y=4;
myTextBox.width = 32*4-4;
myTextBox.height = 32*6;
myTextBox.wordWrap = true;
stage.addChild(myTextBox);
myTextBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownScroll);
//
function mouseDownScroll(event:MouseEvent):void
{
myTextBox.scrollV+=1;
}
}
}
}
For some reason, if I reason it at least creates the instance and textfields though its still unresponsive to Enter key presses.
if I comment out the reference to Board() in Main()
package
{
import flash.display.Bitmap;
import flash.display.Sprite
import flash.text.TextField
import flash.text.TextFormat
import flash.events.MouseEvent
import flash.text.AntiAliasType
import flash.events.KeyboardEvent
import flash.ui.Keyboard
/**
* ...
* #author ...
*/
public class board extends Sprite
{
[Embed(source="../lib/Board.jpg")]
private var boardClass :Class;
public function board():void
{
start();
this.addEventListener(KeyboardEvent.KEY_DOWN, kill);
}
private var startBox:TextField = new TextField();
private function start():void
{var boardclass1:Bitmap = new boardClass() as Bitmap
this.addChild(boardclass1);
startBox.text = "Jabble. Click to Scroll Down. (下にスクロールする]をクリック) Instructions alternate between English and Japanese (translations). Press H for the help web page or put http://wp.me/P3FUQl-n in your web browser. Beneath is the Board and to the right is the Box. Press ENTER to go through the game stages- complete word, check and the score, deal next set of tiles. Press Spacebar to change the tile return modes- remove tiles from hand, exchange for alternate kana, exchange for a kanji. Click and Drag Tiles to move it and double click it set it on a square space on the Board or Box and click on the Box to change its mode. Jabble- 英語と日本語(訳)との間で交互に指示。を押して、ヘルプWebページのHまたはWebブラウザでhttp://wp.me/P3FUQl-nを置く。下には、取締役会であり、右に?などのさらなる命令ディスプレイボックスです.、ゲームを通してステージコンプリート単語、チェックとスコアを行くタイルの次のセットを扱うためにEnterキーを押します。モード·削除タイルの手札からタイル戻り、代替カナ引き換え、漢字と引き換えを変更するにはスペースバーを押します。クリックして、それを移動し、倍増するタイルをドラッグ 。クリックして、それを移動するにはタイルをドラッグし、ダブル会またはボックス上の正方形のスペースには、それを設定してクリックし、そのモードを変更するには、ボックスをクリックしてください " ;
var format:TextFormat = new TextFormat("VERD", 20);
format.size = 20;
format.color = 0xFF0000;
format.font = "VERD";
startBox.defaultTextFormat = format;
startBox.setTextFormat(format);
startBox.antiAliasType = AntiAliasType.ADVANCED;
startBox.multiline = true;
startBox.textColor = 0xFF0000;
startBox.background = true;
startBox.border = true;
startBox.x=32;
startBox.y=32;
startBox.width = 32*13;
startBox.height = 32*13;
startBox.wordWrap = true;
this.addChild(startBox);
startBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownScroll);
//
function mouseDownScroll(event:MouseEvent):void
{
startBox.scrollV+=1;
}
}
private function kill (e:KeyboardEvent):void
{ if (e.keyCode == Keyboard.ENTER)
{removeChild(startBox);
startBox = null;
this.removeEventListener(KeyboardEvent.KEY_DOWN, kill);
}
}
}
}

Related

as3 button getting clicked 50 px below button

I have an issue. I've narrowed down to my button class where if I click 50-100px below the button sprite area, the mouse.click event listener is triggered.
At one point I thought that a nested issue with sprite children could have caused it, but even adding the button straight to stage has the same effect.
I rewrote the button class from scratch and the same thing is happened.
I'm unsure if this is something that happens because I'm writing pure as3 with the flex framework or something else. Here is the class for the button code:
package org.project.ui
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Graphics;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import org.project.controller.IController;
import flash.utils.getQualifiedClassName;
/**
*
*
*/
public class CustomButton2 extends CustomSprite
{
protected var _button:Sprite;
protected var _buttonFunction:Function = null;
protected var _label:String = "";
protected var _textField:TextField;
protected var _textFormat:TextFormat;
protected var _font:String = "Arial";
protected var _fontSize:int = 12;
protected var _fontColor:uint = 0x000000;
protected var _buttonWidth:int = 110;
protected var _buttonHeight:int = 30;
public function CustomButton2(label:String, id:String, w:int, h:int, buttonFunction:Function = null)
{
super(id, content);
_label = label;
_buttonWidth = w;
_buttonHeight = h;
_button = makeButton(label, w, h, buttonFunction);
addButtonListeners();
addChild(_button);
}
protected function makeButton(label:String, w:int, h:int, buttonFunction:Function = null):Sprite {
_button = new Sprite();
_button = drawButton(_button);
_button.useHandCursor = true;
_button.buttonMode = true;
_button.mouseChildren = false;
_button = addTextField(label, _button);
return _button;
}
protected function addTextField(label:String, button:Sprite):Sprite {
_textFormat = new TextFormat(_font, _fontSize, _fontColor, false, null, null, null, null, TextFormatAlign.CENTER);
_textField = new TextField();
_textField.defaultTextFormat = _textFormat;
_textField.name = "textField_" + id;
_textField.text = _label;
_textField.selectable = false;
button.addChild(_textField);
return button;
}
protected function addButtonListeners():void {
_button.addEventListener(MouseEvent.CLICK, mouseClick);
_button.addEventListener(MouseEvent.ROLL_OVER, mouseRollover);
_button.addEventListener(MouseEvent.ROLL_OUT, mouseRollOut);
}
protected function mouseClick(e:MouseEvent) {
e.stopPropagation();
if (_buttonFunction) {
_buttonFunction();
}
changeButtonDisplay();
trace("click");
}
protected function mouseRollover(e:MouseEvent) {
changeButtonDisplay(0xFF0000);
}
protected function mouseRollOut(e:MouseEvent) {
changeButtonDisplay(0xFFCC00);
}
protected function changeButtonDisplay(u:uint = 0xFF0000, w:int = 110, h:int = 30):void {
_button = drawButton(_button, w, h, u);
}
protected function drawButton(button:Sprite, w:int = 110, h:int = 30, u:uint = 0xFFCC00):Sprite{
button.graphics.beginFill(u);
button.graphics.lineStyle(1);
button.graphics.drawRoundRect(0, 0, w, h, 20);
button.graphics.endFill();
button = addTextField(_label, button);
return button;
}
}
}
Any suggestions would greatly be appreciated.
Most likely your TextField is extending past the rest of your button.
It doesn't appear as though your setting the text field's bounds, so it will be the default (usually a 100x100 square).
I suggest explicitly setting the text field's width and height to match your button.
_textField.width = _buttonWidth;
_textField.height = _buttonHeight;
Or instead, if you want all the text visible no matter what, you could use the autoSize property to make the text field bounds match the actual text.
_textField.autoSize = TextFieldAutoSize.LEFT;

Actionscript Loader Error #1009

I'm trying to make a basic loader that uses Splash.swf to then load myisogame.swf
I keep getting error #1009. It's a template we was given in class, originally the Splash.swf directed to Game.swf, but in the code below there is only one mention of where it directs to.
In the template Game.fla doesn't have any code in it.
Here is the Splash
package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
public class Splash extends MovieClip {
var myLoader:Loader;
var loadingAnim:LoadingAnimation;
var percentLoaded:TextField =new TextField();
public function Splash() {
// constructor code
myLoader = new Loader();
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
var blubox = new BluBox();
addChild(blubox);
blubox.x=200;
blubox.y=200;
loadingAnim = new LoadingAnimation();
addChild(loadingAnim);
loadingAnim.x=200;
loadingAnim.y=200;
loadingAnim.scaleX=0;
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0xFF0000;
format.size = 20;
format.underline = false;
percentLoaded.defaultTextFormat = format;
addChild(percentLoaded);
percentLoaded.x=200;
percentLoaded.y=230;
myLoader.load(new URLRequest("myisogame.swf"));
}
function onProgress(evt:ProgressEvent):void {
var nPercent:Number = Math.round((evt.bytesLoaded / evt.bytesTotal) * 100);
loadingAnim.scaleX = nPercent / 100;
percentLoaded.text = nPercent.toString() + "%";
trace("load%"+nPercent.toString());
}
function onComplete(evt:Event):void {
myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
loadingAnim.x=1000;
addChild(myLoader);
}
function onIOError(evt:IOErrorEvent):void {
trace("IOError loading SWF");
}
}
}
5
6
7
8
11
12
13
14
20
25
26
MyIsoGame code
package {
import flash.display.MovieClip;
import as3isolib.display.scene.IsoScene;
import as3isolib.display.IsoView;
import as3isolib.display.scene.IsoGrid;
import as3isolib.graphics.Stroke;
import as3isolib.display.primitive.IsoBox;
import as3isolib.display.IsoSprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import eDpLib.events.ProxyEvent;
import as3isolib.geom.Pt;
import as3isolib.geom.IsoMath;
import as3isolib.graphics.SolidColorFill;
// before class
public class MyIsoGame extends MovieClip {
public var scene:IsoScene;
public var view:IsoView ;
public var CELLSIZE:int = 30;//------This is very important to remember cell size. This will affect placement of objects
var zoomFactor:Number = 1;////Zoom Factor heerrrreee--------------------
var s1:IsoSprite = new IsoSprite();
var wr:IsoSprite = new IsoSprite();
var wre:IsoSprite = new IsoSprite();
var g1:IsoSprite = new IsoSprite();
var b1:IsoSprite = new IsoSprite();
var b2:IsoSprite = new IsoSprite();
var b3:IsoSprite = new IsoSprite();
public function MyIsoGame() {
// constructor code
trace("hello from constructor");
scene = new IsoScene();
view = new IsoView();
view.setSize((stage.stageWidth), stage.stageHeight);
view.clipContent = true;
view.showBorder = false;
view.addScene(scene);
view.addEventListener(MouseEvent.MOUSE_DOWN, onStartPan, false, 0, true);
view.addEventListener(MouseEvent.MOUSE_WHEEL, onZoom, false, 0, true);
addChild(view);
var g:IsoGrid = new IsoGrid();
g.addEventListener(MouseEvent.CLICK, gridClick);
g.cellSize=30;
g.setGridSize(6,6);
g.y=0;
g.x=0;
g.gridlines = new Stroke(2,0x666666);
g.showOrigin = false;
scene.addChild(g);
g.addEventListener(MouseEvent.CLICK, grid_mouseHandler);
var box:IsoBox = new IsoBox();
box.setSize(10, 10, 10);
box.moveTo(50,50,0);
scene.addChild(box);
wr.setSize(30, 30, 30);
wr.moveTo(60, 0, 0);
wr.sprites=[new Wrecked()];
scene.addChild(wr);
wre.setSize(30, 30, 30);
wre.moveTo(30, 0, 0);
wre.sprites=[new Wrecked()];
scene.addChild(wre);
g1.setSize(30, 30, 30);
g1.moveTo(150, 150, 0);
g1.sprites=[new Gold()];
scene.addChild(g1);
b1.setSize(30, 30, 30);
b1.moveTo(120, 120, 0);
b1.sprites=[new Blue()];
scene.addChild(b1);
b2.setSize(30, 30, 30);
b2.moveTo(120, 150, 0);
b2.sprites=[new Blue()];
scene.addChild(b2);
b3.setSize(30, 30, 30);
b3.moveTo(150, 120, 0);
b3.sprites=[new Blue()];
scene.addChild(b3);
scene.render();
stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheel);///MOUSE WHEEL CONTROL
stage.addEventListener (KeyboardEvent.KEY_DOWN, keyboarddownlistener)
}
private function gridClick(event:ProxyEvent):void
{
var me:MouseEvent = MouseEvent(event.targetEvent);
var p:Pt = new Pt(me.localX, me.localY);
IsoMath.screenToIso(p);
y
}
private var panPt:Pt;
private function onStartPan(e:MouseEvent):void
{
panPt = new Pt(stage.mouseX, stage.mouseY);
view.removeEventListener(MouseEvent.MOUSE_DOWN, onStartPan);
view.addEventListener(MouseEvent.MOUSE_MOVE, onPan, false, 0, true);
view.addEventListener(MouseEvent.MOUSE_UP, onStopPan, false, 0, true);
}
private function onPan(e:MouseEvent):void
{
view.panBy(panPt.x - stage.mouseX, panPt.y - stage.mouseY);
panPt.x = stage.mouseX;
panPt.y = stage.mouseY;
}
private function boxClick(e:Event)
{
view.centerOnIso(e.target as IsoBox);
}
private function onStopPan(e:MouseEvent):void
{
view.removeEventListener(MouseEvent.MOUSE_MOVE, onPan);
view.removeEventListener(MouseEvent.MOUSE_UP, onStopPan);
view.addEventListener(MouseEvent.MOUSE_DOWN, onStartPan, false, 0, true);
}
private var zoomValue:Number = 1;
private function onZoom(e:MouseEvent):void
{
if(e.delta > 0)
zoomValue += 0.10;
if(e.delta < 0)
zoomValue -= 0.10;
view.currentZoom = zoomValue;
}
///----------------Grid Mouse Handler
public function grid_mouseHandler (evt:ProxyEvent):void
{
var mEvt:MouseEvent = MouseEvent(evt.targetEvent);
var pt:Pt = new Pt(mEvt.localX, mEvt.localY);
IsoMath.screenToIso(pt);
var roundedX:int = int(pt.x)/30;
var roundedY:int= int(pt.y)/30;
trace("transformed point = "+roundedX +","+roundedY);
///Code that allows things to be put down, located here.
var s:IsoSprite= new IsoSprite();
s.sprites=[new Base()];
s.setSize(30, 30, 30);//Varies via Cell size-
s.moveTo(roundedX*30, roundedY*30, 0);
scene.addChild(s);
scene.render();
}///------------------Grid Mouse Handler
public function mouseWheel (event:MouseEvent){
trace("The Delta value isss: " + event.delta);
//Get current view zoom
zoomFactor+=event.delta*0.04;
view.zoom(zoomFactor)
}
public function keyboarddownlistener(e:KeyboardEvent){
{//Screen-Movement Code
if (e.keyCode == 40)
{// The numbers represent the keyboard buttons
trace("Down Arrow")// I've left these trace commands so you can get a better idea of which one is what.-William 22/04/14
view.pan(0,5);
scene.render();
//Down arrow???
}
}
if (e.keyCode == 38)
{
trace("Up Arrow")
view.pan(0,-5);
scene.render();
//Up arrow???
}
if (e.keyCode == 37)
{
trace("Left Arrow")
view.pan(5,0);
scene.render();
//Left arrow???
}
if (e.keyCode == 39)
{
trace("Right Arrow")
view.pan(-5,0);
scene.render();
//Right arrow???
}
/////OBJECT MOVEMENT code- For moving the donut around
///-- I am going to be working on a version of this game where--
///- everything can be controlled via a Keyboard only -William 22/04/14
if (e.keyCode == 65)
{
trace("A Left <--")
//view.x+=15;//Alternate version
s1.moveBy(30,0,0)
scene.render();
//Left?
}
if (e.keyCode == 68)
{
trace("D Right -->")
//view.x-=15;//Alternate version
s1.moveBy(-30,0,0)
scene.render();
//Right?
}
if (e.keyCode == 83)
{
trace("S Down --v")
//view.x-=15;//Alternate version
s1.moveBy(0,30,0)
scene.render();
//Down?
}
if (e.keyCode == 87)
{
trace("W Up --^")
//view.x-=15;//Alternate version
s1.moveBy(0,-30,0)
scene.render();
//Up?
}
}
}
}
I tried the code you supplied (without the numbers at the bottom) and it worked just fine for me.
error #1009 is a runtime error when you use a variable that hasn't been defined yet. I would suggest debugging from Flash Pro (ctrl + shift +enter) and let it show you where it breaks.
In your FLA, you said there is no code, but in the properties panel you do see the class field with "Splash" in it right? that is what links the class to the FLA.
It is possible that the runtime error you are seeing is not in the Splash class but in either BluBox or LoadingAnimation. Do those have class files? If not, take a look in the Library and you'll have two movie clips that are exported for actionScript with those names. Check in them to see if there might be some framescript.

Child object not detected

Why can't it detect these declared image objects- m22,m33....?
TypeError: 2007 Error #: Parameter child must be non-null.
The code runs fine until choosetext function then errors.
mode traces display.
Other traces display.
Yaddah Yaddah
boxtrans is a transparent sprite to mask mouse input.
package {
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
import mx.core.BitmapAsset;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType;
import flash.utils.describeType;
import flash.net.*;
import Set;
import StatusBox;
import Statusx;
import flash.display.InteractiveObject;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import fl.managers.FocusManager;
import flash.display.*;
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.utils.*;
import boxtrans;
public class boxsprite extends Sprite {
[Embed(source = "C:/Windows/Fonts/Verdana.ttf", fontName = "Verdana", fontWeight = "bold", advancedAntiAliasing = "true", mimeType = "application/x-font")]
public static const VERD:Class;
[Embed(source="../lib/box.gif")]
private var boxspriteClass:Class
[Embed(source = "../lib/m2.gif")]
private var m2:Class
[Embed(source = "../lib/m3.gif")]
private var m3:Class
[Embed(source="../lib/m4.gif")]
private var m4:Class
[Embed(source = "../lib/m5.gif")]
private var m5:Class
[Embed(source = "../lib/m6.gif")]
private var m6:Class
[Embed(source = "../lib/m7.gif")]
private var m7: Class
[Embed(source="../lib/m8.gif")]
private var m8: Class
[Embed(source = "../lib/m9.gif")]
private var m9: Class
internal var m22:Bitmap;
internal var m33:Bitmap;
internal var m44:Bitmap;
internal var m55:Bitmap;
internal var m66:Bitmap;
internal var m77:Bitmap;
internal var m88:Bitmap;
internal var m99:Bitmap;
internal var boxsprite2:Bitmap;
internal var boxtrans1:Sprite;
internal var mode:uint=2;
internal var displaytext:String;
internal var setBox:Boolean = false;
internal var onBoard:Array = [0];
internal var playerRound:uint = 1;
internal var round:uint = 1;
internal var playernumber:uint;
internal var myTextBox:TextField = new TextField();
public function boxsprite():void {
init();
}
internal function init():void {
boxsprite2=new boxspriteClass as Bitmap;
this.addChild(boxsprite2);
m77= new m7 as Bitmap;
this.addChild(m77);
m66= new m6 as Bitmap;
this.addChild(m66);
m55= new m5 as Bitmap;
this.addChild(m55);
m44= new m4 as Bitmap;
this.addChild(m44);
m33= new m3 as Bitmap;
this.addChild(m33);
m22 = new m2 as Bitmap;
this.addChild(m22);
boxtrans1 = new boxtrans() as Sprite;
boxtrans1.x = 0;
boxtrans1.y = 240;
this.addChild(boxtrans1);
this.addEventListener(MouseEvent.CLICK, clickDoubleClick);
}
internal var m_nDoubleClickSpeed:Number = 300;
internal var m_toMouse:Number;
internal function clickDoubleClick(e:MouseEvent):void {
if (isNaN(m_toMouse)==false) {
clearTimeout(m_toMouse);
HandleDoubleClick();
} else {
m_toMouse = setTimeout(HandleSingleClick, m_nDoubleClickSpeed);
}
}
internal function HandleSingleClick():void {
trace("HandleSingleClick");
m_toMouse = NaN;
}
internal function HandleDoubleClick():void {
modeswitch();
trace("HandleDoubleClick");
m_toMouse = NaN;
}
internal function modeswitch():void{
trace(mode);
switch(mode) {
case 8:
{mode = 9;
choosetext(); }
case 9:
{mode = 2;
choosetext();
}
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
{mode +=1;
choosetext(); }
}
}
internal function choosetext():void {
switch (mode) {
case 2: {this.setChildIndex(m22,this.numChildren - 1);}
case 3: {this.setChildIndex(m33,this.numChildren - 1);}
case 4: {this.setChildIndex(m44,this.numChildren - 1);}
case 5: {this.setChildIndex(m55,this.numChildren - 1);}
case 6: {this.setChildIndex(m66,this.numChildren - 1);}
case 7: {this.setChildIndex(m77,this.numChildren - 1);}
case 8: {this.setChildIndex(m88,this.numChildren - 1);}
case 9: {this.setChildIndex(m99,this.numChildren - 1); }
}
}
}
}
It looks like you are not instantiating m88 or m99 anywhere.
Since you don't have any breakcommands in your switch statement it falls through and executes every case even if mode is only 2.
I'm assuming you meant to do something like this:
switch (mode) {
case 2:
this.setChildIndex(m22,this.numChildren - 1);
break;
case 3:
this.setChildIndex(m33,this.numChildren - 1);
break;
// etc...
}

AS3 creating new instances from blueprints

I'm learning how classes work, it's pretty complicated. I need an example of a right object creation. Let's say I have a MovieClip blueprint in my library. It can be used as an example to create many instances with names that can further be used as objects in code to change their properties. So pretend I have a blueprint "AppleBP". I set it as Apple class (assume, it creates a file Apple.as?). I need a code that would create (by pushing a button, for example) an instance Apple01 that would appear at a random place on the screen (just to know it's different from others, I know how to randomize position). Then make Apple02, Apple03, Apple04 and Apple05. If it's hard to set name to "Apple" + N, it's ok to stick to an array with names or at least pick it like if(N = 1){//code for Apple01 creation} then N++ etc.
So for now I tried
var Apple01:Apple = new Apple();
Apple01.visible = true; //just in case I can't see it
Apple01.x = 100;
Apple01.y = 100;
TextField01.text = "blahblah"; //to see if code actually works
Apple doesn't appear, text does. So what am I missing if creating a new class that is a MovieClip blueprint isn't enough? And how would I pick new names for each new instance so that it had variable String instead of pure name? (so that I could change the name as text + number based on it's order)
Add:
package {
import flash.display.Scene;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.events.*;
import flash.display.*;
public class MyFirstClass extends MovieClip{
//var N:int;
var n:int;
var existingApples:int = 0;
var apples:Array = new Array();
public function MyFirstClass():void{
MakeNewApple();
MakeNewApple();
MakeNewApple();
MakeNewApple();
MakeNewApple();
//apple4.x = 5;
//apple4.y = 5;
var draggableApple:Apple = apples[0] ;
draggableApple.addEventListener(MouseEvent.MOUSE_DOWN, draggableApple.onMouseDown) ;
draggableApple.addEventListener(MouseEvent.MOUSE_UP, draggableApple.onMouseUp) ;
info01.text = "Did it";
}
public function MakeNewApple():void{
if(existingApples < 5){
n = existingApples;
var apple:Apple = new Apple();
stage.addChild(apple);
apple.x = (Math.random()*600+100);
apple.y = (Math.random()*400+100);
apple.name = "apple" + n;
apples.push(apple.name);
existingApples++;
trace(existingApples);
trace(apples);
}
}
}
}
Apple.as:
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.events.*;
import flash.display.*;
public class Apple extends MovieClip{
public function Apple() {
}
public function onMouseDown(e:MouseEvent):void{
this.startDrag();
}
public function onMouseUp(e:MouseEvent):void{
this.stopDrag();
}
}
}
Here is come commented example:
package
{
import flash.display.Scene;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class Main extends Sprite
{
public function Main():void {
var apples:Array = new Array() ; // Declare and array
for (var i:int = 0 ; i < 10 ; i++) { //Let's make 10 apples
var apple:Apple = new Apple() ; //Create an apple
apple.x = Math.ceil(Math.random() * stage.stageWidth) ; //Assign random x
apple.y = Math.ceil(Math.random() * stage.stageHeight) ; //Assign random y
stage.addChild(apple) ; //Add it to stage, so we can see them
apples.push(apple) ; //Push into array
}
//EDITED
var draggableApple:Apple = apples[0] ;
draggableApple.addEventListener(MouseEvent.MOUSE_DOWN, draggableApple.onMouseDown) ;
draggableApple.addEventListener(MouseEvent.MOUSE_UP, draggableApple.onMouseUp) ;
}
}
}
And Apple.as
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Apple extends MovieClip {
public function Apple() {
this.graphics.lineStyle(2) ;
this.graphics.beginFill(0x00FF40) ;
this.graphics.drawCircle(0, 0, 20) ;
this.graphics.endFill() ;
//addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown) ;
//addEventListener(MouseEvent.MOUSE_UP, onMouseUp) ;
}
public function onMouseDown(event:MouseEvent):void {
this.startDrag() ;
}
public function onMouseUp(event:MouseEvent):void {
this.stopDrag() ;
}
}
}
Also, name of all variables must start with a small letter. myVariable
Names of classes must implement CamelCaseClass
Names of constants contain only big letters and underscores. MY_CONSTANT

adding noise to a video in actionscript

Before I begin, I would like to apologize if what I'm going to ask is to be considered as super newbie question.
so I was trying out Lee Brimelow's tutorial on creating a simple AR scene using actionscript3. (http://blog.theflashblog.com/?p=901)
It worked out pretty well, considering I have never created something out of Adobe Flex Builder before. (I installed Flex Builder right after I saw those tutorial)
here is the source code
package {
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.media.Camera;
import flash.media.Video;
import flash.utils.ByteArray;
import org.libspark.flartoolkit.core.FLARCode;
import org.libspark.flartoolkit.core.param.FLARParam;
import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData;
import org.libspark.flartoolkit.core.transmat.FLARTransMatResult;
import org.libspark.flartoolkit.detector.FLARSingleMarkerDetector;
import org.libspark.flartoolkit.support.pv3d.FLARBaseNode;
import org.libspark.flartoolkit.support.pv3d.FLARCamera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
[SWF(width="640", height="480", frameRate="30", backgroundColor="#FFFFFF")]
public class FLARdemo extends Sprite
{
[Embed(source="pat1.pat", mimeType="application/octet-stream")]
private var pattern:Class;
[Embed(source="camera_para.dat", mimeType="application/octet-stream")]
private var params:Class;
private var fparams:FLARParam;
private var mpattern:FLARCode;
private var vid:Video;
private var cam:Camera;
private var bmd:BitmapData;
private var raster:FLARRgbRaster_BitmapData;
private var detector:FLARSingleMarkerDetector;
private var scene:Scene3D;
private var camera:FLARCamera3D;
private var container:FLARBaseNode;
private var vp:Viewport3D;
private var bre:BasicRenderEngine;
private var trans:FLARTransMatResult;
public function FLARdemo()
{
setupFLAR();
setupCamera();
setupBitmap();
setupPV3D();
addEventListener(Event.ENTER_FRAME, loop);
}
private function setupFLAR():void
{
fparams = new FLARParam();
fparams.loadARParam(new params() as ByteArray);
mpattern = new FLARCode(16, 16);
mpattern.loadARPatt(new pattern());
}
private function setupCamera():void
{
vid = new Video(640, 480);
cam = Camera.getCamera();
cam.setMode(640, 480, 30);
vid.attachCamera(cam);
addChild(vid);
}
private function setupBitmap():void
{
bmd = new BitmapData(640, 480);
bmd.draw(vid);
raster = new FLARRgbRaster_BitmapData(bmd);
detector = new FLARSingleMarkerDetector(fparams, mpattern, 80);
}
private function setupPV3D():void
{
scene = new Scene3D();
camera = new FLARCamera3D(fparams);
container = new FLARBaseNode();
scene.addChild(container);
var pl:PointLight3D = new PointLight3D();
pl.x = 1000;
pl.y = 1000;
pl.z = -1000;
var ml:MaterialsList = new MaterialsList({all: new FlatShadeMaterial(pl)});
var Cube1:Cube = new Cube(ml, 30, 30, 30);
var Cube2:Cube = new Cube(ml, 30, 30, 30);
Cube2.z = 50
var Cube3:Cube = new Cube(ml, 30, 30, 30);
Cube3.z = 100
container.addChild(Cube1);
container.addChild(Cube2);
container.addChild(Cube3);
bre = new BasicRenderEngine();
trans = new FLARTransMatResult();
vp = new Viewport3D;
addChild(vp);
}
private function loop(e:Event):void
{
bmd.draw(vid);
try
{
if(detector.detectMarkerLite(raster, 80) && detector.getConfidence() > 0.5)
{
detector.getTransformMatrix(trans);
container.setTransformMatrix(trans);
bre.renderScene(scene, camera, vp);
}
}
catch(e:Error){}
}
}
}
what I am asking is :
is it possible for us to add some noise in the final video output? I'm trying to find out the PSNR by adding noises respectively.
can I do some convolution between the noise and the video?
oh btw I'm doing this for my assignment in college. My prof wanted me to explain how exactly the FlarToolKit works. (details such as Matrix Projections, Obtaining Errors by doing Iterative Method, etc.)
Thank you.
Prama
Creating fine-grained noise dynamically is computationally expensive, so I generate low-res noise and scale it up. In your project, simply add the bitmap setup code after the addEventListener call and then add the single line to generate the noise to your activity loop.
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import flash.media.Camera;
import flash.media.Video;
import flash.utils.getTimer;
public class NoiseMain extends Sprite
{
protected static const VID_WIDTH : uint = 640;
protected static const VID_HEIGHT : uint = 480;
protected static const NOISE_SCALE_X : Number = 4;
protected static const NOISE_SCALE_Y : Number = 2;
protected var _vid : Video;
protected var _noise : BitmapData;
protected var _composite : BitmapData;
protected var _matrix : Matrix;
public function NoiseMain()
{
// We're creating a webcam outlet, but not adding it to the stage since we want to post-process the image.
_vid = new Video(VID_WIDTH, VID_HEIGHT);
var cam : Camera = Camera.getCamera();
cam.setMode(VID_WIDTH, VID_HEIGHT, 30);
_vid.attachCamera(cam);
var w : uint = Math.ceil(VID_WIDTH / NOISE_SCALE_X);
var h : uint = Math.ceil(VID_HEIGHT / NOISE_SCALE_Y);
_noise = new BitmapData(w, h, false, 0xFFFFFF);
_composite = new BitmapData(VID_WIDTH, VID_HEIGHT, false, 0x000000);
var bmp : Bitmap = new Bitmap(_composite);
addChild(bmp);
_matrix = new Matrix(NOISE_SCALE_X, 0, 0, NOISE_SCALE_Y);
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
protected function enterFrameHandler(evt : Event) : void
{
_noise.noise(getTimer(), 204, 255, 7, true);
_composite.lock();
_composite.draw(_vid);
_composite.draw(_noise, _matrix, null, BlendMode.MULTIPLY);
_composite.unlock();
}
}
}
EDIT: I've revised my example to be more in line with what you're trying to do. You can tweak the noise scale constants to change the "texture" of the noise as well as messing with the strength of the noise (the 2nd and 3rd arguments to the noise() method) and the visual appearance of the noise by changing the BlendMode in the 2nd draw() call).