Problem with Container?

Here’s a link to my project :

https://thundros.github.io/menu-system-doosan/

so I have uploaded a new 'ContainerScene.js' at :

& I am trying to figure out inside of :

https://thundros.github.io/menu-system-doosan/src/Scenes/ContainerScene.js

&

https://thundros.github.io/menu-system-doosan/src/Scenes/OptionsScene.js

I’m trying to fix :

phaser.js:36795 Uncaught TypeError: Cannot read property 'once' of undefined

I’m wondering why it’s not letting me do :

this.__container.create ({
	scene : this, x : 100, y : 100, 
	w : 100, h : 100, useChildIndex : true, 
	childData : [
		this.__myArrowLeft, 
		this.__myArrowRight,  
	]
});

Here is the 'create ( )' function from 'ContainerScene.js' :

create : function ( __objData ) {

	this.__objData = __objData;
	this.__childData = this.__objData.childData;

	this.__scene = this.__objData.scene;
	this.__x = this.__objData.x;
	this.__y = this.__objData.y;
	this.__w = this.__objData.w;
	this.__h = this.__objData.h;

	this.__useChildIndex = this.__objData.useChildIndex;

	if ( this.__useChildIndex === true ) {
		if ( typeof ( this.__childData ) === 'object' ) {
			if ( this.emptyObject ( this.__childData ) ) {
				return console.error (
					'\r\n' + 
						'CHILD DATA DOES NOT EXIST!' + '\r\n' + 
						'PLEASE ADD CHILD DATA & TRY AGAIN!' + 
					'\r\n\r\n'
				);
			}
		}
	}

	if ( this.__useChildIndex === true ) {

		this.__child = this.__childData.children;
		this.__childIndex = this.__childData.index;

		console.error ( this.__child );

		// console.error ( this.__childIndex );

	}

	this.__useScrollFactor = this.__objData.useScrollFactor;
	this.__setNonExclusive = this.__objData.setNonExclusive;
	this.__setInteractive = this.__objData.setInteractive;
	this.__interactiveGeometry = this.__objData.intGeom;
	this.__contains = this.__objData.contains;

	this.__container = this.__scene.add.container (
		this.__x, 
		this.__y
	);

	this.__container.setSize (
		this.__w, 
		this.__h
	);

	if ( this.__objData.useChildIndex === false ) {

		this.__container.add ( this.__child );

	}

	if ( this.__useChildIndex === true ) {

		this.__container.addAt (
			this.__child, 
			this.__childIndex
		);

	}

	if ( this.__useScrollFactor === true ) {

		this.__container.setScrollFactor (
			this.__scrollX, 
			this.__scrollY
		);

	}

	if ( this.__useScrollFactorChildren === true ) {

		this.__container.setScrollFactor (
			this.__scrollX, 
			this.__scrollY, 
			true
		);

	}

	if ( this.__setInteractive === true ) {

		this.__container.setInteractive (
			this.__interactiveGeometry, 
			this.__contains
		);

	}

	if ( this.__setNonExclusive === true ) {

		this.__container.setExclusive ( false );

	}

	return this.__container;

}, 

Any help is GREATLY appreciated! :slight_smile:

It should extend Scene, not Container.

Did that. I still can’t get it to put my text in the containers properly & allow me to move whatever has been added to the container all at once by moving the container itself.

https://thundros.github.io/menu-system-doosan/src/Scenes/ContainerScene.js

Specifically, 'line{s} 67 - 102 '.

Here’s the part of the code I’m talking about :

// For each Child
for ( this.__i = 0; this.__i < this.__childDataCount; this.__i++ ) {
	// If `use Child index` is `true`
	if ( this.__useChildIndex === true ) {
		// Set `this.__children [ ... ]` to 
		// `this.__childData [ this.__i ]`
		this.__children [ this.__i ] = this.__childData [ this.__i ];
		// Set the `Child` index
		this.__childIndex [ this.__i ] = this.__i;
		// If `this.__children [ this.__i ]`'s type 
		// is an object
		if ( typeof ( this.__children [ this.__i ] ) === 'object' ) {
			// If that `object is `NOT` `empty`
			if ( this.emptyObject ( this.__children [ this.__i ] ) === false ) {
				// If `NOT` using a `Child index`
				if ( this.__objData.useChildIndex === false ) {
					// Log A
					console.log ( 'A' );
					// Add the `children` 
					// to `container`
					this.__container.add ( this.__children [ this.__i ] );
				}
				// `IF` using a `Child index`
				if ( this.__objData.useChildIndex === true ) {
					// Log B
					console.log ( 'B' );
					// Set the `Child` to 
					// `index [ i ]`
					this.__container.addAt (
						this.__children [ this.__i ], 
						this.__childIndex [ this.__i ]
					);
				}
			}
		}
	}
}

Any help is GREATLY appreciated! =)

someone can help me please?

Hi @Thundros
First check if this.__childDataCount is 0 or undefined.
Regards.

Are you stepping through your code?