# PreLoader - ActionScript

**URL:** <https://forum.kirupa.com/t/preloader-actionscript/64146>\
**Category:** flash\
**Created:** [September 13, 2004, 5:35pm UTC](https://forum.kirupa.com/t/preloader-actionscript/64146 "2004-09-13T17:35:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChaoticGood](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@ChaoticGood](https://forum.kirupa.com/u/ChaoticGood)\
**Post date:** [September 13, 2004, 5:35pm UTC](https://forum.kirupa.com/t/preloader-actionscript/64146/1 "2004-09-13T17:35:53Z")

</div>

Greetings.

I know there are many ways to program a preloaded. I just happened to choose the most difficult for a person just learning actionscript. I used the tutorial from [netmag.co.uk](http://netmag.co.uk) and am receiving 4 errors on output - unexpected “if” encountered, unexpected “else” encountered, Line 14: ‘)’ or ‘,’ expected and ine 15: Syntax error.

Here is the script in question -

//find out how much data has loaded  
count=int(\_root.getBytesLoaded()/1024)+“KB”;  
total=int(\_root.getBytesTotal()/1024)+“KB”;  
percentage=int(\_root.getBytesLoaded()/\_root.getBytesTotal()\*100+"%",  
status=“Loading…”,  
//set the x scale of the loadbar  
loadbar\_size=int(\_root.getBytesLoaded()/\_root.getBytesTotal()\*100),  
setProperty(“loadbar”,\_xscale,loadbar\_size),  
//check if all data is loaded  
if(\_root.getBytesLoaded()=\_root.getBytesTotal()) {gotoAndPlay(“darksite”),  
else {  
percentage=“100%”,  
status = “Loaded”,  
setProperty("loadbar, \_xscale, “100”),  
gotoAndPlay (“darksite”,1);  
}  
Any help is much appreciated.

Thanks,  
ChaoticGood.

---

<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:** [September 13, 2004, 7:46pm UTC](https://forum.kirupa.com/t/preloader-actionscript/64146/2 "2004-09-13T19:46:26Z")

</div>

Ok, managed to clear up the Line 14 error and the sytax error on Line 15. Still having trouble with the “unexpected ‘if’” and “unexpected ‘else’” errors.

Any help is greatly appreciated.

Best,  
CG

---

<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:** [September 13, 2004, 10:12pm UTC](https://forum.kirupa.com/t/preloader-actionscript/64146/3 "2004-09-13T22:12:06Z")

</div>

OK, i’m realy nuub to AS, but i’ve “cleaned up” some of it… but i still get

[COLOR=Red] **Error** Scene=Scene 1, layer=AS, frame=1:Line 14: Property name expected in GetProperty.  
setProperty(“loadbar”,"\_xscale",“100”);[/COLOR]

count=int(\_root.getBytesLoaded()/1024)+“KB”;  
total=int(\_root.getBytesTotal()/1024)+“KB”;  
percentage=int(\_root.getBytesLoaded()/\_root.getBytesTotal())\*100+"%";  
status=“Loading…”;  
//set the x scale of the loadbar  
loadbar\_size=int(\_root.getBytesLoaded()/\_root.getBytesTotal()\*100);  
setProperty(“loadbar”,\_xscale,loadbar\_size);  
//check if all data is loaded  
if(\_root.getBytesLoaded() == \_root.getBytesTotal()) {  
gotoAndPlay(“darksite”);  
} else {  
percentage=“100%”;  
status = “Loaded”;  
setProperty(“loadbar”,"\_xscale",“100”);  
gotoAndPlay (“darksite”,“1”);  
}

dunno if this helps… :h: … but i thought i’d give it a shoot 😊

---

<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:** [September 14, 2004, 12:41am UTC](https://forum.kirupa.com/t/preloader-actionscript/64146/4 "2004-09-14T00:41:05Z")

</div>

Try changing this…

```auto

setProperty("loadbar",_xscale,loadbar_size);

```

To this…

```auto

setProperty(" **_root.** loadbar",_xscale,loadbar_size);

```

If it still doesn’t work and you get really fed up, you can put "\_root."s in front of everything! This is the main thing that causes a lot of problems in Flash–forgetting "\_root"s and not referring to the appropriate timeline etc.

---

<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:** [September 14, 2004, 4:37am UTC](https://forum.kirupa.com/t/preloader-actionscript/64146/5 "2004-09-14T04:37:19Z")

</div>

Thanks gents. I will try both of your suggestions tomorrow when I get to work.

Best,  
CG
