I'm trying to make a memory match game in HTML5 canvas with kineticJS
. But when I click on a card on the stage it gives me an
Uncaught TypeError: Object #<Object> has no method 'drawScene'
and I can't figure out why. It happened after I added the event listener to the makeCards
function and made the clicker()
function.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="../JS/jquery.js"></script>
<style>
body {
background-color: #333;
}
#container {
margin: 0 auto;
width: 500px;
height: 500px;
border-color: red;
border-style: solid;
border-width: 2px;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="../JS/kinetic.js"></script>
<script>
//$(document).ready(function() {
var stage = new Kinetic.Stage({
container: 'container',
width: 500,
height: 500,
id: 'canvas'
});
var layer = new Kinetic.Layer();
var colors = ["Red","Blue","Green","Yellow","Orange",
"Purple","HotPink","Brown","Black","Grey",
"White","Cyan","Lime"];
function shuffle(myArray,nb_picks) {
for (i = myArray.length-1; i > 1 ; i--) {
var r = Math.floor(Math.random()*i);
var t = myArray[i];
myArray[i] = myArray[r];
myArray[r] = t;
}
return myArray.slice(0,nb_picks);
}
function cardColors() {
var colorString = [];
var shuffledColors = shuffle(colors, 13);
for (var i=0; i <= 9; i++) {
colorString.push( shuffledColors[i]);
}
var a1 = colorString;
var oldColorString = colorString.concat(a1);
var newColorString = shuffle(oldColorString, 20);
return newColorString;
}
var oldColorArray = cardColors();
var colorArray = oldColorArray.slice(0);
function makeCards(color) {
var k = 0;
for(var i=0; i <= 400; i += 100 ) {
for(var j=0; j <= 300; j += 100) {
var rect = new Kinetic.Rect({
x: i+5,
y: j+5,
width: 90,
height: 90,
fill: color,
id: k
});
rect.on('click', clicker);
layer.add(rect);
stage.add(layer);
k++;
}
}
}
function clicker() {
var i = this.attrs.id;
var newRect = this.attrs;
newRect.fill = colorArray[i];
layer.add(newRect);
stage.add(layer);
}
//start gameloop
function _init() {
makeCards('MidnightBlue');
//layer.clear();
//setInterval(function(){ showCards() }, 5000);
//showCards();
//layer.clear();
}
_init();
//});
</script>
</body>
</html>
Handling events in VB6: Initialize
Here is my question. I have VB6 class FirstClass
. In SecondClass
i create instance of FirstClass
:
WithEvents fClass as FirstClass
...
Set fClass = New FirstClass
Ok. Also in SecondClass
I have an event Initialize
- this is some event of FirstClass
's object (as far as i can understand). But when I paste breakpoint in this event, it doesn't fire. So could you please explain me why I can't go in this event and how the events handling works in VB6 in general.
Please, ask questions if my English isn't good for understanding my thoughts
Update:
Here is property from FirstClass:
Private Property Let IRPCAppMode_Application(RHS As Object)
Const METHOD_NAME As String = "IRPCAppMode_Application" 'DO NOT TRANSLATE
On Error GoTo ErrorHandler
Set mApp = RHS
Set m_objRPCProject = mApp.Project
Set m_objDataSet = m_objRPCProject.CurrentDataSet
RaiseEvent Initialize
...
I know that mApp object sets only in this line of code, that's all. What i can't understand is how Initialize Event rises in SecondClass and how can we set private property outside of class. Calling of Initialize in SecondClass:
Private Sub m_objTestMode_Initialize()
Const METHOD_NAME As String = "m_objTestMode_Initialize" 'DO NOT TRANSLATE
On Error GoTo ErrorHandler
Dim lLoop As Long
Set mRPCProject = m_objTestMode.Project
SetupAutoSaveTimer
SSTab1.Tab = 0
SSTab2.Tab = 0
Set m_objToolManager = m_objTestMode.mApp.ToolManager
Set g_objMonDrives = New clsMonDrives
Set g_objTrendMonDrives = New clsTrendDrives
....