• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 774
  • Last Modified:

Help with "VerifyError: Error #1053"

Hi, I'm shuffling an array of images loaded from XML and it works fine.

It loads swfs fine too but when I try to load a particular swf I need I get a "VerifyError: Error #1053"

I've attached the FLAs, and XML, could someone tell me what the problem is.

Cheers
// CODE FOR SHUFFLE FLA
var pHeight:Number = 200;
var pWidth:Number = 200;

var listLoader:URLLoader = new URLLoader(new URLRequest("filelist4.xml"));
var arrPicLoaders:Array = new Array();
var arrPicList:Array = new Array();
var numImages:Number;

listLoader.addEventListener(Event.COMPLETE, gotList);

function gotList(evt:Event):void
{
	var xmlData:XML = XML(listLoader.data);
	numImages = xmlData.pix.length();
	var arrShuffled:Array = shuffleList(numImages);

	var stImage:String;
	for (var i=0; i<numImages; i++)
	{
		stImage = xmlData.pix[arrShuffled[i]].toString();
		arrPicLoaders[i] = new Loader();
		arrPicLoaders[i].contentLoaderInfo.addEventListener(Event.COMPLETE, gotPic);
		arrPicLoaders[i].load( new URLRequest(stImage) );
	}
	listLoader.removeEventListener(Event.COMPLETE, gotList);
}

function shuffleList(n:Number):Array
{
	var startList:Array = new Array(n);
	var endList:Array = new Array(n);
	var i,j:Number;

	for (i=0; i<n; i++)
	{
		startList[i] = i;
	}

	for (i=0; i<n; i++)
	{
		j = Math.floor(Math.random() * startList.length);
		endList[i] = startList.splice(j,1)[0];
	}
	return (endList);
}

function gotPic(evt:Event):void
{
	var thisObj:Object = Object(evt.target.content);
	var thisWidth:Number = thisObj.width;
	var thisHeight:Number = thisObj.height;

	thisObj.scaleX = pWidth / thisWidth;
	thisObj.scaleY = pHeight / thisHeight;
	arrPicList.push(thisObj);

	if (arrPicList.length == numImages)
	{
		placePictures();
	}
}

function placePictures():void
{
	for (var i=0; i<arrPicList.length; i++)
	{
		arrPicList[i].x = pWidth * Math.floor(i / 2);
		arrPicList[i].y = pHeight*(i%2);
		addChild(arrPicList[i]);
	}
}



// CODE FOR PLANE FLA

// Import the PaperSprite class

import soulwire.display.PaperSprite;

/*
Create a new PaperSprite:

If your front and back faces already exist, you can pass them straight
into the constructor, like so:

myPaperSprite = new PaperSprite( myFrontMc, myBackMc );
*/

var myPaperSprite:PaperSprite = new PaperSprite();

/*
Optionally specify a pivot point, in this example the centre is used
(this is also the default so there is no need to set this normally).

To pivot around the top left use:
myPaperSprite.pivot = new Point(0,0);

or for bottom right:
myPaperSprite.pivot = new Point(1,1);

and so on...
*/

myPaperSprite.pivotX= new Number(0.5);
myPaperSprite.pivotY= new Number(0.5);

// Centre it on the stage

myPaperSprite.x = stage.stageWidth / 2;
myPaperSprite.y = stage.stageHeight / 2;

/*
Set the front and back faces:

These can be any type of DisplayObject, for example, to use a MovieClip
from your library use:

myPaperSprite.front = new MyLibraryClip();
*/

myPaperSprite.front = createSprite(0x66FF00);
myPaperSprite.back = createSprite(0xFF3399);

// Add the PaperSprite to the display list

addChild ( myPaperSprite );

// This method just creates coloured boxes for the demo

function createSprite (colour:uint):Sprite
{
	var mySprite:Sprite = new Sprite();
	mySprite.graphics.beginFill ( colour );
	mySprite.graphics.drawRect (0,0,100,100);
	mySprite.graphics.endFill ();
	return mySprite;
}

// Listen for the enterFrame event

addEventListener ( Event.ENTER_FRAME, spin );

/*
Move and rotate your PaperSprite in any way you want - it will
update it's visible face automatically!
*/

function spin ( event:Event ):void
{
	var mX:Number = ((mouseX / stage.stageWidth) - 0.5) * 360;
	var mY:Number = ((mouseY / stage.stageHeight) - 0.5) * 360;

	myPaperSprite.rotationY += (mX - myPaperSprite.rotationY) / 40;
	myPaperSprite.rotationX += (mY - myPaperSprite.rotationX) / 40;
}



// CODE FOR PAPERSPRITE.AS

/**		
 * 
 *	uk.co.soulwire.display.PaperSprite
 *	
 *	@version 1.00 | Jan 11, 2011
 *	@author Justin Windle
 *  
 **/
package soulwire.display
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	 * @author justin
	 */
	public class PaperSprite extends Sprite
	{
		//	----------------------------------------------------------------
		//	CONSTANTS
		//	----------------------------------------------------------------
		
		private static const POINT_A : Point = new Point(0,   0);
		private static const POINT_B : Point = new Point(100, 0);
		private static const POINT_C : Point = new Point(0, 100);
		
		//	----------------------------------------------------------------
		//	PRIVATE MEMBERS
		//	----------------------------------------------------------------
		
		private var _p1 : Point;
		private var _p2 : Point;
		private var _p3 : Point;
		
		private var _pivot : Point = new Point(0.5, 0.5);
		private var _isFrontFacing : Boolean = false;
		private var _dirty : Boolean = false;
		private var _rect : Rectangle;
		
		private var _front : DisplayObject;
		private var _back : DisplayObject;
		
		//	----------------------------------------------------------------
		//	CONSTRUCTOR
		//	----------------------------------------------------------------
		
		/**
		 * Creates a new PaperSprite instance
		 * 
		 * @param front The DisplayObject to use as the front face 
		 * @param back The DisplayObject to use as the back face 
		 */
		
		public function PaperSprite(front : DisplayObject = null, back : DisplayObject = null)
		{
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			if(front) this.front = front;
			if(back) this.back = back;
		}
		
		//	----------------------------------------------------------------
		//	PUBLIC METHODS
		//	----------------------------------------------------------------
		
		/**
		 * Invalidates the PaperSprite's display, causing it to recalculate 
		 * the face positions and visibility during the next render cycle.
		 */
		
		public function invalidate() : void
		{
			_dirty = true;
			if(stage) stage.invalidate();
		}
		
		//	----------------------------------------------------------------
		//	PRIVATE METHODS
		//	----------------------------------------------------------------
		
		private function update(event : Event = null) : void
		{
			if (_dirty)
			{
				_p1 = localToGlobal( POINT_A );
				_p2 = localToGlobal( POINT_B );
				_p3 = localToGlobal( POINT_C );
				
				_isFrontFacing = (_p2.x-_p1.x)*(_p3.y-_p1.y)-(_p2.y-_p1.y)*(_p3.x-_p1.x) > 0;
				
				if (_front)
				{
					_rect = _front.getBounds(_front);
					
					_front.x = -(_rect.width * _pivot.x);
					_front.y = -(_rect.height * _pivot.y);
					_front.visible = _isFrontFacing;
				}

				if (_back)
				{
					_rect = _back.getBounds(_back);
					
					_back.x = -(_rect.width * _pivot.x * -1);
					_back.y = -(_rect.height * _pivot.y);
					_back.scaleX = -1;
					_back.visible = !_isFrontFacing;
				}

				_dirty = false;
			}
		}
		
		//	----------------------------------------------------------------
		//	EVENT HANDLERS
		//	----------------------------------------------------------------
		
		private function onAddedToStage(event : Event) : void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			stage.addEventListener(Event.RENDER, update);
			update();
		}
		
		//	----------------------------------------------------------------
		//	PUBLIC ACCESSORS
		//	----------------------------------------------------------------
		
		/**
		 * Whether or not the PaperSprite is oriented so that the front face 
		 * is visible
		 */
		
		public function get isFrontFacing() : Boolean
		{
			return _isFrontFacing;
		}
		
		/**
		 * Relative position of the x axis pivot (between 0.0 and 1.0). Defaults 
		 * to the center of each face (0.5).
		 */
		
		public function get pivotX() : Number
		{
			return _pivot.x;
		}
		
		public function set pivotX( value : Number ) : void
		{
			_pivot.x = value;
			invalidate();
		}
		
		/**
		 * Relative position of the y axis pivot (between 0.0 and 1.0). Defaults 
		 * to the center of each face (0.5).
		 */
		
		public function get pivotY() : Number
		{
			return _pivot.x;
		}
		
		public function set pivotY( value : Number ) : void
		{
			_pivot.y = value;
			invalidate();
		}
		
		/**
		 * The DisplayObject to use as the front face
		 */
		
		public function get front() : DisplayObject
		{
			return _front;
		}
		
		public function set front( value : DisplayObject ) : void
		{
			_front = addChild(value);
			invalidate();
		}
		
		/**
		 * The DisplayObject to use as the back face
		 */
		
		public function get back() : DisplayObject
		{
			return _back;
		}
		
		public function set back( value : DisplayObject ) : void
		{
			_back = addChild(value);
			invalidate();
		}
		
		// override display methods
			
		override public function set x(value : Number) : void
		{
			super.x = value;
			invalidate();
		}
		
		override public function set y(value : Number) : void
		{
			super.y = value;
			invalidate();
		}
		
		override public function set z(value : Number) : void
		{
			super.z = value;
			invalidate();
		}
		
		override public function set rotationX(value : Number) : void
		{
			super.rotationX = value;
			invalidate();
		}
		
		override public function set rotationY(value : Number) : void
		{
			super.rotationY = value;
			invalidate();
		}
		
		override public function set rotationZ(value : Number) : void
		{
			super.rotationZ = value;
			invalidate();
		}

	}
}


// CODE FOR FILELIST4 XML

<?xml version="1.0" encoding="utf-8"?>
<imagelist>
<pix>Plane.swf</pix>
<pix>Plane.swf</pix>
<pix>Plane.swf</pix>
<pix>Plane.swf</pix>
<pix>Plane.swf</pix>
<pix>Plane.swf</pix>
<pix>Plane.swf</pix>

</imagelist>

Open in new window

0
Sideas
Asked:
Sideas
  • 2
1 Solution
 
blue-genieCommented:
would be easier if you upload all the files etc. zip them all up.
0
 
SideasAuthor Commented:
Hello blue-genie, the upload function keeps failing, saying my FLAs are forbidden and they are have XFL extensions!

Do you mind getting the zip from here?

http://www.idealogyltd.com/test/experts_exchange.zip

Thanks
0
 
ActionScript_HelperCommented:
The overrides you are trying to make in PaperSprite class (for e.g. override public function set z(value : Number) : void) is not working with Flash player 9. If you'll check it with Flash player 10 it will work just fine.

So you should be publishing your fla on Flash player 10.
0
 
SideasAuthor Commented:
Cheers! Thanks for that
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now