ActionScript 3 Error #1009 null object reference - actionscript-3

I'm having some errors with a command system I built for my flash project. One of the commands is intro which essentially restarts the project, or is meant to (The intro starts at frame 0 of the first scene). But when it runs a reference error is thrown on what I have determined to be line 21 (Through commenting code out until it no longer errors) which is the thisRef.gotoAndPlay line of the intro function.
Here is my code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.system.fscommand;
import flash.events.KeyboardEvent;
import flash.media.Sound;
public class Main extends MovieClip {
/* The real frame number */
public var realFrameNo:int = 0;
/* Whether startup has been ran or not */
public var startupRan:Boolean = false;
/* Whether or not the beggining text is there */
public var placeholderPresent:Boolean = true;
/* Commands recognized by the computer [command:string,handler:void] */
public var commandList = new Array(["intro",function(thisRef:Main) {
gotoAndPlay(0,"Intro");
}],
["exit",function(thisRef:Main) {
fscommand("quit");
}]);
/* Helper functions */
public function isAlphabetic(value:String):Boolean
{
var result:String = value.match(/[a-zA-Z]*/)[0];
return value.length == result.length;
}
public function getSceneNo():int
{
return (realFrameNo > 0 ? Math.floor( (realFrameNo / stage.frameRate) ) : 0 );
}
public function getSceneName(sceneNo:int):String
{
switch(sceneNo)
{
default:
return "Intro";
case 0:
return "Intro";
case 1:
return "MainMenu";
}
}
/* Main functions */
public function Main()
{
this.addEventListener('enterFrame',function() {
if(!this.startupRan)
realFrameNo += 1;
/* Main menu init */
if(getSceneNo() == 1 && !this.startupRan && currentFrame == 2)
{
stop();
this.startupRan = true;
/* Add keyboard events */
stage.addEventListener(KeyboardEvent.KEY_DOWN,function(event:KeyboardEvent){
var letter:String = String.fromCharCode(event.charCode).toUpperCase();
if(event.keyCode == 8)
updateMonitor("");
else if(event.keyCode == 13)
evalInput();
else if(isAlphabetic(letter))
updateMonitor(letter);
});
/* Add button events */
btnQ.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("Q"); });
btnW.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("W"); });
btnE.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("E"); });
btnR.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("R"); });
btnT.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("T"); });
btnY.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("Y"); });
btnU.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("U"); });
btnI.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("I"); });
btnO.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("O"); });
btnP.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("P"); });
btnA.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("A"); });
btnS.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("S"); });
btnD.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("D"); });
btnF.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("F"); });
btnG.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("G"); });
btnH.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("H"); });
btnJ.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("J"); });
btnK.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("K"); });
btnL.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("L"); });
btnZ.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("Z"); });
btnX.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("X"); });
btnC.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("C"); });
btnV.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("V"); });
btnB.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("B"); });
btnN.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("N"); });
btnM.addEventListener(MouseEvent.CLICK,function(){ updateMonitor("M"); });
btnDel.addEventListener(MouseEvent.CLICK,function(){ updateMonitor(""); });
btnEnter.addEventListener(MouseEvent.CLICK,function(){ evalInput(); });
btnReturn.addEventListener(MouseEvent.CLICK,function(){ evalInput(); });
}
});
}
public function updateMonitor(letter:String)
{
if(this.placeholderPresent) //Remove placeholder
lblInput.text = letter;
else if(letter == '' || letter == null) //Backspace
{
lblInput.text = lblInput.text.substr(0,lblInput.text.length-1);
}
else //Append text
lblInput.appendText(letter);
if(lblInput.text == "")
{
lblInput.text = "Type something to begin..";
this.placeholderPresent = true;
}
else
this.placeholderPresent = false;
}
public function evalInput():void
{
if(this.placeholderPresent) //Don't eval the starting text
return;
lblOutput.text = "Scanning for commands...";
for(var i:int = 0; i < this.commandList.length; i++)
{
if(lblInput.text.toLowerCase() == this.commandList[i][0])
{
this.commandList[i][1](this);
lblOutput.appendText("\nCommand ran.");
return;
}
}
lblOutput.appendText("\nNo command recognized.");
}
}
}
Full stack trace:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/evalInput()[H:\Year 2\Units\Unit 43 - Multimedia Design\Flash Application\Main.as:144]
at Function/<anonymous>()[H:\Year 2\Units\Unit 43 - Multimedia Design\Flash Application\Main.as:71]

Related

How to add wavesurfer.js microphone plugin

am working angular cli am trying to add microphone plugin is not working .Let me know how to add the package.
this my code
angular.json file
scripts": ["node_modules/jquery/dist/jquery.min.js",
"node_modules/wavesurfer.js/dist/wavesurfer.js",
"node_modules/wavesurfer.js/dist/plugin/wavesurfer.microphone.min.js"]
}
****This is My .ts file where am getting error could somebody help me****
import MicrophonePlugin from 'wavesurfer.js/dist/plugin/wavesurfer.microphone.min.js';
import * as $ from 'jquery';
import * as WaveSurfer from 'wavesurfer.js';
public start() {
let wavesurfer= WaveSurfer.create({
container: '#waveform',
waveColor: 'violet',
progressColor: 'purple',
plugins: [MicrophonePlugin.create()]
});
wavesurfer.microphone.on('deviceReady', function() {
console.info('Device ready!');
});
wavesurfer.microphone.on('deviceError', function(code) {
console.warn('Device error: ' + code);
})
let microphone = WaveSurfer.Microphone; // Here am getting error microphone is undefined
microphone.create({
wavesurfer: wavesurfer
});
microphone.on('deviceReady', function(stream) {
console.log('Device ready!', stream);
});
microphone.on('deviceError', function(code) {
console.warn('Device error: ' + code);
});
// start the microphone
microphone.start();
}
There you go:
import MicrophonePlugin from 'wavesurfer.js/dist/plugin/wavesurfer.microphone.min.js';
import * as $ from 'jquery';
import * as WaveSurfer from 'wavesurfer.js';
public start() {
let wavesurfer= WaveSurfer.create({
container: '#waveform',
waveColor: 'violet',
progressColor: 'purple',
plugins: [ MicrophonePlugin.create() ]
});
wavesurfer.microphone.on('deviceReady', function (stream) {
console.info('Device ready!', stream);
});
wavesurfer.microphone.on('deviceError', function(code) {
console.warn('Device error: ' + code);
})
let microphone = wavesurfer.microphone; // you had the case wrong!
/*
You have already done all that stuff above
microphone.create({
wavesurfer: wavesurfer
});
microphone.on('deviceReady', function(stream) {
console.log('Device ready!', stream);
});
microphone.on('deviceError', function(code) {
console.warn('Device error: ' + code);
});
*/
// start the microphone
microphone.start();
}
If you want to do something with the stream (to play it back on another wavesurfer or to send it to a server), you can use a MediaRecorder:
wavesurfer: Object;
mediaRecorder: Object;
recordingBlob: Object;
public start() {
...
this.recordingBlob = null;
this.wavesurfer.microphone.on('deviceReady', function (stream) {
this.mediaRecorder = new MediaRecorder(stream);
this.mediaRecorder.onondataavailable = event => {
this.recordingBlob = event.data;
};
this.mediaRecorder.start();
});
...
}
public stop() {
if (!this.mediaRecorder || !this.wavesurfer) return;
this.mediaRecorder.stop();// triggers mediaRecorder.onondataavailable
this.mediaRecorder = null;
this.wavesurfer.stop();
}

Angular 4 - Working with HTMLCanvasElement

Hy every one,
I'm starting to learn Angular and I've decided to start with the implementation of the Langton Ant algorithm.
Project
The source of the standalone viewer is here: https://github.com/Phreno/langton
The source of the Angular version is here: https://stackblitz.com/edit/langton-ng?embed=1&file=app/langton/langton.main.component.ts&view=editor
I use a HTML5 canvas to display the walk.
Template
<p>Langton ant</p>
<canvas #canvas_box width='420' height='420' style="background: #fff; margin:20px"></canvas>
Component
import { LangtonGridService } from './langton.grid.service';
import { CellCoordinate } from './grid/grid.coordinate'
import { Component, ViewChild, AfterViewInit } from '#angular/core'
import { LangtonStep } from './langton.utils'
#Component({
selector: 'langton-main',
templateUrl: "template/langton.template.html",
})
export class LangtonMainComponent implements AfterViewInit{
DIRECTION_UP:number=2;
DIRECTION_RIGHT:number=1;
DIRECTION_LEFT:number=-1;
DIRECTION_DOWN:number=-2;
COLOR_FOG:string='white';
COLOR_GRID:string='gainsboro';
COLOR_FLAG:string='red';
COLOR_FREE:string='aqua';
COLOR_CURRENT:string='black';
MAX_ITERATION:number=15000;
STEP_TIMER:number=100;
grid:LangtonGridService;
#ViewChild('canvas_box')
canvas:HTMLCanvasElement;
lineCount:number;
columnCount:number;
state:any={};
roadmap:Array<LangtonStep>=[];
ngAfterViewInit(){
this.setGrid(new LangtonGridService(this.getCanvas()));
this.getGrid().drawBoard(this.COLOR_GRID);
this.walk();
}
private getCanvas():HTMLCanvasElement{
return this.canvas;
}
private getGrid():LangtonGridService{
return this.grid;
}
private setGrid(grid:LangtonGridService):void{
this.grid = grid;
}
private getState():any{
return this.state;
}
private getRoadmap():Array<LangtonStep>{
return this.roadmap;
}
private setLineCount():void{
this.lineCount = this.getGrid().computeLines().length;
}
private setColumnCount():void{
this.columnCount = this.getGrid().computeColumns().length;
}
private getLineCount():number{
return this.lineCount;
}
private getColumnCount():number{
return this.columnCount;
}
private getStart():LangtonStep{
var middleColumn:number = Math.round(this.getColumnCount()/2);
var middleLine:number = Math.round(this.getColumnCount()/2);
var start:CellCoordinate=new CellCoordinate(middleColumn, middleLine);
var color=this.COLOR_FLAG;
var direction=this.DIRECTION_UP;
var step:LangtonStep = new LangtonStep(start, color, direction);
return step;
};
private memorize(step:LangtonStep):void{
this.getState()[step.getAddress()]=step;
}
private track(step:LangtonStep):void{
this.getRoadmap().push(step);
}
private tracked(step:LangtonStep):boolean{
var state:string=typeof(this.getState()[step.getAddress()]);
var exist:boolean='undefined'.localeCompare(state)!==0;
return exist;
}
private turnRight(step:LangtonStep):LangtonStep{
var cellCoordinate:CellCoordinate;
var direction:number;
var color:string;
var next:LangtonStep;
switch(step.direction){
case this.DIRECTION_UP:
cellCoordinate=new CellCoordinate(step.coordinate.column+1, step.coordinate.line);
direction = this.DIRECTION_RIGHT;
break;
case this.DIRECTION_DOWN:
cellCoordinate=new CellCoordinate(step.coordinate.column-1, step.coordinate.line);
direction = this.DIRECTION_LEFT;
break;
case this.DIRECTION_LEFT:
cellCoordinate=new CellCoordinate(step.coordinate.column, step.coordinate.line+1);
direction = this.DIRECTION_UP;
break;
case this.DIRECTION_RIGHT:
cellCoordinate=new CellCoordinate(step.coordinate.column, step.coordinate.line-1);
direction = this.DIRECTION_RIGHT;
break;
default:
console.error('erreur dans la direction');
};
color=this.COLOR_FLAG;
next = new LangtonStep(cellCoordinate,color,direction);
return next;
}
private turnLeft(step:LangtonStep):LangtonStep{
var cellCoordinate:CellCoordinate;
var direction:number;
var color:string;
var next:LangtonStep;
switch(step.direction){
case this.DIRECTION_UP:
cellCoordinate=new CellCoordinate(step.coordinate.column-1, step.coordinate.line);
direction = this.DIRECTION_RIGHT;
break;
case this.DIRECTION_DOWN:
cellCoordinate=new CellCoordinate(step.coordinate.column+1, step.coordinate.line);
direction = this.DIRECTION_LEFT;
break;
case this.DIRECTION_LEFT:
cellCoordinate=new CellCoordinate(step.coordinate.column, step.coordinate.line-1);
direction = this.DIRECTION_UP;
break;
case this.DIRECTION_RIGHT:
cellCoordinate=new CellCoordinate(step.coordinate.column, step.coordinate.line+1);
direction = this.DIRECTION_RIGHT;
break;
default:
console.error('erreur dans la direction');
};
color=this.COLOR_FREE;
next = new LangtonStep(cellCoordinate,color,direction);
return next;
};
private getColorFromMemory(step:LangtonStep):string{
var color:string;
if(this.tracked(step)){
color=this.getState()[step.getAddress()].color;
} else {
color = this.COLOR_FOG;
}
return color;
};
private print(step:LangtonStep):void{
this.getGrid().fillCell(step.coordinate, step.color);
};
private enlight(cell:CellCoordinate):void{
this.getGrid().strokeCell(cell, this.COLOR_CURRENT);
}
private darken(cell:CellCoordinate):void{
this.getGrid().strokeCell(cell, this.COLOR_GRID);
}
private turn(step:LangtonStep):LangtonStep{
var next:LangtonStep;
switch(step.color){
case this.COLOR_FOG:
next=this.turnRight(step);
break;
case this.COLOR_FLAG:
next=this.turnLeft(step);
break;
case this.COLOR_FREE:
next=this.turnRight(step);
break;
default:
console.error('La couleur venue du ciel');
break;
}
next.setColor(this.getColorFromMemory(next));
return next;
}
private walk(step:LangtonStep=this.getStart()):void{
var self:LangtonMainComponent=this;
var forward:Function=function(step:LangtonStep):LangtonStep{
var next:LangtonStep=self.turn(step);
self.print(step);
self.darken(step.coordinate);
self.enlight(next.coordinate);
self.memorize(step);
self.track(step);
return next;
}
var iteration=0;
var run:number = setInterval(function():void{
if(self.MAX_ITERATION===iteration++){
clearInterval(run);
} else{
step=forward(step);
}
}, self.STEP_TIMER);
}
}
Problem
ERROR TypeError: Cannot read property 'getContext' of undefined
at GridDrawer.getContext (grid.drawer.ts:17)
at GridDrawer.openLayer (grid.drawer.ts:21)
at LangtonGridService.drawBoard (langton.grid.service.ts:109)
at LangtonMainComponent.ngAfterViewInit (langton.main.component.ts:51)
at callProviderLifecycles (provider.js:585)
at callElementProvidersLifecycles (provider.js:556)
at callLifecycleHooksChildrenFirst (provider.js:540)
at checkAndUpdateView (view.js:390)
at callViewAction (view.js:732)
at execComponentViewsAction (view.js:661)
Question
My first try was to set the canvas in the component constructor.
After some search, I understand that I've to import AfterViewInit interface to work with.
But in each case I reach the same error about undefined canvas.
I'm pretty sure the solution is obvious but I can't found it.
Thanks a lot for your help and have a good day.
Etienne.
I finally found the solution. The problem comes from HTMLCanvasElement and I resolve the binding using ElementRef instead.
Template
<canvas #canvas_box width='420' height='420' style="background: #fff; margin:20px"></canvas>
Component
export class LangtonMainComponent implements AfterViewInit{
/* ... */
#ViewChild('canvas_box') canvas:ElementRef;
ngAfterViewInit(){
this.canvas.nativeElement.width = this.grid.getCanvasWidth();
this.canvas.nativeElement.height = this.grid.getCanvasHeight();
this.drawBoard();
this.walk();
}
/* ... */
}

Setting data in viewModel knockoutjs from html5 websocket

I am trying to create knockout.js component that is getting data from HTML5 Websocket. Websocket code is in separate script e.g. util.js. I am able to connect and get data from socket, but dont know how correctly to set corresponding property in component`s ViewModel.
Websocket - util.js:
var options = {
server: '127.0.0.1',
port: '12345'
};
var socket, loadedFlag;
var timeout = 2000;
var clearTimer = -1;
var data = {};
function handleErrors(sError, sURL, iLine)
{
return true;
};
function getSocketState()
{
return (socket != null) ? socket.readyState : 0;
}
function onMessage(e)
{
data=$.parseJSON(e.data);
// ???? Is it possible to have here something like
// ???? viewModel.getDataWS1(data);
}
function onError()
{
clearInterval(clearTimer);
socket.onclose = function () {
loadedFlag = false;
};
clearTimer = setInterval("connectWebSocket()", timeout);
}
function onClose()
{
loadedFlag = false;
clearInterval(clearTimer);
clearTimer = setInterval("connectWebSocket()", timeout);
}
function onOpen()
{
clearInterval(clearTimer);
console.log("open" + getSocketState());
}
function connectWebSocket()
{
if ("WebSocket" in window)
{
if (getSocketState() === 1)
{
socket.onopen = onOpen;
clearInterval(clearTimer);
console.log(getSocketState());
}
else
{
try
{
host = "ws://" + options.server + ":" + options.port;
socket = new WebSocket(host);
socket.onopen = onOpen;
socket.onmessage = function (e) {
onMessage(e);
};
socket.onerror = onError;
socket.onclose = onClose;
}
catch (exeption)
{
console.log(exeption);
}
}
}
}
Component (productDisplay.js) - creating so that is can be used on multiple pages:
define([
'jquery',
'app/models/productDisplayModel',
'knockout',
'mapping',
'socket'
],
function ($, model, ko, mapping) {
ko.components.register('product', {
viewModel: {require: 'app/models/productModel'},
template: {require: 'text!app/views/product.html'}
});
});
Product ViewModel (productModel.js) - where I struggle to set viewModel property to data from websocket:
var viewModel = {};
define(['knockout', 'mapping', 'jquery'], function (ko, mapping, $) {
function Product(name, rating) {
this.name = name;
this.userRating = ko.observable(rating || null);
}
function MyViewModel() {
this.products = ko.observableArray(); // Start empty
}
MyViewModel.prototype.getDataWS1 = function () {
//Websocket has not connected and returned data yet, so data object is empty
// ???? Is there anyway I can add something like promise so that the value is set once socket is connected?
this.products(data);
};
// apply binding on page load
$(document).ready(function () {
connectToServer1();
viewModel = new MyViewModel();
ko.applyBindings(viewModel);
viewModel.getDataWS1();
});
});
Thank you for any ideas.
You can update an observable when you get a message in the following manner:
util.js
function onMessage(e) {
var productData = $.parseJSON(e.data);
viewModel.addNewProduct(productData);
}
productModel.js
function Product(name, rating) {
this.name = name;
this.userRating = ko.observable(rating || null);
}
function MyViewModel() {
this.products = ko.observableArray(); // Start empty
}
MyViewModel.prototype.addNewProduct(product) {
var newProduct = new Product(product.name, product.rating);
this.products.push(newProduct);
}
Basically the idea is that when you get a message (in onMessage function), you will parse the data and call a function in your viewmodel to add the message data to the viewmodel properties (observables, observableArrays, etc.)

An if/else issue in ActionScript 3

For a project I'm working on, I'm making a simple text-based adventure. At one point, the user sees two keys and a door nearby. I'm trying to make it so that if the user enters the door without both keys, it opens up the frame where it states that they will need both to open it (Frame 11).
The problem is, whether or not the user grabs them, it automatically directs them through the door as if they have opened it (Frame 12).
Here's my total coding. Don't mind commented portions, that's just me trying out some different approaches.
import flash.events.MouseEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
var torchb: Boolean = false;
var redkeyb: Boolean = true;
var bluekeyb: Boolean = true;
stop();
StartButtonInst.addEventListener(MouseEvent.CLICK, Page2);
function Page2(event:MouseEvent):void
{
gotoAndStop(2);
LeftButtonInst.addEventListener(MouseEvent.CLICK, Page3);
RightButtonInst.addEventListener(MouseEvent.CLICK, Page4);
}
function Page3(event:MouseEvent):void
{
gotoAndStop(3);
GoBack1Inst.addEventListener(MouseEvent.CLICK, Page2);
}
function Page4(event:MouseEvent):void
{
gotoAndStop(4);
WalkOffInst.addEventListener(MouseEvent.CLICK, Page5);
}
//function torch (e:MouseEvent){
/*if(torchb == true){
this.removeChild(GrabTorchInst);
this.gotoAndStop(7);
}
else{
this.gotoAndStop(6);
} */
/*if(!torchb) {
torchb = true;
this.removeChild(GrabTorchInst);
//this.gotoAndStop(7);
}
else {
torchb = false;
this.gotoAndStop(6);
}*/
//GrabTorchInst.addEventListener(MouseEvent.CLICK, torch);
//This event should change the boolean if the torch is picked up
//EnterCaveInst.addEventListener(MouseEvent.CLICK, cave);
//This event should change the frame to the cave or not depending what the torch bool is.
function torch (e:MouseEvent) {
torchb = torchb==true?false:true;
this.removeChild(GrabTorchInst);
}
function cave(e:MouseEvent) {
if(torchb) {
this.gotoAndStop(7);
}
else {
this.gotoAndStop(6);
}
}
function Page5(event:MouseEvent):void
{
trace(torchb);
gotoAndStop(5);
GrabTorchInst.addEventListener(MouseEvent.CLICK, torch);
EnterCaveInst.addEventListener(MouseEvent.CLICK, cave);
//GrabTorchInst.addEventListener(MouseEvent.CLICK, Page5);
EnterCaveInst.addEventListener(MouseEvent.CLICK, Page7);
/*if (GrabTorchInst = true)
{
this.gotoAndStop(7);
} */
}
/*function torch (e:MouseEvent){
if(!torchb) {
torchb = true;
this.removeChild(GrabTorchInst);
this.gotoAndStop(7);
}
else {
torchb = false;
this.gotoAndStop(6);
}
}*/
function Page6(event:MouseEvent):void
{
gotoAndStop(6);
GoBack2Inst.addEventListener(MouseEvent.CLICK, Page5)
}
function Page7(event:MouseEvent):void
{
gotoAndStop(7);
LightTorchInst.addEventListener(MouseEvent.CLICK, Page8)
AssassinateInst.addEventListener(MouseEvent.CLICK, Page10)
}
function Page8(Event:MouseEvent):void
{
gotoAndStop(8);
AssassinateInst.addEventListener(MouseEvent.CLICK, Page10)
RunAwayInst.addEventListener(MouseEvent.CLICK, Page9)
}
function Page9(Event:MouseEvent):void
{
gotoAndStop(9);
GoBack3Inst.addEventListener(MouseEvent.CLICK, Page7)
}
/*function redkey (e:MouseEvent){
if(!redkeyb) {
redkeyb = true;
this.removeChild(RedKeyInst);
//this.gotoAndStop(12);
}
else {
redkeyb = false;
this.gotoAndStop(11);
}
} */
function redkey (e:MouseEvent) {
redkeyb = redkeyb==true?false:true;
this.removeChild(RedKeyInst);
}
function bluekey (e:MouseEvent) {
bluekeyb = bluekeyb==true?false:true;
this.removeChild(BlueKeyInst);
}
function door(e:MouseEvent) {
if(redkey==true && bluekey==true){
(12)
this.gotoAndStop(12);
}
else {
this.gotoAndStop(11);
}
}
/*function bluekey (e:MouseEvent){
if(!bluekeyb) {
bluekeyb = true;
this.removeChild(BlueKeyInst);
//this.gotoAndStop(12);
}
else {
bluekeyb = false;
this.gotoAndStop(11);
}
} */
if(redkey==true&&bluekey==true){
(12)
}
function Page10(Event:MouseEvent):void
{
gotoAndStop(10);
RedKeyInst.addEventListener(MouseEvent.CLICK, redkey)
BlueKeyInst.addEventListener(MouseEvent.CLICK, bluekey)
DoorInst.addEventListener(MouseEvent.CLICK, door)
DoorInst.addEventListener(MouseEvent.CLICK, Page12)
}
function Page11(Event:MouseEvent):void
{
gotoAndStop(11)
GoBack4Inst.addEventListener(MouseEvent.CLICK, Page10)
}
function Page12(Event:MouseEvent):void
{
gotoAndStop(12)
GiveJakeAnAInst.addEventListener(MouseEvent.CLICK, Page13)
}
function Page13(Event:MouseEvent):void
{
gotoAndStop(13)
}
I'd really appreciate some assistance on this.
Don't know if this is what you want but you can try
if(torchb == true){
this.removeChild(GrabTorchInst);
this.gotoAndStop(7);
}
else{
this.gotoAndStop(6);
}
So if torchb is true, they would be sent to 7th frame
if it isn't, they would be sent to sixth frame.

CHECKPOINT-FAIL com.thoughtworks.selenium.SeleniumException: this.waitForCondition is not a function

A simple function defined in the user-extensions.js :
Selenium.prototype.doGetThis = function(){
var errors = "";
if (browserVersion.isChrome) {
errors = true;
} else {
throw new SeleniumError("TODO: Non-FF browser...");
}
return errors;
}
The Selenium.java file:
String getThis() {
return this.commandProcessor.doCommand("getThis", EMPTY_STRING_ARRAY);
}
Running the test throws a SeleniumException:
CHECKPOINT-FAIL com.thoughtworks.selenium.SeleniumException: this.waitForCondition is not a function
Could this exception be avoided?
Settings:
selenium server 2.0a5
firefox 3.6.11
After I added the ; I still got the same exception.
Selenium.prototype.doGetThis = function(){
var errors = "";
if (browserVersion.isChrome) {
errors = true;
} else {
throw new SeleniumError("TODO: Non-FF browser...");
}
return errors;
};
It seems that you need to add a ; to the end of your doGetThis function:
Selenium.prototype.doGetThis = function(){
var errors = "";
if (browserVersion.isChrome) {
errors = true;
} else {
throw new SeleniumError("TODO: Non-FF browser...");
}
return errors;
};