# ExecuteCodeAction is not working on meshes when imported ES6 style

**URL:** <https://forum.babylonjs.com/t/executecodeaction-is-not-working-on-meshes-when-imported-es6-style/7002>\
**Category:** Bugs\
**Created:** [November 15, 2019, 7:09am UTC](https://forum.babylonjs.com/t/executecodeaction-is-not-working-on-meshes-when-imported-es6-style/7002 "2019-11-15T07:09:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganeshrnet](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@ganeshrnet](https://forum.babylonjs.com/u/ganeshrnet)\
**Post date:** [November 15, 2019, 7:09am UTC](https://forum.babylonjs.com/t/executecodeaction-is-not-working-on-meshes-when-imported-es6-style/7002/1 "2019-11-15T07:09:19Z")

</div>

I am using babylonjs/core - 4.0.3 for my react project.

While importing the BabylonJs ES6 styles the action events are not firing for meshes

Code:

```
import { Scene } from '@babylonjs/core/scene';
import { Vector3 } from '@babylonjs/core/Maths/math';
import { FreeCamera } from '@babylonjs/core/Cameras/freeCamera';
import { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight';
import { ActionManager } from '@babylonjs/core/Actions/actionManager';
import { ExecuteCodeAction } from '@babylonjs/core/Actions/directActions';
import { Mesh } from '@babylonjs/core/Meshes/mesh';
import '@babylonjs/core/Meshes/meshBuilder';

const createScene = function() {
  const scene = new Scene(engine);
  const camera = new FreeCamera('camera1', new Vector3(0, 5, -10), scene);

  camera.setTarget(Vector3.Zero());
  camera.attachControl(canvas, true);
  const light = new HemisphericLight('light1', new Vector3(0, 1, 0), scene);

  light.intensity = 0.7;
  const sphere = Mesh.CreateSphere('sphere1', 16, 2, scene);

  sphere.position.y = 1;

  scene.exclusiveDoubleMode = false;

  const meshes = [sphere];

  for (let i = 0; i < meshes.length; i++) {
    const mesh = meshes[i];

    mesh.actionManager = new ActionManager(scene);
    mesh.actionManager.registerAction(
      // the events wont fire for this code
      new ExecuteCodeAction(ActionManager.OnPickDownTrigger, (mesh) => {
        console.log(`mesh clicked`);
      })
    );
  }

  return scene;
};

```

But when the code is imported the legacy way the the events are fired.

Code:

```
import * as BABYLON from '@babylonjs/core/Legacy/legacy';
import { Scene } from '@babylonjs/core/scene';
import { Vector3 } from '@babylonjs/core/Maths/math';
import { FreeCamera } from '@babylonjs/core/Cameras/freeCamera';
import { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight';
import { ActionManager } from '@babylonjs/core/Actions/actionManager';
import { Mesh } from '@babylonjs/core/Meshes/mesh';
import '@babylonjs/core/Meshes/meshBuilder';

const createScene = function() {
  const scene = new Scene(engine);
  const camera = new FreeCamera('camera1', new Vector3(0, 5, -10), scene);

  camera.setTarget(Vector3.Zero());
  camera.attachControl(canvas, true);
  const light = new HemisphericLight('light1', new Vector3(0, 1, 0), scene);

  light.intensity = 0.7;
  const sphere = Mesh.CreateSphere('sphere1', 16, 2, scene);

  sphere.position.y = 1;

  scene.exclusiveDoubleMode = false;

  const meshes = [sphere];

  for (let i = 0; i < meshes.length; i++) {
    const mesh = meshes[i];

    mesh.actionManager = new ActionManager(scene);
    mesh.actionManager.registerAction(
      // the code will execute in this case
      new BABYLON.ExecuteCodeAction(ActionManager.OnPickDownTrigger, (mesh) => {
        console.log(`mesh clicked`);
      })
    );
  }

  return scene;
};
```

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [November 22, 2019, 9:17pm UTC](https://forum.babylonjs.com/t/executecodeaction-is-not-working-on-meshes-when-imported-es6-style/7002/2 "2019-11-22T21:17:43Z")

</div>

Hi @ganeshrnet . Welcome to the forum! No replies yet, huh? Is the issue still pending/active?

Bump. 🙂 In fact, rubber baby buggy bump. Calling all helpers. CQ-DX, CQ-DX.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [November 23, 2019, 5:18pm UTC](https://forum.babylonjs.com/t/executecodeaction-is-not-working-on-meshes-when-imported-es6-style/7002/3 "2019-11-23T17:18:48Z")

</div>

Hey,  
Hard to say. It looks good to me. Can you try to reproduce it here:[https://codesandbox.io/](https://codesandbox.io/)  
or in other editor using es6 modules?
