Skip to main content
joshe55299479
Participant
December 17, 2019
Answered

I can't target the mask in javascript. I need it to follow the mouse

  • December 17, 2019
  • 1 reply
  • 541 views

Hi. First post, thanks for reading 

 

Here is what I have to target the movie clip on the mask layer:

 

 

exportRoot.labelXMask.x = props.graph.maskX.x

 

 

Now this works fine when the layer is not a mask but becomes un-targetable once the layer is made a mask. I've done a bit of reading and from what I've gathered once I've published that movie clip on the mask it loses its instance name.

 

Other people seem to have cracked it by targeting 'mask', which I have to admit is not making much sense to me. I've tried the following:

 

 

exportRoot.mask.x = props.graph.maskX.x
exportRoot.labelXMask.mask.x = props.graph.maskX.x
mask.x = props.graph.maskX.x
mask_1.x = props.graph.maskX.x

 

 

but no luck 😞 Can anyone shed some light, please? 

Save me Obi-Wan!

This topic has been closed for replies.
Correct answer ClayUUID

While it might be possible to do what you want by rummaging around in the guts of the generated data structures, you're far better off doing this properly with a programmatic mask.

this.themask.visible = false;
this.maskee.mask = this.themask.shape;
this.themask.shape.x = 200;

Where "maskee" is the movieclip to be masked, and "themask" is a movieclip containing a single, contiguous vector shape and nothing else. Origin for the masked region is 0, 0 of the masked clip's parent.

1 reply

ClayUUIDCorrect answer
Legend
December 17, 2019

While it might be possible to do what you want by rummaging around in the guts of the generated data structures, you're far better off doing this properly with a programmatic mask.

this.themask.visible = false;
this.maskee.mask = this.themask.shape;
this.themask.shape.x = 200;

Where "maskee" is the movieclip to be masked, and "themask" is a movieclip containing a single, contiguous vector shape and nothing else. Origin for the masked region is 0, 0 of the masked clip's parent.

joshe55299479
Participant
December 22, 2019

Hi Clay - I have a question regarding my specific scenario if you don't mind. 

 

I have two masks on the stage - one has it's x coordinates set by the mouse and the other the y coordinates. I'm using these masks to only reveal bold text when the correct region is being highlighted. 

 

If I'm reading you're answer correctly:

It's targeting a shape I've generated in animate? 

 

 

this.themask.visible = false;
this.maskee.mask = this.themask.shape;
this.themask.shape.x = 200;

 

 

in my case would be:

 

exportRoot.maskX.visible = false;
exportRoot.labelX.mask = exportRoot.maskX.shape;
exportRoot.maskX.shape.x = props.mouse.x

 

 

Does that seem right to you?

Legend
December 23, 2019

Probably? Why don't you try it and see if it works.