Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button memory

Status
Not open for further replies.

JohnandSwifty

Technical User
May 31, 2005
192
GB
Hi,

I have a map where customers choose counties to search for outlets(flash creates variables to send to CF). I would like the counties to change colour as they are clicked and remain that way until clicked again (so the customer has a visual representation of what they are searching.

Best place to start ?
 
Create a MovieClip with 2 frames - the 1st frame contains a country graphic and the 2nd frame contains the coloured country graphic. Place [tt]stop()[/tt] in the 1st frame. In the same MovieClip place a button with an action:
[tt]//
on (press) {
var frame:Number;
_currentframe<2 ? frame=2 : frame=1;
gotoAndStop(frame);
}
//[/tt]

Kenneth Kawamoto
 
thanks for the reply...

so what if the country (england) is split into a button for each county - i cant use goto as the next click will just select another instead of being able to select several?

 
yer i have them as separate buts - im still not sure how the movie clip will be clickable - if i put a but inside each movclip then it wont function - i know im missunderstanding something but i cant work out what!

help :)
 
A button in a MovieClip definitely works as long as the button is present in the MovieClip's current frame, and the MovieClip has no event handler associated with.

However, there is another approach. Create a MovieClip (call it "mcX" for now). As before it contains the county graphic and [tt]stop()[/tt] in the frame 1, and the coloured county graphic in the frame 2. Then in the main timeline place this script:
[tt]//
mcX.onPress = function() {
var frame:Number;
mcX._currentframe<2 ? frame=2 : frame=1;
mcX.gotoAndStop(frame);
};
//[/tt]

With this approach you won't need a button in the county MovieClip.

Kenneth Kawamoto
 
> this is the kind of thing im doing...

Let's take West Cornwall as an example. (I wish I were there now.) Create 3 graphics: West Cornwall in pale green, dark green and white. Create a button (A) with the pale green graphic as normal state and the dark green graphic as rollover state. Create another button (B) with the white graphic as both normal and rollover states.

Create a MovieClip. Place the button A in the 1st frame, and the button B in the 2nd frame. Place [tt]stop()[/tt] in the 1st frame.

Attach this script to the button A in the MovieClip frame 1:
[tt]//
on(press){
gotoAndStop(2)
}
//[/tt]

This to the button B in the MovieClip frame 2:
[tt]//
on(press){
gotoAndStop(1)
}
//[/tt]

Place the MovieClip on stage, and you're done.

Kenneth Kawamoto
 
at last! - sorry my whole doc was just badly organised - ive tidied up and done what you suggested - thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top