# Dynamic Loading

**URL:** <https://forum.kirupa.com/t/dynamic-loading/26905>\
**Category:** flash\
**Created:** [July 28, 2003, 4:26am UTC](https://forum.kirupa.com/t/dynamic-loading/26905 "2003-07-28T04:26:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjaini](https://avatars.discourse-cdn.com/v4/letter/r/ecd19e/32.png) [@rjaini](https://forum.kirupa.com/u/rjaini)\
**Post date:** [July 28, 2003, 4:26am UTC](https://forum.kirupa.com/t/dynamic-loading/26905/1 "2003-07-28T04:26:09Z")

</div>

I have this code here… and it seems to work until I try to tell it to listen to the buttons [instances named ‘back’ and ‘next’]. And, of course, without the images being able to being viewed… it’s just a super fancy way of getting one image to fade in. The error message is:

~–~--~–~--~–~--~  
[COLOR=orangered]Scene=Scene 1, Layer=action, Frame=1: Line 6: ‘{’ expected  
next.onPress = function()

Scene=Scene 1, Layer=action, Frame=1: Line 56: Syntax error.  
}[/COLOR]  
~–~--~–~--~–~--~

Line 56 is the very last line… I’ve been looking at it too long to figure it out anymore.

Any help would be much appreciated.

~–~--~–~--~–~--~–~--~–~--~–~  
[COLOR=orangered]  
square.\_alpha=0;  
i.e. alpha=0  
mypic=1;

\_root.onEnterFrame = function() // \_root main movie timeline, when movie starts call function  
next.onPress = function()  
{  
if (mypic \< 10 && !fadeIn && !fadeOut)  
{  
fadeOut=true;  
mypic++;  
}  
if (mypic \>= 10)  
{  
mypic=1;  
}  
}

back.onPress = function()  
{  
if (mypic \> 1 && !fadeIn && !fadeOut)  
{  
fadeOut = true;  
mypic–;  
}  
if (mypic == 1 && !fadeIn && !fadeOut) // if image is on 1 go to the last image in series  
{  
fadeOut=true;  
mypic=10;  
}  
}  
{  
if (square.\_alpha \<10)  
{  
loadMovie(“images/image”+mypic+".jpg", “square”)  
fadeOut=false;  
fadeIn=true;  
}

if (square.\_alpha \> 10 && fadeOut)  
{  
square.\_alpha -= 10;  
}

if (square.\_alpha \< 100 && fadeIn && !fadeOut)  
{  
square.\_alpha += 10;  
}  
else  
{  
fadeIn=false;  
}

}  
[/COLOR]  
~–~--~–~--~–~--~–~--~–~--~–~

Thank you muchly!!! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 28, 2003, 4:35am UTC](https://forum.kirupa.com/t/dynamic-loading/26905/2 "2003-07-28T04:35:54Z")

</div>

i think i figured itout change your script to  
[AS]  
square.\_alpha=0;  
i.e. alpha=0  
mypic=1;

\_root.onEnterFrame = function() { // \_root main movie timeline, when movie starts call function  
next.onPress = function()  
{  
if (mypic \< 10 && !fadeIn && !fadeOut)  
{  
fadeOut=true;  
mypic++;  
}  
if (mypic \>= 10)  
{  
mypic=1;  
}  
}

back.onPress = function()  
{  
if (mypic \> 1 && !fadeIn && !fadeOut)  
{  
fadeOut = true;  
mypic–;  
}  
if (mypic == 1 && !fadeIn && !fadeOut) // if image is on 1 go to the last image in series  
{  
fadeOut=true;  
mypic=10;  
}  
}  
{  
if (square.\_alpha \<10)  
{  
loadMovie(“images/image”+mypic+".jpg", “square”)  
fadeOut=false;  
fadeIn=true;  
}

if (square.\_alpha \> 10 && fadeOut)  
{  
square.\_alpha -= 10;  
}

if (square.\_alpha \< 100 && fadeIn && !fadeOut)  
{  
square.\_alpha += 10;  
}  
else  
{  
fadeIn=false;  
}  
}  
}  
[/AS]  
basiacally in the line  
[AS]  
\_root.onEnterFrame = function() // \_root main movie timeline, when movie starts call function  
[/AS]

yoou need a { after function() and at the very end youll need one more }

hope that helps (-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 28, 2003, 4:26pm UTC](https://forum.kirupa.com/t/dynamic-loading/26905/3 "2003-07-28T16:26:46Z")

</div>

:thumb: Tis muchly appreciated.

* * *

One more question, though… is there anything in there that would make the script not work? There are no more error messages, but the other images never load.

Any [more] help would be great!

Thank you!
