Solved

Help with "VerifyError: Error #1053"

Posted on 2011-03-24
4
745 Views
Last Modified: 2012-05-11
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
Comment
Question by:Sideas
  • 2
4 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 35209180
would be easier if you upload all the files etc. zip them all up.
0
 
LVL 2

Author Comment

by:Sideas
ID: 35213237
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
 
LVL 8

Accepted Solution

by:
ActionScript_Helper earned 500 total points
ID: 35215077
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
 
LVL 2

Author Comment

by:Sideas
ID: 35238880
Cheers! Thanks for that
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now