Changing state of a movieclip during a movie

I've got a movieclip that I want to have button functionality. I don't want the button functionality to exist however until the _alpha of the movieclip is >= 90.

My current movieclip is set up in 2 sections. The first section is the OFF state and the second section is the ON state. I need to constantly be watching the clip to see when it's _alpha exceeds 90 so that I can move the clip to the ON state.

What is the best way to do this?

I'm in Flash MX 2004 Pro
LVL 1
befidledAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SavongCommented:
movieClipName.onEnterFrame = function(){
   if(this._alpha >= 90){
      this.onRelease = function(){
         //button function here
       }
   }
   else{
      this.onRelease = null;
   }
}

That will check your clip each frame and turn on or off your button function.  Should do what you want, just put that on the movieclip's frame with the right movie clip name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AgentSmith007Commented:
no points please

After activating button functionality, it might be a good idea to:

movieClipName.onEnterFrame = null,

so it doesn't unecessarily keep setting that function, hence freeing up a nominal amount of system resources
0
SavongCommented:
True, except that he said he wanted to constantly watch the clip.  Would be a good idea to free the CPU if it could be implemented at times anyhow.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

AgentSmith007Commented:
Ah, i guess i missed that part...Carry on!! : )
0
befidledAuthor Commented:
is there anyway to do this using event listeners or the Object.watch method?

thanks
brian
0
SavongCommented:
It could be done with the Object.watch if you have the _alpha value stored somewhere.  What is causing the value to change?  A little info is needed to give any advice on this.
0
befidledAuthor Commented:
I'm using the MovieClipTween extension (http://laco.wz.cz/tween/) and causing a movieclip to fade in. So it looks like this...

myMovieclipName._alphaTo(100, 1.5, "easeOutSine");

Once the clip reaches 90% alpha I want it to jump from it's off state to it's on state, thus activating the button.

does that help?
0
SavongCommented:
I'm not aware of another solution beyond the checking each frame.  Using that extension wouldn't appear to give you an Object property to monitor using Object.watch.  And unless that _alphaTo throws an event a listener wouldn't help.  I'd be happy to be proven wrong but as I said I don't know of a way to use those.
0
befidledAuthor Commented:
I tried the above code a number of ways and didn't get it to work. After a couple hours of sleep I realized I could just loop the movieclip within its "off" frame until it's alpha was greater than 90.

FRAME 1:
if (this._alpha >= 90) {
      this.gotoAndPlay("on");
}

FRAME 2:
gotoAndPlay(1);


since the loop is completed as soon as the _alpha is greater than 90 there is no lingering drain on the system resources.

thanks for the suggestions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.