PDA

View Full Version : Help with button...


lws_dk
09-02-2005, 06:39 AM
Hi. I'm pretty new at flash, but I've managed to make some neat buttons with "over" and "out"-effects... I've gathered all my buttons (a menu) in a tween om my main-scene. Onto each button I've attached the following command:

onClipEvent(enterFrame){
this.txt.text ="trioen";
}

on(rollOver)
{
this.gotoAndPlay("RollOver");
}

on(rollOut)
{
this.gotoAndPlay("RollOut");
}

on(release)
{
gotoAndPlay("Scene 1", 5);
}

My problem is, that the last part

"
on(release)
{
gotoAndPlay("Scene 1", 5);
}
"

plays frame 5 in my button-tween (which is from the "Roll Over"-flag), and not frame 5 in my "main-scene"...
So somehow I need to make the release command exit the button tween and go to the frame in the "Scene 1", instead...

but how?

(I apologise for any incorrect use of the various terms - I'm, as mentioned, still rather new at this...)

Hope you understand what I'm asking about, and that you have a solution...

thanx

slacker
09-03-2005, 01:26 AM
you are encountering the evils of scenes. Think of action script and scenes as mater and anti-matter. when the 2 get too close to eachother, there is a huge violent fiery explosion.
For some reason, flash doesnt like to change scenes from buttons. I think it is a bug, but i'm not sure. here's the work around:

On your main timeline, create a new layer named "Actions" and put this code on the first keyframe:

function SceneChange(scene,frame) {
_root.gotoAndPlay(scene,frame)
}


This will create a function on the main timeline. it needs 2 variables to run: the scene name, and the frame number. On your button, put this code:


on(release)
{
_root.SceneChange("Scene 1", 5);
}


This code will call that function (which we have set up to act just like a gotoAndPlay) this way, instead of flash trying to change the scene from the button(which doesnt work for whatever reason), it will now be changing the scene from the root of the movie (which works).

you might also find it helpful to hit F1 in flash and search for "function" to see the actionscript refrence for usage and syntax. or click here
http://livedocs.macromedia.com/flash/mx2004/main_7_2/00001353.html

lws_dk
09-03-2005, 08:55 AM
thanx... works like a charm...

but after trying this, actually a friend of mine told me, that I could just write "_level0" before my "GotoAndPlay", so that the complete "click"-command now reads:

on(release)
{
_level0.gotoAndPlay(5);
}

I left out the scene-part, as I decided to make the presentation in one scene only, so I don't know if it will work if you add a scene-name in there... but without, it does the job, without having to create any new functionc or anything...

thanks for the help...

ultrax
09-12-2005, 10:04 PM
I have a few buttons, they're using movie clips to animate the rollOver and the rollOut process. I want to make a reference button with color changed when someone click on it, so that way they'll know what area of website they are into.

for example:

>Home< | Portfolio | Contact

I have these codes in my Home button :

on(release)
{
loadMovie("home.swf","load");
}

on (rollOver)
{
tellTarget("content") {
gotoAndPlay("start");
}
}

on (rollOut) {
tellTarget ("content") {
gotoAndPlay("continue");
}
}

my rollOver/rollOut animated are working fine.