1120: Access of undefined property itemPickup.
Help i cant work out what is wrong with this code. it has to be completed by tomorrow and i have spent too long trying to solve this problem.
we keep getting Access of undefined property itemPickup for all of the addEventListeners where itemPickup is used
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
public class Main extends MovieClip
{
var startPage:StartPage;
var secondPage:SecondPage;
var whatGenderPage:WhatGenderPage;
var draganddropPage:DragAndDropPage;
var mailingListPage:MailingListPage;
var orderformPage:OrderFormPage;
var lastPage:LastPage;
//clothes variables
var shirt1:Shirt1;
var shirt2:Shirt2;
var shirt3:Shirt3;
var jumpers1:Jumper1;
var jumpers2:Jumper2;
var jumpers3:Jumper3;
var skirts1:Skirts1;
var skirts2:Skirts2;
var skirts3:Skirts3;
var trousers1:Trousers1;
var trousers2:Trousers2;
var trousers3:Trousers3;
var tshirts1:Tshirts1;
var tshirts2:Tshirts2;
var tshirts3:Tshirts3;
var footwear1:Footwear1;
var footwear2:Footwear2;
var footwear3:Footwear3;
var _isDragging:Boolean;
public function Main()
{
startPage = new StartPage();
secondPage = new SecondPage();
whatGenderPage = new WhatGenderPage();
draganddropPage = new DragAndDropPage();
mailingListPage = new MailingListPage();
orderformPage = new OrderFormPage();
lastPage = new LastPage();
shirt1 = new Shirt1();
shirt2 = new Shirt2();
shirt3 = new Shirt3();
jumpers1 = new Jumper1();
jumpers2 = new Jumper2();
jumpers3 = new Jumper3();
skirts1 = new Skirts1();
skirts2 = new Skirts2();
skirts3 = new Skirts3();
trousers1 = new Trousers1();
trousers2 = new Trousers2();
trousers3 = new Trousers3();
tshirts1 = new Tshirts1();
tshirts2 = new Tshirts2();
tshirts3 = new Tshirts3();
footwear1 = new Footwear1();
footwear2 = new Footwear2();
footwear3 = new Footwear3();
_isDragging = false;
addChild(startPage);
//Add event listeners
startPage.startButton1.addEventListener(MouseEvent.CLICK,onStartButtonClick);
secondPage.nextArrow1.addEventListener(MouseEvent.CLICK,startWhatGenderPage);
whatGenderPage.previousArrow1.addEventListener(MouseEvent.CLICK,startSecondPage2);
whatGenderPage.nextArrow2.addEventListener(MouseEvent.CLICK,startDragAndDropPage);
draganddropPage.previousArrow2.addEventListener(MouseEvent.CLICK,startGenderPage2);
draganddropPage.nextArrow3.addEventListener(MouseEvent.CLICK,startMailingListPage);
mailingListPage.previousArrow3.addEventListener(MouseEvent.CLICK,startDragAndDropPage2);
mailingListPage.continueButton1.addEventListener(MouseEvent.CLICK,startOrderFormPage);
orderformPage.previousArrow4.addEventListener(MouseEvent.CLICK,startMailingListPage2);
//orderformPage.submitButton1.addEventListener(MouseEvent.CLICK,startLastPage);
//orderformPage.submitButton1.addEventListener(MouseEvent.CLICK,onSubmitClick);
//orderformPage.submitButton1.addEventListener(MouseEvent.CLICK,onSubmitButton1Click);
//Drag and drop listeners
draganddropPage.menuBar.stop();
draganddropPage.menuBar.shirtsButton2.addEventListener(MouseEvent.CLICK,showShirtsMenu);
draganddropPage.menuBar.jumpersButton2.addEventListener(MouseEvent.CLICK,showJumpersMenu);
draganddropPage.menuBar.tshirtsButton2.addEventListener(MouseEvent.CLICK,showTshirtsMenu);
draganddropPage.menuBar.trousersButton2.addEventListener(MouseEvent.CLICK,showTrousersMenu);
draganddropPage.menuBar.skirtsButton2.addEventListener(MouseEvent.CLICK,showSkirtsMenu);
draganddropPage.menuBar.footwearButton2.addEventListener(MouseEvent.CLICK,showFootwearMenu);
draganddropPage.menuBar.Shirt1.addEventListener(MouseEvent.CLICK,addShirt1);
draganddropPage.menuBar.shirt2.addEventListener(MouseEvent.CLICK,addShirt2);
draganddropPage.menuBar.shirt3.addEventListener(MouseEvent.CLICK,addShirt3);
draganddropPage.menuBar.jumpers1.addEventListener(MouseEvent.CLICK,addJumpers1);
draganddropPage.menuBar.jumpers2.addEventListener(MouseEvent.CLICK,addJumpers2);
draganddropPage.menuBar.jumpers3.addEventListener(MouseEvent.CLICK,addJumpers3);
}
//Event handlers
function onStartButtonClick(event:MouseEvent):void
{
addChild(secondPage);
removeChild(startPage);
}
function startSecondPage(event:MouseEvent):void
{
addChild(secondPage);
removeChild(startPage);
}
function startWhatGenderPage(event:MouseEvent):void
{
addChild(whatGenderPage);
removeChild(secondPage);
}
function startSecondPage2(event:MouseEvent):void
{
addChild(secondPage);
removeChild(whatGenderPage);
}
function startDragAndDropPage(event:MouseEvent):void
{
addChild(draganddropPage);
removeChild(whatGenderPage);
}
function startGenderPage2(event:MouseEvent):void
{
addChild(whatGenderPage);
removeChild(draganddropPage);
}
function startMailingListPage(event:MouseEvent):void
{
addChild(mailingListPage);
removeChild(draganddropPage);
}
function startDragAndDropPage2(event:MouseEvent):void
{
addChild(draganddropPage);
removeChild(mailingListPage);
}
function startOrderFormPage(event:MouseEvent):void
{
addChild(orderformPage);
removeChild(mailingListPage);
}
function startMailingListPage2(event:MouseEvent):void
{
addChild(mailingListPage);
removeChild(orderformPage);
}
function startLastPage(event:MouseEvent):void
{
addChild(lastPage);
removeChild(orderformPage);
}
//Drag and drop handlers
//Drag and drop handlers
function showShirtsMenu(event:MouseEvent):void
{
draganddropPage.menuBar.gotoAndStop(2);
}
function showJumpersMenu(event:MouseEvent):void
{
draganddropPage.menuBar.gotoAndStop(3);
}
function showTshirtsMenu(event:MouseEvent):void
{
draganddropPage.menuBar.gotoAndStop(4);
}
function showTrousersMenu(event:MouseEvent):void
{
draganddropPage.menuBar.gotoAndStop(5);
}
function showSkirtsMenu(event:MouseEvent):void
{
draganddropPage.menuBar.gotoAndStop(6);
}
function showFootwearMenu(event:MouseEvent):void
{
draganddropPage.menuBar.gotoAndStop(7);
}
function addShirt1(event:MouseEvent):void
{
addChild(shirt1);
shirt1.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addShirt2(event:MouseEvent):void
{
addChild(shirt2);
shirt2.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addShirt3(event:MouseEvent):void
{
addChild(shirt3);
shirt3.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addJumpers1(event:MouseEvent):void
{
addChild(jumpers1);
jumpers1.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addJumpers2(event:MouseEvent):void
{
addChild(jumpers2);
jumpers2.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addJumpers3(event:MouseEvent):void
{
addChild(jumpers3);
jumpers3.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addTshirts1(event:MouseEvent):void
{
addChild(tshirts1);
tshirts1.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addTshirts2(event:MouseEvent):void
{
addChild(tshirts2);
tshirts2.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addTshirts3(event:MouseEvent):void
{
addChild(tshirts3);
tshirts3.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addTrousers1(event:MouseEvent):void
{
addChild(trousers1);
trousers1.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addTrousers2(event:MouseEvent):void
{
addChild(trousers2);
trousers2.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addTrousers3(event:MouseEvent):void
{
addChild(trousers3);
trousers3.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addSkirts1(event:MouseEvent):void
{
addChild(skirts1);
skirts1.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addSkirts2(event:MouseEvent):void
{
addChild(skirts2);
skirts2.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addSkirts3(event:MouseEvent):void
{
addChild(skirts3);
skirts3.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addFootwear1(event:MouseEvent):void
{
addChild(footwear1);
footwear1.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addFootwear2(event:MouseEvent):void
{
addChild(footwear2);
footwear2.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function addFootwear3(event:MouseEvent):void
{
addChild(footwear3);
footwear3.addEventListener(MouseEvent.MOUSE_DOWN,itemPickup);
}
function onEnterFrame(event:Event):void
{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
if (draganddropPage.jumpers1.hitTestObject(draganddropPage.topTarget))
{
draganddropPage.jumpers1.x = draganddropPage.topTarget.x;
draganddropPage.jumpers1.y = draganddropPage.topTarget.y;
}
function onSubmitButton1Click(event:MouseEvent):void
{
addChild(lastPage);
captureText();
removeChild(orderformPage);
}
function itemPickup(event:MouseEvent):void
{
var currentDragObject:MovieClip = event.currentTarget as MovieClip;
currentDragObject.startDrag();
_isDragging = true;
currentDragObject.addEventListener(MouseEvent.MOUSE_UP, itemDrop);
}
function itemDrop(event:MouseEvent):void
{
var currentDragObject:MovieClip = event.currentTarget as MovieClip;
currentDragObject.stopDrag();
_isDragging = false;
currentDragObject.removeEventListener(MouseEvent.MOUSE_UP, itemDrop);
//Find the name of the object over which the drag object is dropped
if (currentDragObject.dropTarget != null)
{
trace(currentDragObject.dropTarget.parent.name);
}
}
function captureText():void
{
myText = OrderFormPage.nameInput.text;
homePage.output_txt.text = "Hello " + myText + "!";
}
}
}
}
