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!

variables and visibility

Status
Not open for further replies.

struth

Programmer
Aug 26, 2001
114
GB
In flash 5

I have the movie clips a,b,c. These are made visible by separate button actions (which fine I can do).

Problem: I want each button to check if the other movie clips are already visible and if they are (and only if they are) I want movie clip D to play.

I've worked out that the solution is probably something like (using button controlling a):

on (press) {
setProperty (_root.a,_visible,true)
}
on (release){
"b_v" = GetProperty (b._visible);"
"c_v" =GetProperty (c._visible)"
"v_all" = "a_v+b_v+c_v";
If (v_all,_ visible)==true {
TellTarget (_root.d)
Play()
}
}

At the moment, D is playing regardless of the visibility of the other movie clips.

Grateful for any assistance
 
HI

A fairly simple way of checking would be to use a control mc to monitor the situation....

First put the actions on your buttons to make each relevant movie-clip visible, but also add an incremented variable:

on(release){
_root.a._visible=1;
/:total++;
}


Repeat these actions on the rest of your buttons, changing only the target instance (in blue above).

Now, press Ctrl+F8 to create a new movie-clip symbol. Drag a copy of this from the library onto the main stage. Right click the circle (which appears as the empty movie-clip) and select Actions. Insert the following:

onClipEvent (enterframe){
if (/:total>1){
_root.D.play();
}
}


Where 'D' is the instance name of the movie-clip you want to play when two movie-clips are visible.

Hope this has helped.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
ps: If you use actions elsewhere to make the visibility of a movie-clip '0', just add /:total--immediately after to decrement the control value.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Right Dave, get the idea, many thanks. I'll try it out now and get back to you.

As a total aside, there are loads of books out there on Flash 5 but as someone who is definitely a flash guru are there any you would recommend? I really have only been tackling flash for a few days and though it hasn't changed my life, it sure has made it more fun and I want to know more.

Thanks again
 
That's a common question in the forum, but my answer is always the same. I only have two books, one I bought about 6 months ago called New Masters of Flash (around £50UK) and the other a couple of weeks ago called Server-Side Flash (around £40UK).

I never bought any 'beginner' or 'Teach-yourself' books because they just duplicate what you get with the Manual (which is a carbon copy of the Help Files). I also think many people do themselves out of a lot of healthy brainwork by simply following a 'learner' book chapter by chapter, in many cases being led up a particularly boring garden-path, if you know what I mean.

My own personal recommendation, as I have always said, is to set yourself targets and figure them out, either by brain-work or leg-work. You won't learn a great deal simply by reading a recipe, because at the end of the recipe you'll only know how to bake one cake. What you have to do is make up your own recipes and try to be as creative and challenging as possible. Easier said than done in a lot of cases, but I'll always stick by it.

Anyway, be careful when you buy a book, you could be throwing your money away.

Bye for now.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Tried it but I'm afraid this just isn't quite working. I read up as best I could off the net about the event clip handler and I see the logic (I have actually 7 clips now so I even increased it to 'total>6' but to no avail. I know its close.

Hear what you're saying about the books too.

You enjoying the festival up there or does the annual invasion drive you nuts?

 
email me a zipped fla if you like Struth. Let me know the buttons which create visibility, the movieclips involved, and the number of movie-clips which need to be visible for "D" to activate/play.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Thanks Dave but I'm pleased to report that this particular nut has been cracked. I have to say your way seemed sweeter and simpler but on another forum someone helped me out with:
Placed on each button:

on (release) {
if (_root.a._visible == true && _root.b._visible == true &&
_root.c._visible == true) {
_root.d.play();
}
}

Which again I could't get working until I thought back to what you had brought my attention to namely 'onClipEvent'. I had embedded the visibility (0/false) in the first frame of each clip but when I changed this to

onClipEvent (load) {
setProperty (_root.a, _visible, false);
}

Shazamm! it all burst into life. I now suspect that this probably is what I needed to do for your solution to work.

So thanks again for your assistance, very much appreciated.

Struth

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top