# If statement not recognized?

**URL:** <https://forum.kirupa.com/t/if-statement-not-recognized/265419>\
**Category:** Uncategorized\
**Created:** [July 8, 2008, 6:33pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419 "2008-07-08T18:33:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bovine](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bovine](https://forum.kirupa.com/u/bovine)\
**Post date:** [July 8, 2008, 6:33pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419/1 "2008-07-08T18:33:54Z")

</div>

so i have this code for a video player i’m using

```auto

var listenerObject:Object = new Object();
listenerObject.stateChange = function(eventObject:Object):Void {
    if (eventObject.state == "buffering") {
    }
    if (eventObject.state == "playing") {
    }
    if (eventObject.state == "rewinding") {
    }
    if (eventObject.state == "paused") {
    }

};
myPlayer.volume = 100;
myPlayer.addEventListener("stateChange",listenerObject);

//myPlayer.contentPath=currentVideo;
myPlayer.bufferTime = 5;

_root.debug("PLAYING: "+currentVideo);

stop();

mTimer._visible = false;
setInterval(updateTime,500);
function updateTime() {
    cTime = formatTime(myPlayer.playheadTime);
    tTime = formatTime(myPlayer.totalTime);
    //trace("playhead time"+cTime);
    //trace("Total time" + formatTime(myPlayer.totalTime));
    if (cTime>5) {
        trace("TRUE");
        curtain.btnHandler();
    }
    if (myPlayer.totalTime>0) {// video must be loaded
        mTimer._visible = true;
    }
}

function formatTime(wTime) {
    fTime = "";
    if (!isNaN(wTime)) {
        mins = Math.floor(wTime/60);
        secs = Math.floor(wTime-(mins*60));
        fTime = addZero(mins)+":"+addZero(secs);
    }
    return fTime;
}

function addZero(wNum) {
    rNum = wNum;
    if (wNum<10) {
        rNum = "0"+wNum;
    }
    return rNum;
}

```

Everything works really well, i just want the if statment that says:

```auto

if (cTime>5) {
        trace("TRUE");
        curtain.btnHandler();
    }

```

to work and i can’t figure out why its not???

Thanks again for the help i get here.

---

<div class="post-metadata">

**Author:** ![wes\_design](https://avatars.discourse-cdn.com/v4/letter/w/ad7895/32.png) [@wes\_design](https://forum.kirupa.com/u/wes_design)\
**Post date:** [July 8, 2008, 6:40pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419/2 "2008-07-08T18:40:25Z")

</div>

maybe try using an else statement in there as well as trace the amount of cTime variable

```auto
if (cTime>5) {
        trace("TRUE");
        curtain.btnHandler();
    }else{
trace(cTime)};

```

---

<div class="post-metadata">

**Author:** ![bovine](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bovine](https://forum.kirupa.com/u/bovine)\
**Post date:** [July 8, 2008, 6:45pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419/3 "2008-07-08T18:45:56Z")

</div>

for some reason its going right to the else, even the the time on the video is greater than 5 seconds??

I’m perplexed?

---

<div class="post-metadata">

**Author:** ![wes\_design](https://avatars.discourse-cdn.com/v4/letter/w/ad7895/32.png) [@wes\_design](https://forum.kirupa.com/u/wes_design)\
**Post date:** [July 8, 2008, 6:50pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419/4 "2008-07-08T18:50:47Z")

</div>

declare

```auto
var cTime:Number = 20;myPlayer.volume = 100;

```

on the first line above “my player” and test it out I have a theory

---

<div class="post-metadata">

**Author:** ![bovine](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bovine](https://forum.kirupa.com/u/bovine)\
**Post date:** [July 8, 2008, 6:57pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419/5 "2008-07-08T18:57:01Z")

</div>

unfortunately, it didn’t do anything? your theory was?  
I’m starting to think it has to do with the format of the time, its not recognizing it as real numbers so my if statement doesn’t make any sense to it???

---

<div class="post-metadata">

**Author:** ![bovine](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bovine](https://forum.kirupa.com/u/bovine)\
**Post date:** [July 8, 2008, 6:59pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419/6 "2008-07-08T18:59:57Z")

</div>

yes, if i set a variable:  
playTime = myPlayer.playheadTime;  
then it will recognize it, it was the formating that screwed things up

---

<div class="post-metadata">

**Author:** ![wes\_design](https://avatars.discourse-cdn.com/v4/letter/w/ad7895/32.png) [@wes\_design](https://forum.kirupa.com/u/wes_design)\
**Post date:** [July 8, 2008, 7:06pm UTC](https://forum.kirupa.com/t/if-statement-not-recognized/265419/7 "2008-07-08T19:06:45Z")

</div>

^congrats
