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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing a mc........ 2

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
on (press) {
_root.window3.gotoAndPlay("29");
}
on (press) {
_root.window1.gotoAndPlay("29");
}
on (press) {
_root.window2.gotoAndPlay("2");
}
this will pic and choose which mc is open and close it by sending it to the frame that is blank to shut off the mc..then opening window2 after it closes either 3, or 1, which ever is open...

is there a easier way to script this or will this suffice..it works fine..was just wondering how you guys would script it!!
e.gif


carlsatterwhite@endangeredgraphics.com
 
I'd put them all within the same event...

on (press) {
_root.window3.gotoAndPlay("29");
_root.window1.gotoAndPlay("29");
_root.window2.gotoAndPlay("2");
}


...saves some typing.
 
thanks....
e.gif


carlsatterwhite@endangeredgraphics.com
 
Here's a more complex, but reusable approach just in case you ever need to shut down 50 clips before opening a new one ;-)

When your button is pressed set a variable identifying which clip you want to run... (assuming that each clip has a button associated with it)...

on (press) {
_root.thisWindow = 2;
}


Have a control clip monitoring what's going on at all times, this will detect the button push, shut down as many clips as necessary (defined in a variable called "maxclips"), then start the clip associated with the button that was pushed...

onClipEvent (enterFrame) {
//
// loop through all of the clips
for (i=1; i<=maxClips; i++) {
//
// make sure you leave the targeted one alone (not strictly necessary)
if (i != _root.thisWindow) {
//
// shut the clip down
eval(&quot;_root.window&quot;+i).gotoAndPlay(&quot;close&quot;);
}
}
//
// start the selected clip
eval(&quot;_root.window&quot;+_root.thisWindow).gotoAndPlay(&quot;start&quot;);
//
// clear the variable so that you don't keep sending the clip to the start
_root.thisWindow = &quot;&quot;;
}


Since you're sending each clip to a frame label you could actually use this script to start multiple clips too.

Sledgehammer to crack a nut but I was bored...
 
As a matter of small detail...

on (press) {
_root.window3.gotoAndPlay(&quot;29&quot;);
_root.window1.gotoAndPlay(&quot;29&quot;);
_root.window2.gotoAndPlay(&quot;2&quot;);
}

You don't need the &quot;&quot;s when targeting a frame number. You should only use them when targeting a label. I'll work... But once again, respecting some standards will help when debugging!

Regards,
mywink.gif
ldnewbie
 
While we're at it... And if you still want constructive criticism...
You should add a script like that to all your buttons (still not working from mission to members), and also provide a way to stop that button from re-opening the window when it's already opened... Sort of like the channels thing in your TV setup, remember?

You should also add a first blank keyframe to your preloader (with a script in it!), to avoid seeing a flash frame of the preloader at 100%, on subsequent visits to the site.

Regards,
mywink.gif
ldnewbie
 
just got in from work...wangbar your insane :).. must be nice to have all that knowledge..oldnewbie..first off i'm not done with those windows yet..not enough time in the day to help myself learn, my friends at school ( building their site), promaintenance, kids, wife, all those things..so if i seem to be dragging please bare with me..the other windows will be done soon..what script would i add to the pre-loader?..and as far as the button opening twice..what do you suggest?..

You don't need the &quot;&quot;s when targeting a frame number. You should only use them when targeting a label. I'll work... But once again, respecting some standards will help when debugging!

dude why are you giving me such a hard time about respecting standards?..i never claim to be as informed as some of you guys..but if your pushing to make me a darn flash guru..your doing a good job..i'm learning about 8 programs all at once, so if the &quot;&quot;s are out of place please cut me some slack..

thanks guys for your help and suggestions!!
e.gif


carlsatterwhite@endangeredgraphics.com
 
For the preloader...
Something along these lines...

On an empty keyframe (the first one in your preloader scene , add one if you need to, with no bar mc or graphics of any sort), add the following script:

if (_root.getBytesLoaded() >= _root.getBytesTotal()) {
_root.gotoAndPlay (&quot;site&quot;);
}

Adapt this gotoAndPlay action to the similar line you have in the actual preloader... Targeting a scene name & frame or a labeled frame, as I did here.
Also make sure this script is on a layer that is first in the LOAD ORDER under the Flash Publish settings. Either Bottom up or Top down according to where the layer is positioned.

---------------------------------

To keep the buttons from re-opening the windows when already opened, something along these lines:

Set up a variable at the beginning of your movie like:
_root.currentselect=&quot;none&quot;;

...And then change your buttons' scripts this way:

on (press) {
if (_root.currentselect==&quot;members&quot;) {
stop ();
} else {
_root.currentselect=&quot;members&quot;;
yourpresentscriptmc.gotoAndPlay(2);
}
}


Regards,

mywink.gif
ldnewbie
 
thanks.............
e.gif


carlsatterwhite@endangeredgraphics.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top