Flash AS3 help - Error

Hey guys,

Sorry if this is been answered 1000 times before but I keep getting this message whenever I test my movie… I’ve googled it so many times and I still can’t figure it out.

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at Main()

at site()

at flashsitecopy_fla::wholeSite_1/frame1()

I’ve used a tutorial on dynamic websites and another tutorial from Computer Arts magazine.

Main is an external Base class file

and site is the movie clip I’m trying to add to my website

This is from Main.as

package

{

import caurina.transitions.Tweener;

import caurina.transitions.properties.*;


import flash.display.*;

import flash.events.*;

import flash.filters.BitmapFilterQuality;

import flash.filters.BlurFilter;




public class Main extends MovieClip

{

// This is the list of the photo's z and x positions, the parallax damp, image, depth and t-shirt name.

// This can be easily changed so this data is XML driven.

private var arrPhotos:Array = new Array({zPos:500,	xPos:-500,	damp:7, image:image1,	depth:0, tee:""},

{zPos:700,	xPos:300,	damp:8, image:image2,	depth:1,	tee:""},

{zPos:500,	xPos:600,	damp:6, image:image3,	depth:2,	tee:""},

{zPos:300,	xPos:-50,	damp:4, image:image4,	depth:3,	tee:""});


private var photoYpos = -320; // The y position of each photo.

private var bgDamp:Number = 20; // The parallax damp for the background.

private var picPush:Number = 5; // The z depth of each photo when it's rolled over.

private var blurAmount:Number = 7; // The blur amount of the remaining items when a photo is selected.

private var currPhoto:MovieClip; // The current selected photo.

private var currPhotoNum:Number; // The number of the current selected photo.

private var photoHolder:MovieClip = new MovieClip(); // The clip that holds the photos.

private var closeBtn:closebtn;




function Main(){

stage.quality = StageQuality.HIGH;


addChild(photoHolder);


FilterShortcuts.init();


initStage();

}





// ***** INITIALIZE FUNCTIONS *****


private function initStage():void

{

for(var i:uint = 0; i < arrPhotos.length; i++){

var photoMC:photo = new photo();

arrPhotos*.clip = photoMC;

photoMC.name = "p" + i;

photoMC.z = arrPhotos*.zPos;

photoMC.x = arrPhotos*.xPos;

photoMC.y = photoYpos;


photoMC.p_mc.txt.text = arrPhotos*.tee;


var bmap:Bitmap = new Bitmap( new arrPhotos*.image(0,0) );

photoMC.p_mc.image_mc.addChild(bmap);


var btn:MovieClip = photoMC.area_mc;

initBtn(btn);

btn.addEventListener(MouseEvent.ROLL_OVER, picRoll);

btn.addEventListener(MouseEvent.ROLL_OUT, picOut);

btn.addEventListener(MouseEvent.CLICK, picClick);


photoHolder.addChild(photoMC);

}


startParallax();

}





// ***** PARALLAX FUNCTIONS *****


private function initBtn(btn:MovieClip):void

{

btn.useHandCursor = true;

btn.buttonMode = true;

}



private function startParallax():void

{

stage.addEventListener(MouseEvent.MOUSE_MOVE, trackMouse);

}



private function stopParallax():void

{

stage.removeEventListener(MouseEvent.MOUSE_MOVE, trackMouse);

trace("hello");

}



private function trackMouse(evt:Event):void

{

var mousePos:Number = stage.mouseX;

moveItem(bg_mc, 0 - (mousePos / bgDamp));


for(var i:uint = 0; i < arrPhotos.length; i++){

var photo:MovieClip = arrPhotos*.clip;

moveItem(photo, arrPhotos*.xPos - (mousePos / arrPhotos*.damp));

}

}






// ***** PHOTO FUNCTIONS *****


private function picRoll(evt:Event):void

{

var mc:MovieClip = evt.target.parent.p_mc;

twistItem(mc, picPush, 0);

}




private function picOut(evt:Event):void

{

var mc:MovieClip = evt.target.parent.p_mc;

twistItem(mc, 0, 0);

}




private function picClick(evt:Event):void

{

stopParallax();

enableBtns(false);


currPhoto = evt.target.parent;

currPhotoNum = Number(currPhoto.name.substr(1));


photoHolder.setChildIndex(currPhoto, arrPhotos.length - 1);


blurItems(blurAmount);


Tweener.addTween(currPhoto,{rotationX:0, z:-50, x:0, time:0.5, transition:"easeInOutSine", onComplete:initClose});

}



private function enableBtns(e:Boolean):void

{

for(var i:uint = 0; i < arrPhotos.length; i++){

var btn:MovieClip = arrPhotos*.clip.area_mc;

btn.mouseEnabled = e;

}

}






// ***** MOVE FUNCTIONS *****


private function moveItem(mc:MovieClip, xpos:Number):void

{

Tweener.addTween(mc,{x:xpos, time:1, transition:"easeOutBack"});

}



private function twistItem(mc:MovieClip, rX:Number, rY:Number):void

{

Tweener.addTween(mc,{rotationX:rX, rotationY:rY, time:0.5, transition:"easeOutBack"});

}



private function twistPhoto(evt:Event):void

{

twistItem(currPhoto, 0, currPhoto.mouseX / 50);

}




private function blurItems(amount:Number):void

{

blurItem(bg_mc, amount);


for(var i:uint = 0; i < arrPhotos.length; i++){

var photo:MovieClip = arrPhotos*.clip;


if(photo != currPhoto){

blurItem(photo, amount);

}

}

}



private function blurItem(mc:MovieClip, amount:Number):void

{

var blur:BlurFilter = new BlurFilter();

blur.blurX = amount;

blur.blurY = amount;

blur.quality = BitmapFilterQuality.LOW;

mc.filters = [blur];

}





// ***** SLECTED FUNCTIONS *****


private function initClose():void

{

stage.addEventListener(MouseEvent.MOUSE_MOVE, twistPhoto);


closeBtn = new closebtn();

closeBtn.x = -160;

closeBtn.y = 775;

initBtn(closeBtn);

closeBtn.addEventListener(MouseEvent.CLICK, removeDetails);

currPhoto.p_mc.addChild(closeBtn);

}



private function removeDetails(evt:Event):void

{

currPhoto.p_mc.removeChildAt(numChildren);


stage.removeEventListener(MouseEvent.MOUSE_MOVE, twistPhoto);


currPhoto.rotationY = 0;

blurItems(0);


Tweener.addTween(currPhoto,{rotationX:0, z:arrPhotos[currPhotoNum].zPos, x:arrPhotos[currPhotoNum].xPos, time:0.3, transition:"easeOutSine", onComplete:startAgain});


photoHolder.setChildIndex(currPhoto, arrPhotos[currPhotoNum].depth);

}



private function startAgain():void

{

startParallax();

enableBtns(true);

}


}

}


and this is from frame1 on the timeline


stop ();


import fl.transitions.*;

import fl.transitions.easing.*;

// tween the main menu into place upon opening

var moveTween:Tween = new Tween(mainmenu_mc, "y", Elastic.easeOut, mainmenu_mc.y, 580, 2, true);

// claim MCs from library to use on stage when needed using addChild

var p1:site = new site;

var p2:page2 = new page2;

var p3:page3 = new page3;

var p4:page4 = new page4;

var p5:page5 = new page5;


pageContainer_mc.addChild(p1);

var pageMoveTween:Tween = new Tween(pageContainer_mc, "y", Elastic.easeOut, 0, 0, 2, true);


mainmenu_mc.menuBtn1_btn.addEventListener(MouseEvent.CLICK, btn1Click);

mainmenu_mc.menuBtn2_btn.addEventListener(MouseEvent.CLICK, btn2Click);

mainmenu_mc.menuBtn3_btn.addEventListener(MouseEvent.CLICK, btn3Click);

mainmenu_mc.menuBtn4_btn.addEventListener(MouseEvent.CLICK, btn4Click);

mainmenu_mc.menuBtn5_btn.addEventListener(MouseEvent.CLICK, btn5Click);


function btn1Click (event:MouseEvent):void {


var btn1Outro:Tween = new Tween(pageContainer_mc, "alpha", Strong.easeOut, 1, 0, 1, true);

btn1Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn1Transition);

function runBtn1Transition (event:TweenEvent):void {

pageContainer_mc.removeChildAt(1);

pageContainer_mc.addChild(p1);

var btn1Intro:Tween = new Tween(pageContainer_mc, "alpha", Strong.easeOut, 0, 1, 1, true);

}

}

function btn2Click (event:MouseEvent):void {


var btn2Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true);

btn2Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn2Transition);

function runBtn2Transition (event:TweenEvent):void {

pageContainer_mc.removeChildAt(1);

pageContainer_mc.addChild(p2);

var btn2Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true);

}

}

function btn3Click (event:MouseEvent):void {


var btn3Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true);

btn3Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn3Transition);

function runBtn3Transition (event:TweenEvent):void {

pageContainer_mc.removeChildAt(1);

pageContainer_mc.addChild(p3);

var btn3Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true);

}

}

function btn4Click (event:MouseEvent):void {


var btn4Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true);

btn4Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn4Transition);

function runBtn4Transition (event:TweenEvent):void {

pageContainer_mc.removeChildAt(1);

pageContainer_mc.addChild(p4);

var btn4Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true);

}

}

function btn5Click (event:MouseEvent):void {


var btn5Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true);

btn5Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn5Transition);

function runBtn5Transition (event:TweenEvent):void {

pageContainer_mc.removeChildAt(1);

pageContainer_mc.addChild(p5);

var btn5Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true);

}

}

if you could tell me what I’m doing wrong or how to fix it that would be awesome.

  • Tish