• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

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
0
befidled
Asked:
befidled
  • 4
  • 3
  • 2
2 Solutions
 
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
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now