Groups | Blog | Home
all groups > flash actionscript > october 2005 >

flash actionscript : klgad, or anyone, how to get slider land on correct button on page load



artscreations
10/31/2005 11:45:31 PM
Hi All,

How can I get the slider bar to land over the main menu button when that page
loads in the browser?

Below is a link for the current page I am working on, but the same problem is
with every page in the site.

http://www.innova-techsolutions.com/blacknwhite_image.htm

Below is a link for the fla file if it will help:

http://www.innova-techsolutions.com/blacknwhitemenu_10_28.fla

for nttp users:

www.innova-techsolutions.com/blacknwhite_image.htm
www.innova-techsolutions.com/blacknwhitemenu_10_28.fla

The menu as you can see, is a flash object with the code below in the first
frame of the actions layer of the main timeline of the menu. Each page has a
slight change in the menu code. But here is the code that I have for the
black n white image process page.

As you can see, for each of the 8 buttons, I thought that putting the command
to move the slider with the actions for each "onRelease" event handler would
work but it does not. (i hope this makes sense, anyhow, code for this page is
below):

easeSpeed = 5;
//slider_mc is your Movie Clip's name, not the Instance Name.

slider_mc.onEnterFrame = function() {
this._x += (xMove1-this._x)/easeSpeed;
};

//Begin code for "Galleries" button w drop //down //menu

btnA = [button_2.gallery_btn, button_2.relationship_btn, button_2.wedding_btn,
button_2.baby_btn, button_2.art_btn, button_2.family_btn];
urlA = ["http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Wedding_Gallery.htm",
"http://www.innova-techsolutions.com/Baby_Gallery.htm",
"http://www.innova-techsolutions.com/Art_Gallery.htm"];
for (var i = 0; i<btnA.length; i++) {
btnA.ivar = i;
btnA.onRollOut = function() {
_root.button_2.gotoAndStop("closed");
_root.slider.xMove = _root.button_5._x;
};
btnA.onRollOver = function() {
_root.slider.xMove = _root.button_2._x;
_root.button_2.gotoAndStop("open");
};
btnA.onRelease = function() {
getURL(urlA[this.ivar], self);
_root.slider.xMove = _root.button_2._x;
};
}
//End coding for "Galleries" button w drop down //menu

//<Begin HOME button coding w Url, note I will //leave the coding here, but
comment out the url //in it since I do not want the home button to //open up
any page>\\

btnB = [button_1];
urlB = ["http://www.innova-techsolutions.com/erika_home_8_18_05.htm"];
for (var i = 0; i<btnB.length; i++) {
btnB.ivar = i;
btnB.onRollOut = function() {
_root.slider.xMove = _root.button_5._x;
};
btnB.onRollOver = function() {
_root.slider.xMove = _root.button_1._x;

};
btnB.onRelease = function() {
getURL(urlB[this.ivar], self);
_root.slider.xMove = _root.button_1._x;
};
}
//<End home button/>\\

//Begin MEET ERIKA button coding\\

btnC = [button_3];
urlC = ["http://www.innova-techsolutions.com/meet_erika.htm"];
for (var i = 0; i<btnC.length; i++) {
btnC.ivar = i;
btnC.onRollOut = function() {
//_root.button_2.gotoAndStop("closed");
_root.slider.xMove = _root.button_5._x;
};
btnC.onRollOver = function() {
_root.slider.xMove = _root.button_3._x;
//_root.button_2.gotoAndStop("open");
};
btnC.onRelease = function() {
//getURL(urlC[this.ivar], self);
_root.slider.xMove = _root.button_3._x;
};
}

//<End MEET ERIKA button coding/>\\


//<Begin THE SESSION button coding>\\

btnD = [button_4];
//urlD = ["http://www.innova-techsolutions.com/thesession.htm"];
for (var i = 0; i<btnD.length; i++) {
btnD.ivar = i;
btnD.onRollOut = function() {
//_root.button_2.gotoAndStop("closed");
_root.slider.xMove = _root.button_5._x;
};
btnD.onRollOver = function() {
_root.slider.xMove = _root.button_4._x;
//_root.button_2.gotoAndStop("open");
};
btnD.onRelease = function() {
//getURL(urlD[this.ivar], self);
_root.slider.xMove = _root.button_4._x;
};
}



//<End THE SESSION button coding/>\\


//<Begin B & W IMAGE PROCESS coding\\

btnE = [button_5];
urlE = ["http://www.innova-techsolutions.com/blacknwhite_image.htm"];
for (var i = 0; i<btnE.length; i++) {
btnE.ivar = i;
btnE.onRollOut = function() {
_root.slider.xMove = _root.button_5._x;
};
btnE.onRollOver = function() {
_root.slider.xMove = _root.button_5._x;

};
btnE.onRelease = function() {
//getURL(urlE[this.ivar], self);
_root.slider.xMove = _root.button_5._x;
};
}

//<End B & W IMAGE PROCESS button coding/>\\


//<Begin MATTING N FRAMING button coding>\\

btnF = [button_6];
urlF = ["http://www.innova-techsolutions.com/mattingandframing.htm"];
for (var i = 0; i<btnF.length; i++) {
btnF.ivar = i;
btnF.onRollOut = function() {
_root.slider.xMove = _root.button_5._x;
};
btnF.onRollOver = function() {
_root.slider.xMove = _root.button_6._x;

};
btnF.onRelease = function() {
getURL(urlF[this.ivar], self);
_root.slider.xMove = _root.button_6._x;
};
}




//<End MATTING N FRAMING button coding/>\\

//<Begin MAKING AN APPOINTMENT button>\\

btnG = [button_7];
urlG = ["http://www.innova-techsolutions.com/makinganappointment.htm"];
for (var i = 0; i<btnG.length; i++) {
btnG.ivar = i;
btnG.onRollOut = function() {
_root.slider.xMove = _root.button_5._x;
};
btnG.onRollOver = function() {
_root.slider.xMove = _root.button_7._x;

};
btnG.onRelease = function() {
getURL(urlG[this.ivar], self);
_root.slider.xMove = _root.button_7._x;
};
}




//<End MAKING AN APPOINTMENT button/>\\

//<Begin CONTACT button coding>\\

btnH = [button_8];
urlH = ["http://www.innova-techsolutions.com/contact.htm"];
for (var i = 0; i<btnH.length; i++) {
btnH.ivar = i;
btnH.onRollOut = function() {
_root.slider.xMove = _root.button_5._x;
};
btnH.onRollOver = function() {
_root.slider.xMove = _root.button_8._x;
};
btnH.onRelease = function() {
getURL(urlH[this.ivar], self);
_root.slider.xMove = _root.button_8._x;
};
}




//<End CONTACT button coding/>\\

Thanks for any suggestions.

Art Hans



artscreations
11/1/2005 12:00:00 AM
I also attempted using an onClipEvent thing with "load", since my limited
knowledge of looking at javascript MM's done with all html site (w javascript),
but I didn't get the attach only to movie clip thing worked out, since it
wasn't clear what, if any movie clip was specifically involved.

Then as I mentioned, in my coding that exists now, in the onRelease coding,
next to the getUrl, I also but the slider_mc code to match up w the correct
page matched w the main menu button. No workie.

Anyone?

Thanks,

Art Hans
kglad
11/1/2005 12:00:00 AM
change all the coding in your actions layer to:

subBtnA = [button_2.gallery_btn, button_2.relationship_btn,
button_2.wedding_btn, button_2.baby_btn, button_2.art_btn, button_2.family_btn];
btnA = [];
for (var i = 1; i<=9; i++) {
btnA = _root["button_"+i];
}
urlA = ["http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Wedding_Gallery.htm",
"http://www.innova-techsolutions.com/Baby_Gallery.htm",
"http://www.innova-techsolutions.com/Art_Gallery.htm"];
lastX=btnA[1]._x;
for (var i = 1; i<btnA.length+1; i++) {
if (i == 2) {
for (var j = 0; j<subBtnA.length; j++) {
subBtnA[j].jvar = j;
subBtnA[j].onRollOut = function() {
btnA[2].gotoAndStop("closed");
//_root.slider.xMove = _root.button_5._x;
_root.slider.xMove = lastX;
};
subBtnA[j].onRollOver = function() {
//_root.slider.xMove = _root.button_2._x;
_root.slider.xMove = btnA[2]._x;
btnA[2].gotoAndStop("open");
};
subBtnA[j].onRelease = function() {
getURL(urlA[this.jvar], self);
lastX = btnA[2]._x;
_root.slider.xMove = lastX;
//_root.slider.xMove = _root.button_2._x;
};
}
} else {
btnA[ i ].ivar = i;
btnA[ i ].onRollOut = function() {
//_root.slider.xMove = _root.button_5._x;
_root.slider.xMove = lastX;
};
btnA[ i ].onRollOver = function() {
//_root.slider.xMove = _root.button_2._x;
_root.slider.xMove = this._x;
};
btnA[ i ].onRelease = function() {
getURL(urlA[this.ivar], self);
lastX = this._x;
_root.slider.xMove = lastX;
//_root.slider.xMove = _root.button_2._x;
};
}
}
kglad
11/1/2005 12:00:00 AM
p.s. you'll need to fix your urlA so your buttons load the correct page. in
fact, to be consistant use:

urlSubA=["http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Wedding_Gallery.htm",
"http://www.innova-techsolutions.com/Baby_Gallery.htm",
"http://www.innova-techsolutions.com/Art_Gallery.htm"];

and


urlA=["http://www.innova-techsolutions.com/erika_home_8_18_05.htm",x,"http://www
..innova-techsolutions.com/meet_erika.htm",...]

and change the subBtnA[j].onRelease to

subBtnA[j].onRelease = function() {
getURL(urlSubA[this.jvar], self);

artscreations
11/1/2005 12:00:00 AM
Klagd, what is this?

btnA = [];

What is that symbol?

Thanks, I don't understand what you did here, except seeing the sub added.

As I did with the other code, I look it over a number of times, until I see
what I can add or change.

thanks, again.

Art

kglad
11/2/2005 12:00:00 AM
that's a left bracket ( [ ) followed by a right bracket ( ] ). the following lines are equivalent:

btnA=[];
artscreations
11/2/2005 12:00:00 AM
Got it. Since I'm brand new to arrays (at least the use of them), I never
noticed that symbol without the index item (if thats what its called)
contained within the brackets.

But I guess its a simpler form. Is it also AS2 or 1 n 2?, or is that
irrevelant?

Anyhow, thanks. The code you set up for me before, was actually kinda fun to
figure out so that I could add my own for the rest of the buttons.
Awesome way to learn..... Though I had to go over it 5 times before it dawned
on me how simple it was to employ. Slow learner. Anyhow. I enjoy it.

Thank you again for the great help. This site has got me on edge since
its my first flash site, and first flash customer. (my 2nd website customer
other than 2 or 3 freebies for friends n mom)

Anyhow, back to interpretation mode.

Art Hans
kglad
11/2/2005 7:10:09 PM
you're welcome. that will for for as 1 and 2. you can always test by changing
your publish settings and try something simple like:

myA=[];
myA[0]="HI";
trace(myA[0]);

if myA=[] were not supported in as 1, you would see undefined in the output
panel.
artscreations
11/8/2005 12:00:00 AM
Klagd,

A few things I don't understand about this:


[quoted text, click to view]
w.innova-techsolutions.com/meet_erika.htm",...<

1) You have an "x", as the second item. By ordering, that would be the
"Galleries" subbutton A, but I don't understand why that is in there

2) When you set this up, does that mean that I am eliminating Button B, C,D
etc, and placing all of them into Url A? I don't grasp that at all.

3) If I place all the buttons (other than the galleries w sub links) all under
Url A, I don't see how to set up Rollover, Rollout, Release.

I apologize for my ignorance, but I am lost here.

Thanks,

Art

artscreations
11/9/2005 12:00:00 AM
Thoughts?

Thx

kglad
11/9/2005 12:00:00 AM
all your buttons use a getURL() in their onRelease handler EXCEPT the buttonA[
1 ]. so urlA[ 1 ] is never used.

the onRelease, onRollOver and onRollOut handlers for all the buttons and
subbuttons are all defined in the code i gave above.
artscreations
11/9/2005 12:00:00 AM
Klagd, you mentioned:

[quoted text, click to view]
subbuttons are all defined in the code i gave above. <

Are you saying they are defined in this code below, where there will be no
button A (gallery), because I understood you to mean that button A corellates
to Url A (which will no longer exist since only subButA is used on the link for
the 4 or 5 galleries ?:

[quoted text, click to view]
fact, to be consistant use:

urlSubA=["http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Relationship_Gallery.htm",
"http://www.innova-techsolutions.com/Wedding_Gallery.htm",
"http://www.innova-techsolutions.com/Baby_Gallery.htm",
"http://www.innova-techsolutions.com/Art_Gallery.htm"

and


urlA=["http://www.innova-techsolutions.com/erika_home_8_18_05.htm",x,"http://www
..innova-techsolutions.com/meet_erika.htm",...

and change the subBtnA[j].onRelease to

subBtnA[j].onRelease = function() {
getURL(urlSubA[this.jvar], self);<<

This new code with subBtnA that you revised on 11/1 is a whole new concept
that I don't grasp at all.

Taking the original code you gave me, and interpolating it for all the other
link buttons as immediately below here, I finally got a grasp on (which they
all worked except, for having the sliding current page indicator load over the
correct/current page link as follows below) :

Example

//Begin MEET ERIKA button coding\\

btnC = [button_3];
urlC = ["http://www.innova-techsolutions.com/meet_erika.htm"
for (var i = 0; i<btnC.length; i++) {
btnC.ivar = i;
btnC.onRollOut = function() {
//_root.button_2.gotoAndStop("closed");
_root.slider.xMove = _root.button_5._x;
};
btnC.onRollOver = function() {
_root.slider.xMove = _root.button_3._x;
//_root.button_2.gotoAndStop("open");
};
btnC.onRelease = function() {
//getURL(urlC[this.ivar], self);
_root.slider.xMove = _root.button_3._x;
};
}

//<End MEET ERIKA button coding/>\\

Or are you saying that I use this code directly below, for all the onRollover,
Rollout and onRelease for button B,C,D,E,etc and of course remove btn A, and
change it to C,D etc?:

[quoted text, click to view]
btnA[ i ].ivar = i;
btnA[ i ].onRollOut = function() {
//_root.slider.xMove = _root.button_5._x;
_root.slider.xMove = lastX;
};
btnA[ i ].onRollOver = function() {
//_root.slider.xMove = _root.button_2._x;
_root.slider.xMove = this._x;
};
btnA[ i ].onRelease = function() {
getURL(urlA[this.ivar], self);
lastX = this._x;
_root.slider.xMove = lastX;
//_root.slider.xMove = _root.button_2._x;
};
}
} <<

I just read chapter 11 on Arrays in "Flash MX2004 - Actionscript Bible", and I
am reading it again, but so far it is not clear to me, mainly because Ch. 11
had to do with the array class, and no constructors are used in the code for my
site, so the chapter doesn't seem to be relevant. (granted, I have to read
anything like this 3 or 4 times to grasp it, I am severe ADD n Dyslexic, no
bs-ing, it took me 14 years to get thru college, but I am determined to learn
this stuff)

Anyhow, thanks for all your help so far.

PS - My apologies for being such a pain in the butt, and for being so thick
headed. Sincere.

Art Hans










AddThis Social Bookmark Button