Skip to main content
Inspiring
March 17, 2022
Question

NEVER MIND -- MY BAD: how to make two nested movie clips work as variables

  • March 17, 2022
  • 1 reply
  • 281 views

I animate, Sorry I posted this.  I was using the wrong library instance to experiment on, so please ignore this question.  The code  below works just fine and both console.log(currentPetals) and console.log(currentHitArea) give the correct variable name.  I'm blushing all over the place.  Thanks.

Zaffer

Hi Animate,

I have nested two movie clips (petals_mc and hitArea_mc) inside another movie clip (currentFlower).  I do need two different nested movie clips in a flower -- one for rotation registration and one to try to manually make a hittest.  While console.log(currentPetals) always gives a variablename, console.log(currentHitArea) is always undefined.  Here's my code.  Any help will be appreciated.

Zaffer

 

 

let currentFlower;
let currentPetals;
let currentHitArea;

this.redButton_btn.addEventListener("click", positionRedFlower.bind(this));

function positionRedFlower()
{
	const redFlower_mc = new lib.redFlower();	
	this.addChild(redFlower_mc);
	redFlower_mc.x = 75;
	redFlower_mc.y = 200;
	redFlower_mc.addEventListener("pressmove", moveSomeFlower.bind(this));
}

function moveSomeFlower(e)
{
	currentFlower = e.currentTarget;
	pt = exportRoot.globalToLocal(e.stageX, e.stageY);
	e.currentTarget.x = pt.x;
	e.currentTarget.y = pt.y;
	currentPetals = currentFlower.petals_mc;
	currentHitArea = currentFlower.hitArea_mc;
	
	console.log(currentPetals);
	console.log(currentHitArea);
}

 

 

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
March 17, 2022

then there's no redFlower_mc.hitArea_mc when that console.log executes.  eg, beware of frame changes.

ZafferAuthor
Inspiring
March 17, 2022

Thanks!

kglad
Community Expert
Community Expert
March 17, 2022

you're welcome.