Skip to main content
mhunter1964
Known Participant
February 14, 2013
Question

setting a variable

  • February 14, 2013
  • 1 reply
  • 912 views

new to AS3...

I put this on the main timeline actions layer:

var alpha1 = 0;

inside mc1 animation on the last frame I put

alpha1 = 1;

and back on the main timeline:

if(alpha1 == 1)

{

mc1.alpha *= 0.5;

}

What am I doing wrong here?

This topic has been closed for replies.

1 reply

Nabren
Inspiring
February 14, 2013

Scope. When you set alpha1 = 1 inside mc1 - it sets mc1.alpha1 - not the alpha1 variable back on your main timeline. What are you trying to do? Perhaps I can suggest a better method.

mhunter1964
Known Participant
February 14, 2013

I want to make a movieclip react to a change in a var. Is there something wrong with the code?

Nabren
Inspiring
February 14, 2013

Yes. If mc1 is a child if the main timeline you can change your statement:

alpha1 = 1;

to

Object(this.parent).alpha1 = 1;

However, a better way would just be to set mc1.alpha instead wherever you are trying to set alpha1.