# Statement must appear within on/onClipEvent handler

**URL:** https://forum.kirupa.com/t/statement-must-appear-within-on-onclipevent-handler/252620
**Category:** Uncategorized
**Created:** [February 21, 2008, 7:34pm UTC](https://forum.kirupa.com/t/statement-must-appear-within-on-onclipevent-handler/252620 "2008-02-21T19:34:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![fatboy202](https://avatars.discourse-cdn.com/v4/letter/f/7ba0ec/32.png) [@fatboy202](https://forum.kirupa.com/u/fatboy202)
#### Post date: [February 21, 2008, 7:34pm UTC](https://forum.kirupa.com/t/statement-must-appear-within-on-onclipevent-handler/252620/1 "2008-02-21T19:34:35Z")

</div>

Hi Guys, I’m creating a site with a vertical scroll xml photo gallery. When i run it I get the following errors would anyone be able to help

> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 2: Statement must appear within on/onClipEvent handler  
> function loadXML(loaded){  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 20: Statement must appear within on/onClipEvent handler  
> xmlData = new XML();  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 21: Statement must appear within on/onClipEvent handler  
> xmlData.ignoreWhite = true;  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 22: Statement must appear within on/onClipEvent handler  
> xmlData.onLoad = loadXML;  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 23: Statement must appear within on/onClipEvent handler  
> xmlData.load(“images.xml”);  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 26: Statement must appear within on/onClipEvent handler  
> previous\_btn.onRelease = function(){  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 29: Statement must appear within on/onClipEvent handler  
> next\_btn.onRelease = function (){  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 34: Statement must appear within on/onClipEvent handler  
> p=0  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 35: Statement must appear within on/onClipEvent handler  
> this.onEnterFrame = function(){  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 48: Statement must appear within on/onClipEvent handler  
> function nextImage(){  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 59: Statement must appear within on/onClipEvent handler  
> function prevImage(){  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 68: Statement must appear within on/onClipEvent handler  
> function firstImage(){  
> **Error** Scene=Scene 1, layer=preloader, frame=1:Line 76: Statement must appear within on/onClipEvent handler  
> function picture\_num(){

My Code is

> 

function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = ;  
description = ;  
thumbnails = ;  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
thumbnails\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
thumbnails\_fn(i);  
}  
firstImage();  
} else {  
content = “file not loaded!”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images.xml”);  
//Preloader  
p = 0;  
this.onEnterFrame = function() {  
filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {  
preloader.preload\_bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;  
if (picture.\_alpha\<100) {  
picture.\_alpha += 10;  
}  
}  
};  
//nextimage function  
function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
}  
}  
}  
//Previous Image funtion  
function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[1], 1);  
desc\_txt.text = description[0];  
picture\_num();  
}  
}  
function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
}  
function thumbNailScroller() {

```
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 7;
tscroller.onEnterFrame = function() {
    if ((_root._xmouse &gt;= thumbnail_mc._x ) && (_root._xmouse &lt;= thumbnail_mc._x + thumbnail_mc._width)) {
        if ((_root._ymouse&gt;=(hit_down._y - 20)) && (thumbnail_mc.hitTest(hit_down))) {
            thumbnail_mc._y -= scroll_speed;
        } else if ((_root._ymouse&lt;= 120) && (thumbnail_mc.hitTest(hit_up))) {
            thumbnail_mc._y += scroll_speed;
        }
    } else {
        delete tscroller.onEnterFrame;
    }
};

```

}  
function thumbnails\_fn(k) {  
thumbnail\_mc.createEmptyMovieClip(“t”+k, thumbnail\_mc.getNextHighestDepth());  
tlistener = new Object();  
tlistener.onLoadInit = function(target\_mc) {  
target\_mc.\_y =(target\_mc.\_height + 2)\*k;  
target\_mc.pictureValue = k;  
target\_mc.onRelease = function() {  
p = this.pictureValue-1;  
nextImage();  
};  
target\_mc.onRollOver = function() {  
this.\_alpha = 50;  
thumbNailScroller();  
};  
target\_mc.onRollOut = function() {  
this.\_alpha = 100;  
};  
};  
image\_mcl = new MovieClipLoader();  
image\_mcl.addListener(tlistener);  
image\_mcl.loadClip(thumbnails[k], “thumbnail\_mc.t”+k);  
}

It would be awesome if someone could help me out thanks:p:
