Hi
I have a website put together in flash cs3. Everything is fully fucntional.
Unfortunately i have stumbled against a slight problem with my menu set up.
I have implemented swfAdress into my movie and have managed to pull it off.
The only thing is that if a user types the address directly into addres bar e.g. www.mysite.com/#contact it takes them to the correct section of the movie but the button state (my buttons are movie clips with instance names) doesnt reflect which section of the movie in other words the button is not highlighted.
Is there a way i could fix this? My script is set up to trigger button states onPress and hover etc, but also needs to be applied when the movie enters that frame label.
Here is the action script for my buttons:
//stop();
import com.asual.swfaddress.*;
/*
These three string manipulation functions convert your frame label into neater
text to use as the title that will display in the browser title bar for a page. If you are happy
to use your frame label as is in the title or you have more complex titles planned, these three functions
are unnecessary.
*/
function replace(str, find, replace) {
return str.split(find).join(replace);
}
function toTitleCase(str) {
return str.substr(0,1).toUpperCase() + str.substr(1);
}
function formatTitle(title) {
return 'Brooke Products' + (title != '' ? ' / ' + toTitleCase(replace(title, '/', ' / ')) : '');
}
// SWFAddress handling
SWFAddress.setStrict(false);
/*
This is the main SWFAddress function and it's triggered everytime the URL changes;
uses the full deep-linking value from the URL to determine the appropriate frame
to go to with that matching label.
*/
SWFAddress.onChange = function() {
// required - Provides the current deep linking value (including the query string)
// (e.g. returns "portfolio?id=1" if URL has #portfolio?id=1)
var value = SWFAddress.getValue();
var path = SWFAddress.getPath(); // optional - Provides the deep linking value without the query string (e.g. returns "portfolio" if URL has #portfolio?id=1), needed if you have sub pages as these are displayed after the ? in the URL
var id = SWFAddress.getParameter('id'); // optional - Provides the value of a specific parameter in the query string (e.g. returns "1" if URL has #portfolio?id=1), needed if have sub pages as these are displayed after the ? in the URL
// This if statement is needed only if you have a preloader/splash screen, otherwise you can remove it, leaving just the gotoAndStop('$' + value); line
/*if (_currentframe == 2 && value == '') { // check whether the current frame is the one immediately after the preloader and if the URL is the base URL (not a page)
intro.play(); // and if so, then play this current frame
} else {*/
// if the URL has a deep-linking value (i.e. is a page and not the base URL), then play the frame that is named by prepending a $ to the deep linking value
gotoAndStop('$' + value);
/*if (value == "$ceiling") {
gotoAndStop("blue");
} else if (value == "$active") {
gotoAndStop("red");
} else if (value == "$compact") {
gotoAndStop("yellow");
}*/
//changeOptionColor('$' + [value, overColor);
//SWFAddress.setTitle(navigation[value].title);
}
/*
Construct the browser title for the page that will now display;
this uses the three string manipulation functions above as well as the two optional variables if you have subpages
*/
/*SWFAddress.setTitle(formatTitle(path + (id != '' ? '/' + id : '')));
}
// when the user clicks the Enter button in this frame, go to the main content identified by frame label $ (frame 3 in this case)
/*enter.onRelease = function () {
gotoAndStop("$");
}*/
//----------------<re-enable menu options>-----------------\\\\
function reActivateBtns() {
lightweight.enabled = true;
paMixer.enabled = true;
triFunction.enabled = true;
ceiling.enabled = true;
wall.enabled = true;
pendant.enabled = true;
active.enabled = true;
passiveSpeaker.enabled = true;
subwoofers.enabled = true;
compact.enabled = true;
large.enabled = true;
demo.enabled = true;
contact.enabled = true;
changeOptionColor(lightweight, outColor);
changeOptionColor(paMixer, outColor);
changeOptionColor(triFunction, outColor);
changeOptionColor(ceiling, outColor);
changeOptionColor(wall, outColor);
changeOptionColor(pendant, outColor);
changeOptionColor(active, outColor);
changeOptionColor(passiveSpeaker, outColor);
changeOptionColor(subwoofers, outColor);
changeOptionColor(compact, outColor);
changeOptionColor(large, outColor);
changeOptionColor(demo, outColor);
changeOptionColor(contact, outColor);
}
//----------------</re-enable menu options>-----------------\\\\
//------------------------<define option colours>-------------------------------\\\\
var overColor:Number = 0xBB8748;
var outColor:Number = 0x000000;
function changeOptionColor (myOption:MovieClip, myColor:Number) {
myOption.textLabel.textColor = myColor;
}
//------------------------</define option colours>-------------------------------\\\\
//----------------<brooke option>-----------------\\\\
brooke.onRollOver = function () {
changeOptionColor(this, overColor);
}
brooke.onRollOut = function () {
changeOptionColor(this, outColor);
}
brooke.onRelease = function () {
SWFAddress.setValue('brooke');
SWFAddress.setStatus('brooke');
//gotoAndStop("$brooke");
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
}
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
//----------------</brooke option>-----------------\\\\
//----------------<lightweight option>-----------------\\\\
lightweight.onRollOver = function () {
changeOptionColor(this, overColor);
}
lightweight.onRollOut = function () {
changeOptionColor(this, outColor);
}
lightweight.onRelease = function () {
SWFAddress.setValue('lightweight');
SWFAddress.setStatus('lightweight');
//gotoAndStop("$lightweight");
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</lightweight option>-----------------\\\\
//----------------<paMixer option>-----------------\\\\
paMixer.onRollOver = function () {
changeOptionColor(this, overColor);
}
paMixer.onRollOut = function () {
changeOptionColor(this, outColor);
}
paMixer.onRelease = function () {
SWFAddress.setValue('paMixer');
SWFAddress.setStatus('paMixer');
//gotoAndStop("$paMixer");
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</paMixer option>-----------------\\\\
//----------------<triFunction option>-----------------\\\\
triFunction.onRollOver = function () {
changeOptionColor(this, overColor);
}
triFunction.onRollOut = function () {
changeOptionColor(this, outColor);
}
triFunction.onRelease = function () {
SWFAddress.setValue('triFunction');
SWFAddress.setStatus('triFunction');
//gotoAndStop("$triFunction");
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</triFunction option>-----------------\\\\
//----------------<ceiling option>-----------------\\\\
ceiling.onRollOver = function () {
changeOptionColor(this, overColor);
}
ceiling.onRollOut = function () {
changeOptionColor(this, outColor);
}
ceiling.onRelease = function () {
SWFAddress.setValue('ceiling');
SWFAddress.setStatus('ceiling');
//gotoAndStop("$ceiling");
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</ceiling option>-----------------\\\\
//----------------<wall option>-----------------\\\\
wall.onRollOver = function () {
changeOptionColor(this, overColor);
}
wall.onRollOut = function () {
changeOptionColor(this, outColor);
}
wall.onRelease = function () {
SWFAddress.setValue("wall");
//gotoAndStop("$wall");
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</wall option>-----------------\\\\
//----------------<pendant option>-----------------\\\\
pendant.onRollOver = function () {
changeOptionColor(this, overColor);
}
pendant.onRollOut = function () {
changeOptionColor(this, outColor);
}
pendant.onRelease = function () {
SWFAddress.setValue("pendant");
//gotoAndStop("$pendant");
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</pendant option>-----------------\\\\
//----------------<portable option>-----------------\\\\
active.onRollOver = function () {
changeOptionColor(this, overColor);
}
active.onRollOut = function () {
changeOptionColor(this, outColor);
}
active.onRelease = function () {
SWFAddress.setValue("active");
//gotoAndStop("$active");
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</portable option>-----------------\\\\
//----------------<installation option>-----------------\\\\
passiveSpeaker.onRollOver = function () {
changeOptionColor(this, overColor);
}
passiveSpeaker.onRollOut = function () {
changeOptionColor(this, outColor);
}
passiveSpeaker.onRelease = function () {
SWFAddress.setValue("passive");
//gotoAndStop("$passive");
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</installation option>-----------------\\\\
//----------------<subwoofer option>-----------------\\\\
subwoofers.onRollOver = function () {
changeOptionColor(this, overColor);
}
subwoofers.onRollOut = function () {
changeOptionColor(this, outColor);
}
subwoofers.onRelease = function () {
SWFAddress.setValue("subwoofers");
//gotoAndStop("$subwoofers");
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</subwoofer option>-----------------\\\\
//----------------<compact option>-----------------\\\\
compact.onRollOver = function () {
changeOptionColor(this, overColor);
}
compact.onRollOut = function () {
changeOptionColor(this, outColor);
}
compact.onRelease = function () {
SWFAddress.setValue("compact");
//gotoAndStop("$compact");
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</compact option>-----------------\\\\
//----------------<large option>-----------------\\\\
large.onRollOver = function () {
changeOptionColor(this, overColor);
}
large.onRollOut = function () {
changeOptionColor(this, outColor);
}
large.onRelease = function () {
SWFAddress.setValue("large");
//gotoAndStop("$large");
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</large option>-----------------\\\\
//----------------<demo option>-----------------\\\\
demo.onRollOver = function () {
changeOptionColor(this, overColor);
}
demo.onRollOut = function () {
changeOptionColor(this, outColor);
}
demo.onRelease = function () {
SWFAddress.setValue("demo");
//gotoAndStop("$demo");
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</demo option>-----------------\\\\
//----------------<contact option>-----------------\\\\
contact.onRollOver = function () {
changeOptionColor(this, overColor);
}
contact.onRollOut = function () {
changeOptionColor(this, outColor);
}
contact.onRelease = function () {
SWFAddress.setValue("contact");
//gotoAndStop("$contact");
for(z=0;z<numOfItems; z++)
{
removeMovieClip(home["item"+z]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homepaMixer["itempaMixer"+p]);
}
for(t=0;t<numOfItems; t++)
{
removeMovieClip(hometriFunction["itemtriFunction"+t]);
}
for(c=0;c<numOfItems; c++)
{
removeMovieClip(homeceiling["itemceiling"+c]);
}
for(p=0;p<numOfItems; p++)
{
removeMovieClip(homeportables["itemportables"+p]);
}
for(b=0;b<numOfItems; b++)
{
removeMovieClip(homestadium["itemstadium"+b]);
}
for(s=0;s<numOfItems; s++)
{
removeMovieClip(homesubs["itemsubs"+s]);
}
for(l=0;l<numOfItems; l++)
{
removeMovieClip(homeLightweight["itemLightweight"+l]);
}
removeMovieClip(container_mc);
removeMovieClip(fullImage_mc);
removeMovieClip(mask_mc);
reActivateBtns();
changeOptionColor(this, overColor);
this.enabled = false;
}
//----------------</contact option>-----------------\\\\
Thanks fo your help