Difficulty adding children with AS3 Advanced Layers
I use AS3 on Adobe Animate with the built-in Camera function. My scene has a man walking in front of a field of flowers. Pressing up/down makes him walk into the flowers behind him, with the flowers appearing above his feet. Pressing left/right makes him move left and right, while the camera follows his movements and the flowers parallax behind him.
Movement code:
if (downKey == true) {
man.scaleX = 1;
man.scaleY = 1;
this.addChild (man)
}
if (upKey == true) {
man.scaleX = .8;
man.scaleY = .8;
this.addChild (flowers)
}Camera code:
import fl.VirtualCamera;
var cameraObj = VirtualCamera.getCamera(root);
cameraObj.setPosition(0,0,0);
stage.addEventListener(Event.ENTER_FRAME, paralaxing)
function paralaxing( e:Event 😞void {
if (rightKey == true) {
cameraObj.moveBy(-13,0,0);
}
if (isLeft == true) {
cameraObj.moveBy(13,0,0);
}
}My issue: I cannot re-arrange the child objects while using the Advanced Layers parallax function at the same time. I currently use the "addChild" method to ensure the right objects appear at the front, but instead of parallaxing the flowers become "glued" to the camera and move with the man.
It seems that the (this.addChild (flowers)) function is adding the flowers on the camera itself, rather than the stage they belong in (???). Any idea how to fix this?
