Hey i have a movieClipLoader that loads a jpg into a empty movie clip created in AS. I want to have the picture appear after one second the first time the function is called while other things on the stage disappear, but after the first time this one second delay shouldn’t appear.
I decided to use a setInterval to get the one second delay, and this works when i dont make it only work on the first photo loaded, but as soon as i put it within an if statement the other things in the if statement work but the interval doesnt work.
This is the code that works, but has a delay on every image that is loaded:
[LEFT][COLOR=#993300]function[/COLOR] loadBigPicture[COLOR=#000000]([/COLOR]iValue:[COLOR=#993300]Number[/COLOR], firstTime:[COLOR=#993300]String[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]this[/COLOR].[COLOR=#993300]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]“myBigPicture”[/COLOR]+iValue, [COLOR=#993300]this[/COLOR].[COLOR=#993300]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];
tlistener = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Object[/COLOR]COLOR=#000000[/COLOR];
tlistener.[COLOR=#993300]onLoadProgress[/COLOR] = [COLOR=#993300]function[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]target[/COLOR], bytes_loaded, bytes_total[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]var[/COLOR] myLoaded = [COLOR=#993300]Math[/COLOR].[COLOR=#993300]floor[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR]iValue+[COLOR=#0000FF]" has loaded: "[/COLOR]+myLoaded[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR];
tlistener.[COLOR=#993300]onLoadInit[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
target_mc.[COLOR=#993300]_x[/COLOR] = centerOfImageX-target_mc.[COLOR=#993300]_width[/COLOR]/[COLOR=#000000]2[/COLOR];
target_mc.[COLOR=#993300]_y[/COLOR] = centerOfImageY-target_mc.[COLOR=#993300]_height[/COLOR]/[COLOR=#000000]2[/COLOR];
target_mc.[COLOR=#993300]_alpha[/COLOR] = [COLOR=#000000]0[/COLOR];
[COLOR=#993300]var[/COLOR] mypic = [COLOR=#993300]setInterval[/COLOR][COLOR=#000000]([/COLOR]brightenBigPic, [COLOR=#000000]1000[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]function[/COLOR] brightenBigPicCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
target_mc.[COLOR=#993300]_alpha[/COLOR] = [COLOR=#000000]100[/COLOR];
[COLOR=#993300]clearInterval[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR];
bigimage_mcl = [COLOR=#993300]new[/COLOR] [COLOR=#993300]MovieClipLoader[/COLOR]COLOR=#000000[/COLOR];
bigimage_mcl.[COLOR=#993300]addListener[/COLOR]COLOR=#000000[/COLOR];
bigimage_mcl.[COLOR=#993300]loadClip[/COLOR][COLOR=#000000]([/COLOR]imglocation[COLOR=#000000][[/COLOR]iValue[COLOR=#000000]][/COLOR], _level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]“myBigPicture”[/COLOR]+iValue[COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
And the code that doesnt make the first image ever show up, but when the function is called again it works fine:
[LEFT][COLOR=#993300]function[/COLOR] loadBigPicture[COLOR=#000000]([/COLOR]iValue:[COLOR=#993300]Number[/COLOR], firstTime:[COLOR=#993300]String[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]this[/COLOR].[COLOR=#993300]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]“myBigPicture”[/COLOR]+iValue, [COLOR=#993300]this[/COLOR].[COLOR=#993300]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];
tlistener = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Object[/COLOR]COLOR=#000000[/COLOR];
tlistener.[COLOR=#993300]onLoadProgress[/COLOR] = [COLOR=#993300]function[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]target[/COLOR], bytes_loaded, bytes_total[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]var[/COLOR] myLoaded = [COLOR=#993300]Math[/COLOR].[COLOR=#993300]floor[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR]iValue+[COLOR=#0000FF]" has loaded: "[/COLOR]+myLoaded[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR];
tlistener.[COLOR=#993300]onLoadInit[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
target_mc.[COLOR=#993300]_x[/COLOR] = centerOfImageX-target_mc.[COLOR=#993300]_width[/COLOR]/[COLOR=#000000]2[/COLOR];
target_mc.[COLOR=#993300]_y[/COLOR] = centerOfImageY-target_mc.[COLOR=#993300]_height[/COLOR]/[COLOR=#000000]2[/COLOR];
target_mc.[COLOR=#993300]_alpha[/COLOR] = [COLOR=#000000]0[/COLOR];
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]firstTime == [COLOR=#0000FF]“yes”[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]trace[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#993300]var[/COLOR] mypic = [COLOR=#993300]setInterval[/COLOR][COLOR=#000000]([/COLOR]brightenBigPic, [COLOR=#000000]1000[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]function[/COLOR] brightenBigPicCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
target_mc.[COLOR=#993300]_alpha[/COLOR] = [COLOR=#000000]100[/COLOR];
[COLOR=#993300]clearInterval[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
target_mc.[COLOR=#993300]_alpha[/COLOR] = [COLOR=#000000]100[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR];
bigimage_mcl = [COLOR=#993300]new[/COLOR] [COLOR=#993300]MovieClipLoader[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
bigimage_mcl.[COLOR=#993300]addListener[/COLOR][COLOR=#000000]([/COLOR]tlistener[COLOR=#000000])[/COLOR];
bigimage_mcl.[COLOR=#993300]loadClip[/COLOR][COLOR=#000000]([/COLOR]imglocation[COLOR=#000000][[/COLOR]iValue[COLOR=#000000]][/COLOR], _level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+iValue[COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
Any ideas on why the interval doesnt work when its put inside the if statement, on the 2nd, firstTime traces but the interval doesnt work.