3/3/2010 4:20:42 AM
Title:
Site Menu ActionScript
hi
i'm a beginner of flash cs3, & making a static site (XHTML)
i've included a flash menu in it, it works fine.
problem is this that when its buttons doesn't stay on
"selected state". i want to show each button selected on its
relevant page.
ActionScript on every button is same (with different variable
& URL)
onClipEvent (load) {
num = 5;
}
on (rollOver)
{
if (_root.link != num)
{
_root.menu2["item" + num].gotoAndPlay("over");
}
}
on (releaseOutside, rollOut)
{
if (_root.link != num)
{
_root.menu2["item" + num].gotoAndPlay("out");
}
}
on (release)
{
if (_root.link != num)
{
_root.link_prev = _root.link;
_parent["item" + _root.link].gotoAndPlay("out");
_root.menu2["item" + num].gotoAndPlay("slctd");
_root.link = num;
getURL("quick_quote.html");
}
}
3/3/2010 4:46:08 AM
Hi, Kami when you are using a flash menu and on each click load a new page . Due to page refresh the flash menu is reset. You need to tell the flash menu that which page is opened know .
To achieve this , you should use use the param tag in html to set a variable in flash which will tell the flash movie which page is loaded.
Like if home page is open you will set variable in flash using param tag like this in HTML flash tag
<PARAM NAME=page VALUE="home">
the variable page will now be available in flash movie with _root.page know using this variable you can set the button selected as soon as movie is loaded.
so in each html page you should set this value according to page name.
3/3/2010 5:05:16 AM
for each page html page tell flash using query string
for page1 menuFlash.swf?setButton=page1
for page2 menuFlash.swf?setButton=page2
for page3 menuFlash.swf?setButton=page3
and in flash movie
if(setButton== page1){
gotoAndPlay("selctedButton1")
}else if(setButton== page2){
gotoAndPlay("selctedButton2")
}else if(setButton== page3){
gotoAndPlay("selctedButton3")
}
if not clear ping me back will create a sample for you
3/3/2010 5:34:30 AM
happy to see ur response :)
but as u know that i'm a beginner... so
will u please show me this solution fitted
into my ActionScript code:
--------------------------------------------
onClipEvent (load) {
num = 1;
}
on (rollOver)
{
if (_root.link != num)
{
_root.menu2["item" + num].gotoAndPlay("over");
}
}
on (releaseOutside, rollOut)
{
if (_root.link != num)
{
_root.menu2["item" + num].gotoAndPlay("out");
}
}
on (release)
{
if (_root.link != num)
{
_root.link_prev = _root.link;
_parent["item" + _root.link].gotoAndPlay("out");
_root.menu2["item" + num].gotoAndPlay("slctd");
_root.link = num;
getURL("index.html");
}
}
----------------------------------------------
page name is "index.html"
3/3/2010 9:31:56 AM
You have to set page variable in every html page where you want some button to be selected, notice the "page=selectHomeButton" is set at two places for home page, for contact page set the variable like "page=selectContactButton" , do it in each html for all links.
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://macromedia.com/cabs/swflash.cab#version=6,0,0,0"
ID=flaMovie WIDTH=250 HEIGHT=250>
<PARAM NAME=movie VALUE="testParam.swf">
<PARAM NAME=FlashVars VALUE="page=selectHomeButton">
<PARAM NAME=quality VALUE=medium>
<PARAM NAME=bgcolor VALUE=#ffffff>
<EMBED src="testParam.swf"
FlashVars="page=selectHomeButton"
bgcolor=#ffffff WIDTH=250 HEIGHT=250
TYPE="application/x-shockwave-flash">
</EMBED>
</OBJECT>
in flash write this code in first frame in the root
if(_root.page=="selectHomeButton"){
//write code to show home button selected
}else if(_root.page=="selectContactButton"){
//write code to show home button selected
}