News:

If you need instructions on how to get through the hotels, check out the enclosed instruction book.

Main Menu

ActionScript3 - Multiple Boolean Conditional Statement

Farted by CaramelAppleClock, December 09, 2014, 04:14:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CaramelAppleClock

I need help with a few lines of code I'm working for a commission.

Basically I have 10 movie clips that are invisible at the start. After they are all visible I want to do a gotoAndStop command. My current code is

if (med.visible && epa.visible && elg.visible && lig.visible && gov.visible && cst.visible && smt.visible && shr.visible && construction.visible && loc_com.visible){
gotoAndStop(2);
}


I don't get any errors, but the gotoAndStop doesn't initiate when all movie clips are visible.

Any thoughts?

CaramelAppleClock

Ok so I found a fix, took me a while though. I hoped to avoid using them cause I am a total sock at ActionScript, but apparently it was necessary to use an Array to clump together all those movie clips.

If anyone will ever encounter a similar issue, like having to use a multiple conditional for visible/invisbile objects, the code below goes before what I posted previously.

var answers:Array = new Array (med, epa, elg, lig, gov, cst, smt, shr, construction, loc_com);    
this.addEventListener (Event.ENTER_FRAME, multipleif)

    function multipleif(e:Event):void {

PhantomCatClock

If that's your entire code, it's only called once, the second the movie runs. So right now, what's happening (with the code in your first post, that is,) is

Frame one:
is all those niggas visible? Naw. Do nothing.

Frame two, three, four...:
nothing, man. I already did my script.



and you want ._visible, not .visible

CaramelAppleClock

I do have some event listeners for buttons that toggle those movie clips' visibility on and off. However, the whole timeline is only 2 frames long.

Btw what does ._visible offer in favor of .visible?

PhantomCatClock

Oh, whoops, it's ._visible in AS2. Just .visible in AS3. Weird they'd change that, since it's still an instance variable


ANYWAY, yeah, that event handler just makes the whole thing loop every frame, which is good (the following is completely unnecessary, but you could add a line to remove that listener after the gotoAndStop




Your thing is right, right now, but just so it's easier to understand in the future, your timeline IS only two KEYframes long, but that script is being called every FRAME. Y'allknowhowitis.