PDA

View Full Version : rollOver issue



Syous
May 21st, 2007, 03:42 PM
I'm modding a template for a friend, the site is pgaloans.com

When you go to the first page or the last page, everything works fine. The menu also corresponds to the current page by having the button remaining highlighted. However this isn't working for pages 2 - 5, any idea why?


on (rollOver) {
if (_root.link<>4) {
this.gotoAndPlay("s1");
}
}
on (releaseOutside, rollOut) {
if (_root.link<>4) {
this.gotoAndPlay("s2");
}
}
on (release) {
if (_root.link<>4) {
_root["item"+_root.link].gotoAndPlay("s2");
_root.link = 4;
getURL("about.html");
}
}

The actionscript is the same for every button, except the get URL and the _root.link=4 do change to the appropriate url/number.

bigbstanley
May 21st, 2007, 04:40 PM
in the on (release) you will need to change "_root.link = 4" to a different number (1 - 5);

for example here would be button 1 and button 2

Button 1
---------------------
on (rollOver) {
if (_root.link<>1) {
this.gotoAndPlay("s1");
}
}
on (releaseOutside, rollOut) {
if (_root.link<>1) {
this.gotoAndPlay("s2");
}
}
on (release) {
if (_root.link<>1) {
_root["item"+_root.link].gotoAndPlay("s2");
_root.link = 1;
getURL("page1.html");
}
}
---------------------

Button 2

--------------------
on (rollOver) {
if (_root.link<>2) {
this.gotoAndPlay("s1");
}
}
on (releaseOutside, rollOut) {
if (_root.link<>2) {
this.gotoAndPlay("s2");
}
}
on (release) {
if (_root.link<>2) {
_root["item"+_root.link].gotoAndPlay("s2");
_root.link = 2;
getURL("page2.html");
}
}


and so on . . .

Syous
May 21st, 2007, 05:06 PM
That's how the buttons are, and it still isn't working. Le sigh.

bigbstanley
May 21st, 2007, 06:24 PM
make sure then that each button has an instance name of "item"+(1-5) (ie. item1, item2, item3, item4, item5)

also, I've seen this type of code before from the templates. I think you're missing a piece as well.

the ones I've seen have code like such:



on (rollOver) {
if (_root.link<>2) {
gotoAndPlay("s1"); //a fade in
}
}
on (releaseOutside, rollOut) {
if (_root.link<>2) {
gotoAndPlay("s2"); //a fade out
}
}
on (release) {
if (_root.link<>2 ) {
_root["item"+_root.link].gotoAndPlay("s4"); //deselect motion
gotoAndPlay("s3"); //selected motion
_root.link = 2;
}
}

Syous
May 22nd, 2007, 12:30 PM
I've checked and the instance names are rights. I wish I could upload the .fla but it's too big, I'll put it up on the backend of the site in a few.

Syous
May 22nd, 2007, 12:35 PM
Click on Privacy Policy on the bottom of the index page to download the .fla if you want 8)

bigbstanley
May 22nd, 2007, 02:59 PM
Found the problem. On the buttons your code is telling the previous button to gotoAndPlay("s2") sometimes and "s3" other times. That needs to be the same throughout. Also, then in each timeline, based on your decision to use s2 or s3, you need to name the fadeout frame properly to either "s2" or "s3".

I've attached the condensed fla for you.

Syous
May 22nd, 2007, 03:45 PM
Awesome thanks! Good news and bad..

It does work in flash now, even when I applied to my header. However, it doesn't work live on the site. No idea why =/

bigbstanley
May 22nd, 2007, 03:55 PM
that's because when you click on a link, it loads a new page, thus reloading the flash and starting from the beginning. That flash header probably came from an entire flash site, where the flash does not have to reload. There are several ways to do fix this for an html site.

1. Use an iframe for your flash header.
2. Create a flash header for each page; each one having a certain button selected.
2. Use flashvars which sets the variable "_root.link" on the flash reload, thus telling which button to play as selected.

I highly recommend using FlashVars. It's really simple and then you'll only have to worry about one flash movie.

Syous
May 22nd, 2007, 04:02 PM
Okie, I'll look up flashvars in the Kirupa tutorials and see what I can find. Thanks again for all your help!

bigbstanley
May 22nd, 2007, 04:08 PM
Here is how to use FlashVars

You call FlashVars in your html (when you call the flash to load into your site). Add a parameter and call it FlashVars and give it an attribute that holds a variable and it's value.

Then in your flash, on the root, this variable will be called in.

In other words:

HTML


<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="760" height="60" id="movie" align="middle">

<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="movie.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name ="FlashVars" value="link=3" />

<embed FlashVars="link=3" src="movie.swf" quality="high" bgcolor="#ffffff" width="760" height="60" name="movie" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
notice that the flashvars is in both the parameters and embed tags.

then in your flash the variable "link", also "_root.link" will be called in at the root level. So in your flash you need a line like this (probably after the buttons fadein to help with the look of it):


_root["item"+_root.link].gotoAndPlay("s1");


Then on each page where you have the html flash code, just change the number to whichever button you want to fade in as selected.

Syous
May 22nd, 2007, 05:15 PM
That fixed it. There was also a bug in the html that came with the template that had to be changed. Thanks again for all your help, you get brownie points.

bigbstanley
May 22nd, 2007, 06:01 PM
no prob. glad I could help.

adityamenon
August 1st, 2010, 11:16 PM
I *know* I'm digging up a three year old thread, but giving credit where credit is due is extremely important.

Stanley, you are hero! In fact, you are my hero!

Thanks a lot for helping out that guy, you helped me out too! Very generous of you to spend time to solve someone else's problem (for free). You are great. :thumbs up: