Skip to main content
Known Participant
August 30, 2011
Answered

1120 Error Problem

  • August 30, 2011
  • 2 replies
  • 625 views

I am getting an 1120 error on the includ scipr called scrolling_image.as and I am not sure why.  As you can see I am trying to put all parts of that script into a function to be called when a button is clicked it would load the appropriate info from the xmil file and show the correct pictures into the scroller. Anyone have any ideas why I am getting the error?

The main script is :

import flash.events.MouseEvent;

import flash.display.MovieClip;

import caurina.transitions.*;

//Intialize Variables

//var organName:String = "";

var speed:Number;

var padding:Number = 20;

var thumbFadeOut:Number = .2;

var thumbFadeIn:Number = 1;

var thumbSmall:Number = 1;

var thumbLarge:Number = 1.1;

//Included Files

include "/AS/buttonScripts.as"

include "/AS/scrolling_image.as"

//buttonScripts.as

function LoadXML(e:Event):void

{

trace("xml loading complete");

//load xml

var xmlLoader:URLLoader = new URLLoader();

var xmlData:XML = new XML();

var xmlPath:String = "XML/organtext.xml";

xmlLoader.load(new URLRequest(xmlPath));

trace("loading xml from: " + xmlPath);

xmlData = new XML(e.target.data);

trace(xmlData.organ.(@name==organName).visualAids.image);

var scroller:MovieClip = new MovieClip();

questions.addChild(scroller);

scroller.x = scroller.y = padding;

buildScroller(xmlData.organ.(@name==organName).visualAids.image);

textImport(xmlData.organ.(@name==organName).name);

}

//Set Text from XML

function textImport(imageList:XMLList):void

{

trace(xmlData.organ.(@name==organName).descriptions)

questions.headers.text = xmlData.organ.(@name==organName).name

questions.topictext.text = xmlData.organ.(@name==organName).descriptions

}

/*var speed:Number;

var padding:Number = 20;

var thumbFadeOut:Number = .2;

var thumbFadeIn:Number = 1;

var thumbSmall:Number = 1;

var thumbLarge:Number = 1.1;*/

//var scroller:MovieClip = new MovieClip();

//questions.addChild(scroller);

//scroller.x = scroller.y = padding;

//build scroller from xml

function buildScroller(imageList:XMLList):void

{

trace("build Scroller");

for (var item:uint = 0; item < imageList.length(); item++)

{

var thisOne:MovieClip = new MovieClip();

//outline

var blackBox:Sprite = new Sprite();

blackBox.graphics.beginFill(0xFFFFFF);

blackBox.graphics.drawRect( -1, -1, 142, 107);

blackBox.alpha = thumbFadeOut;

thisOne.addChild(blackBox);

thisOne.blackBox = blackBox;

thisOne.y = thisOne.myy = (140 + padding) * item;

thisOne.itemNum = item;

thisOne.title = imageList[item].attribute("title");

thisOne.link = imageList[item].attribute("url");

thisOne.src = imageList[item].attribute("src");

//image container

var thisThumb:Sprite = new Sprite();

//add image

var ldr:Loader = new Loader();

var urlReq:URLRequest = new URLRequest(thisOne.src);

trace("loading thumbnail "+item+" into Scroller: " + thisOne.src);

ldr.load(urlReq);

//assign event listeners for Loader

ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

thisThumb.addChild(ldr);

thisOne.addChild(thisThumb);

//create listeners for this thumb;

thisOne.buttonMode = true;

thisOne.addEventListener(MouseEvent.MOUSE_OVER, overScrollerItem);

thisOne.addEventListener(MouseEvent.MOUSE_OUT, outScrollerItem);

thisOne.addEventListener(MouseEvent.CLICK, clickScrollerItem);

//add item;

scroller.addChild(thisOne);

}

scroller.addEventListener(Event.ENTER_FRAME, moveScrollerThumbs);

trace("termination of build scroller");

}

function overScrollerItem(e:MouseEvent):void

{

//trace("over" + e.currentTarget.name);

Tweener.addTween(e.currentTarget, { scaleY:thumbLarge, scaleX:thumbLarge, y:e.currentTarget.myy - e.currentTarget.height * Math.abs(thumbSmall - thumbLarge)/2, x: -e.currentTarget.height * Math.abs(thumbSmall - thumbLarge)/2, time:1 } );

Tweener.addTween(e.currentTarget.blackBox, { alpha:thumbFadeIn, time: 1 } );

}

function outScrollerItem(e:MouseEvent):void

{

//trace("out" + e.currentTarget.name);

Tweener.addTween(e.currentTarget, { scaleY:thumbSmall, scaleY:thumbSmall, y:e.currentTarget.myy, x:0, time:1 } );

Tweener.addTween(e.currentTarget.blackBox, { alpha:thumbFadeOut, time: 1 } );

}

function clickScrollerItem(e:MouseEvent):void

{

//trace("clicked item " + e.currentTarget.itemNum + " - visit url: " + e.currentTarget.link);

var urlRequest:URLRequest = new URLRequest(e.currentTarget.link);

try

{

navigateToURL(urlRequest);

}

catch (e:Error)

{

// handle error here

trace(e);

}

}

function completeHandler(e:Event):void

{

//trace("thumbnail complete "+e.target.loader.parent.parent.name);

//size image into scroller

resizeMe(e.target.loader.parent, 140, 105, true, true, false);

Tweener.addTween(e.target.loader.parent.parent, { alpha:1, time: .5 } );

}

function errorHandler(e:IOErrorEvent):void

{

trace("thumbnail error="+e);

}

function resizeMe(mc:DisplayObject, maxW:Number, maxH:Number=0, constrainProportions:Boolean=true, centerHor:Boolean=true, centerVert:Boolean=true):void

{

maxH = maxH == 0 ? maxW:maxH;

mc.width = maxW;

mc.height = maxH;

if (constrainProportions)

{

mc.scaleX < mc.scaleY ? mc.scaleY = mc.scaleX:mc.scaleX = mc.scaleY;

}

if (centerHor)

{

mc.x = (maxW - mc.width) / 2;

}

if (centerVert)

{

mc.y = (maxH - mc.height) / 2;

}

}

function moveScrollerThumbs(e:Event):void

{

if ( mouseX > scroller.x && mouseX < scroller.x + scroller.width)

{//vertically over scroller

if (mouseY < stage.stageHeight/2 - padding*2 && mouseY > 0)

{//left of stage explicitly

speed = -(mouseY - (stage.stageHeight/2 - padding*2)) / 8;

}

else if (mouseY > stage.stageHeight/2 + padding*2 && mouseY < stage.stageHeight)

{//right of stage explicitly

speed = -(mouseY - (stage.stageHeight/2 + padding*2)) / 8;

}

else

{

speed = 0;

}

scroller.y +=  speed;

//scroller limits

if (scroller.y <  -  scroller.height + stage.stageHeight - padding)

{//if scrolled too far left

scroller.y =  -  scroller.height + stage.stageHeight - padding;

}

else if (scroller.y > padding)

{//if scrolled to far right

scroller.y = padding;

}

}

}

This topic has been closed for replies.
Correct answer Ned Murphy

I can't tell by your code which line is which, but based on your defining the xmlData variable inisde a function, if you are trying to access it anywhere outside that function it doesn't exist outside the function.  Try declaring the variable outside of any function to give it a more global scope.

2 replies

Known Participant
August 30, 2011

AS\scrolling_image.as, Line 40 1120: Access of undefined property xmlData.

I have this same error on 19 lines

Ned Murphy
Ned MurphyCorrect answer
Legend
August 30, 2011

I can't tell by your code which line is which, but based on your defining the xmlData variable inisde a function, if you are trying to access it anywhere outside that function it doesn't exist outside the function.  Try declaring the variable outside of any function to give it a more global scope.

Ned Murphy
Legend
August 30, 2011

What is the complete error message, and if possible what portion of the code you show is relevant to the error?