• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

javascript targeting movieclip to change colour problem

Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Hi, newbie beginners question: I'm trying to target a movieclip on the timeline in order to change the colour of an element inside the movieclip.

The movieclip on the timeline is called 'meCircle', and inside meCircle there is another movieclip called 'meCircleRed'

I thought I'd be able to use this to change the colour of the movieclip inside;

this.meCircle.meCircleRed.style.backgroundColor = #000;

But does not work... is it correct that meCircleRed should be a movieclip, or perhaps a button?

Finding it difficult to find any examples online to learn from! any pointers to good online guides much appreciated...

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 08, 2017 May 08, 2017

Since you specify JavaScript I assume you're working in a Canvas document.

No, you cannot slap CSS styles on movieclips. Canvas mode Does Not Work That Way. To recolor objects in Canvas documents you use the ColorFilter class.

However, all Canvas filter effects except alpha are VERY SLOW, because they're implemented in JavaScript. The bigger the object, the more likely your timeline will noticeably freeze up while the filter is being applied. This may or may not be acceptable depending on what you

...

Votes

Translate

Translate
LEGEND ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Since you specify JavaScript I assume you're working in a Canvas document.

No, you cannot slap CSS styles on movieclips. Canvas mode Does Not Work That Way. To recolor objects in Canvas documents you use the ColorFilter class.

However, all Canvas filter effects except alpha are VERY SLOW, because they're implemented in JavaScript. The bigger the object, the more likely your timeline will noticeably freeze up while the filter is being applied. This may or may not be acceptable depending on what you're using it for.

There are alternative approaches too, like storing versions of the graphic pre-drawn in the colors you'll need, or tinting the object with an alpha overlay, or redrawing the object from scratch in code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

ah, thought it seemed a bit too easy... thanks, will read through a lot more of your link!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

while I'm here, would you mind just pointing me to the code for tinting an object with an alpha overlay – I think that might be the solution I need...

thanks again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

There is no code. You just put a transparent colored thing over the thing you want to tint. You know, like in the real world.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

LATEST

ah, okay, I see! thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines