PDA

View Full Version : problem with 2 state movie clip



Alber Kidd
May 12th, 2008, 05:35 AM
I have a movie clip that is an 'about' button. It has 2 frames one for each state(see gif). The problem is I have added the following code to the rollover (blue box). It traces the message but does not move the timeline. Any reason why the this keyword should not work here?


inv2.addEventListener(MouseEvent.MOUSE_OVER, goBack);


function goBack(event:MouseEvent) {
trace('yo');
this.gotoAndStop(1);

}

amarghosh
May 12th, 2008, 08:08 AM
'this' won't work from an inner function (a function declared inside another one); 'this' is to be used from a class function (which can be declared private, protected, public etc); if u trace(this) in ur code u will get [Object global] instead of [Object YourClassName];
try declaring ur goBack function as public in the same place: it should give an error:
take the goBack method out of all the methods and place it just in side the class declaration and it will work;

Alber Kidd
May 12th, 2008, 08:32 AM
thanks, this object is not created with a class it is a frame tweened menu with lots of buttons inside it.

is there any way to do it from an inner function?

I have tried

gotoAndStop(1);

this.gotoAndStop(1);

When I trace(this) I get

[object about]

There must be a way to make the current movieclips timeline go to frame 1?

amarghosh
May 12th, 2008, 08:42 AM
give a trace(this.currentFrame) before and after the gotoAndStop line and see what u get;

Alber Kidd
May 12th, 2008, 08:49 AM
give a trace(this.currentFrame) before and after the gotoAndStop line and see what u get;

I get the correct frame

this code

inv3_mc.addEventListener(MouseEvent.MOUSE_OVER, goBack);


function goBack(event:MouseEvent) {
trace(this.currentFrame);
trace(this);
gotoAndStop(1);
trace(this.currentFrame);

}



outputs...


2
[object about]
1



so why us the timeline not moving?


Thanks.

amarghosh
May 12th, 2008, 08:53 AM
is there any chance that ur frame number 1 and 2 are similar? try going to some other frames and see if its moving;

Alber Kidd
May 12th, 2008, 09:33 AM
attached is the flash source. Please can you take a quick look. Thanks.

amarghosh
May 12th, 2008, 09:40 AM
am sorry but i work on flex builder. can't open fla with it
:(