View Full Version : "else if" within an function?
mrsam
02-10-2009, 01:01 PM
I'm currently running a videoplayer and whenever the loaded videoclip ends, im setting a var endClip.Boolean = true;
// Start of AS code
var endClip:Boolean = false;
// Videoclip ends
else if(e.info.code == "NetStream.Play.Stop") {
var endClip:Boolean = true;
}
Further down in my AS code i'm trying to set buttons_mc.visible as true/false depending on my endClip var.
// Function -------------------------------------------/
function buttonFadeUp(e:Event):void
{
if(endClip == false) {
buttons_mc.visible = false;
buttons_mc.alpha = 0;
} else if(endClip == true) {
buttons_mc.visible = true;
buttons_mc.alpha = 1;
}
}
However my "if and else if" within my function, doesn't seem to work. Am I doing anything wrong in this setup?
lordofduct
02-10-2009, 01:07 PM
why would you have to change the alpha if you're making it not visible???
also, you could just say:
function buttonFadeUp(e:Event):void
{
buttons_mc.visible = endClip;
}
instead
also why is this standing alone??
else if(e.info.code == "NetStream.Play.Stop") {
var endClip:Boolean = true;
}
is there an if to go with that?
Oh and try tracing "endClip" at the function... is it even getting changed? I have noticed sometimes on the timeline (I hate the timeline very unpredictable) that when a frame resets the initial declaration for a variable resets.
Mazoonist
02-10-2009, 01:49 PM
If endClip is defined, don't define it again. Only use the var keyword once. Otherwise it's not the same variable, you are making a new one.
lordofduct
02-10-2009, 01:58 PM
If endClip is defined, don't define it again. Only use the var keyword once. Otherwise it's not the same variable, you are making a new one.
heh, I didn't notice he said "var endClip" in that function...
durrrr
hand me my Mountain Dew
mrsam
02-10-2009, 06:20 PM
why would you have to change the alpha if you're making it not visible???
Guess I was just being sloopy, I was using the alpha for a courina tween , but decided to drop it - so should have removed it :)
also, you could just say:
function buttonFadeUp(e:Event):void
{
buttons_mc.visible = endClip;
}
Thx
instead
also why is this standing alone??
else if(e.info.code == "NetStream.Play.Stop") {
var endClip:Boolean = true;
}
is there an if to go with that?
There is an "if" before that, it was taken out of context, so you didnt have to see all the other code :)
If endClip is defined, don't define it again. Only use the var keyword once. Otherwise it's not the same variable, you are making a new one.
How would I go about re-defining the boolean then? Just by doing endClip = true/false; then? But guess that would explain why endClip didnt change within my function - simply because I defined it again with - var endClip?
mrsam
02-11-2009, 08:39 AM
How would I go about re-defining the boolean then? Just by doing endClip = true/false; then?
Just to answer my own question, yes that's how you would go about that :) . Got it working as I wanted now :) .. Thanks for the responses..
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.