Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Animated button does not work inside of MC 1

Status
Not open for further replies.

spook007

Programmer
May 22, 2002
259
US
I've put together a simple button, imported into a new MC and placed the MC on the stage. There is code inside the button that will change a status variable depending whether the user is rollingover or rollingout of the button.

On the timeline on the MC, I have code on frame 1 that initializes my variables. On frame 4 I have code that determines what the status of the button is. Depending on the status the code will either increase or decrease the size of the button. On frame 5 I have a "gotoandplay" command that goes back to frame 4 and creates a continuous loop.

When I test it, the button is displayed but does not do anything. When I put the button directly on the stage and place the code on the stage and not on a MC, I've had the button work perfectly.

Perhaps I'm missing some concept of how the movie executes by having the button inside an MC. Any suggestions or recommendations would be appreciated!
 
sounds like a path problem

once the button is inside the clip the path to the variables changed

something like _root.clipName.vars = whatever
 
Here is the code I have on the button (opt_commercial):

on (rollOver){
mousePos="in";
}

on (rollOut){
mousePos="out";
}

On the MC (mc_animation) frame 1('init'):

//init
mousePos="out";
ZoomRate=10;

on the MC (mc_animation) frame 4 ('play'):

if (mousePos=="in"){
if(_root.mc_animation.opt_commercial._xscale<200){
_root.mc_animation.opt_commercial._xscale=_root.mc_animation.opt_commercial._xscale+ZoomRate;
_root.mc_animation.opt_commercial._yscale=_root.mc_animation.opt_commercial._yscale+ZoomRate;
}
}else if(mousePos==&quot;out&quot;){
if (_root.mc_animation.opt_commercial._xscale>100){
_root.mc_animation.opt_commercial._xscale=_root.mc_animation.opt_commercial._xscale-ZoomRate;
_root.mc_animation.opt_commercial._yscale=_root.mc_animation.opt_commercial._yscale-ZoomRate;
}
}

on the MC (mc_animation) frame 5 ('loop'):

gotoandplay('play');

I've gone into the debug mode and have modified my mousePos to &quot;in&quot;, I can see the if statement execute correctly but the properties on opt_commercial do not change? How should I be referencing the opt_commercial properties? Thanks.
 
Would be easier if you posted your .fla, rather than I (us) trying to re-create it from scratch! Regards,

oldman3.gif


Don't worry, if my reply is wrong, BillWatson will clean it up for me!
 
i will have a closer look but for a start take out the refererences to the button
 
on second thoughts post the fla.....got to be easier than trying to second guess what you have done.
 
if (mousePos==&quot;in&quot;){
if(this._xscale<200){
this._xscale+=ZoomRate;
this._yscale+=ZoomRate;
}
}else if(mousePos==&quot;out&quot;){
if (this._xscale>100){
this._xscale-=ZoomRate;
this._yscale-=ZoomRate;
}
}

does this give the effect you want
 
Billwatson;

Thank you very much... that is exactly what I wanted...

When you make the reference to 'this', is that refering to the MC instead of the button since the code is on MC? I was under the impression that I had to make the reference to the button?
 
'this' really has many uses depending on the situation. rather than my explanation for where and when to use it read the text in the reference panel. it has a few examples which may help clear up this point for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top