# Arrays: Null object reference

**URL:** <https://forum.kirupa.com/t/arrays-null-object-reference/298968>\
**Category:** flash\
**Created:** [October 27, 2009, 8:10pm UTC](https://forum.kirupa.com/t/arrays-null-object-reference/298968 "2009-10-27T20:10:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nejuf](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@Nejuf](https://forum.kirupa.com/u/Nejuf)\
**Post date:** [October 27, 2009, 8:10pm UTC](https://forum.kirupa.com/t/arrays-null-object-reference/298968/1 "2009-10-27T20:10:43Z")

</div>

Hello

I’m trying to migrate a page turning animation from AS2 to AS3. The open source code is not my own, and I had started actionscript with AS3. With the below code, I get the error, “Error #1009: Cannot access a property or method of a null object reference.”

It seems to happen on the “pageOrder[page] = ename;” line. I thought that maybe the arrays disappeared when exiting the function, but even when I moved the array declarations outside the function, I still get the problem. I don’t know if the problem lies in its AS2 roots or my own misunderstanding of arrays. Any help would be appreciated, thanks.

function addPage(ename:String,tear:Boolean) { //defining pages… -------------------------------------------------------------------------------------------  
if(ename==“start”)  
{  
var pageOrder:Array = new Array();  
var pageCanTear:Array = new Array();  
page=0;  
ename=“blankpage”;  
}

```
if(ename=="end") {
    var maxpage:int = page-1;
    ename="blankpage";
}
if(tear == undefined)
{tear = false;}

pageOrder[page] = ename;
pageCanTear[page] = tear;

page = page + 1;

```

}
