Clock Crew

Community => Flash & Flash Accessories => Topic started by: CaramelAppleClock on December 09, 2014, 04:14:40 PM

Title: ActionScript3 - Multiple Boolean Conditional Statement
Post by: CaramelAppleClock on December 09, 2014, 04:14:40 PM
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

Code: [Select]
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?
Title: ActionScript3 - Multiple Boolean Conditional Statement
Post by: CaramelAppleClock on December 09, 2014, 05:03:43 PM
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.

Code: [Select]
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 {
Title: ActionScript3 - Multiple Boolean Conditional Statement
Post by: PhantomCatClock on December 09, 2014, 10:05:46 PM
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
Title: ActionScript3 - Multiple Boolean Conditional Statement
Post by: CaramelAppleClock on December 10, 2014, 08:14:31 AM
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?
Title: ActionScript3 - Multiple Boolean Conditional Statement
Post by: PhantomCatClock on December 10, 2014, 11:42:50 AM
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.