Jump to content
Search Community

SWFLoader error message

Benjamin Waller test
Moderator Tag

Recommended Posts

Hello,

I'd some help with this class file. Here is the following error message.

Error: Error #2136: The SWF file file:///E|/Adobe%20developer/Flash%20Tutorials/Stacey%20Reiman/Test/Chaohoi%5FV0001/TestCustomCursor.swf contains invalid data. at CustomCursor()

I'm not sure weather I've got the path to the cursor SWF correctly or it's something else I've not done right so I've included both my .AS and .FLA files.

Here's the code:

package  {
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.ui.Mouse;

public class CustomCursor  extends Sprite{

   	private var myCursor:Sprite;

	public function CustomCursor() {
		myCursor = new CustomCursor();

//stage.align = StageAlign.TOP_LEFT;
//stage.scaleMode = StageScaleMode.NO_SCALE;

 function init(){
	 var loader:SWFLoader = new SWFLoader("1/images/pointerL.swf", {onComplete:mouseMoveHandler});
	loader.load();
	Mouse.hide();


myCursor.mouseEnabled = false;
myCursor.visible = false;

// you'll want to make sure the child is added above everything
// else, possibly in its own container
//
addChild(myCursor);

// respond to mouse move events
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler);
}

function mouseMoveHandler(evt:MouseEvent):void
{
// whenever the mouse moves, place the cursor in the same spot
myCursor.visible = true;
myCursor.x = evt.stageX;
myCursor.y = evt.stageY;
}

function mouseLeaveHandler(evt:Event):void
{
myCursor.visible = false;
}

init();
	}

}

}

 

Cheers,

Ben.

Link to comment
Share on other sites

the LoaderMax code has nothing to do with your error. Remove it and test. The same error appears.

 

i'm guessing the problem is that you are defining an object that attempts to create itself

 

public class CustomCursor  extends Sprite{

   	private var myCursor:Sprite;

	public function CustomCursor() {
		myCursor = new CustomCursor();

 

i'm not so sure that is valid.

Link to comment
Share on other sites

Thanks Carl,

 

Yes, a silly error I my part.

Then, I just needed to add the loader's content to the display list and now I get the Custom Cursor appearing on stage. :D

But I now have another error message (see below) after I added following line of code :

 

myCursor = loader.content;

 

TypeError: Error #1034: Type Coercion failed: cannot convert com.greensock.events::LoaderEvent@2f3e1121 to flash.events.MouseEvent.

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at com.greensock.loading.core::LoaderCore/_completeHandler()

at com.greensock.loading::SWFLoader/_completeHandler()

 

Here's the revised code:

package  {
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.ui.Mouse;

public class CustomCursor  extends Sprite{

   	private var myCursor:Sprite;

	public function CustomCursor() {

//stage.align = StageAlign.TOP_LEFT;
//stage.scaleMode = StageScaleMode.NO_SCALE;

 function init(){
	 var loader:SWFLoader = new SWFLoader("1/images/pointerL.swf", {onComplete:mouseMoveHandler});
	loader.load();
	addChild(loader.content)
	Mouse.hide();

	myCursor = loader.content;
	myCursor.mouseEnabled = false;
	myCursor.visible = false;

// you'll want to make sure the child is added above everything
// else, possibly in its own container
//
addChild(myCursor);

// respond to mouse move events
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler);
}

function mouseMoveHandler(evt:MouseEvent):void
{


// whenever the mouse moves, place the cursor in the same spot
myCursor.visible = true;
myCursor.x = evt.stageX;
myCursor.y = evt.stageY;
}

function mouseLeaveHandler(evt:Event):void
{
myCursor.visible = false;
}

init();
	}

}

}

 

Any thoughts?

 

Cheers Ben.

Link to comment
Share on other sites

Thanks Carl.

I've sorted out the SWFLoader issue. But now I've got a ImageLoading error.

Here's the error message.

 

----

Loading error on ImageLoader 'reload' (1/images/reload_1.png): Error #2035: URL Not Found. URL: file:///E|/Adobe%20developer/Flash%20Tutorials/Stacey%20Reiman/Test/Chaohoi%5FV0001/1/images/reload_1.png

----

progress: 0.36694406812463715

progress: 0.5731888265273208

progress: 0.5753177214373266

progress: 0.5790594155215792

progress: 0.785304173924263

progress: 0.9957422101799884

progress: 0.9978711050899942

progress: 1

LoaderMax 'mainQueue' is complete!

 

here's the LoaderMax code:

 

var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler});

queue.append( new ImageLoader("1/images/reload_1.png", {name:"reload"}) );
		//prioritize the loader named "photo1"
LoaderMax.prioritize("reload");//same as LoaderMax.getLoader("photo1").prioritize();

//start loading
queue.load();

function progressHandler(event:LoaderEvent):void {
   trace("progress: " + event.target.progress);
}

function completeHandler(event:LoaderEvent):void {
   var image:ContentDisplay = LoaderMax.getContent("reload");
   TweenLite.to(image, 1, {alpha:1, y:100});
   trace(event.target + " is complete!");
addChild(image);

}

 

Any ideas?

Link to comment
Share on other sites

Hi Ben, thought I'd chime in here if I could.

The error looks pretty strait forward "Loading error on ImageLoader 'reload' (1/images/reload_1.png): Error #2035: URL Not Found".

Based on "E|/Adobe%20developer/Flash%20Tutorials/Stacey%20Reiman/Test/Chaohoi%5FV0001/1/images/reload_1.png" I'm guessing your fla is in "E|/Adobe developer/Flash Tutorials/Stacey Reiman/Test/Chaohoi_V0001/" ? If not, maybe that's the issue.

I've run into messes like that in the past, I've found that keeping my project directory paths as simple as possible really helps narrowing down like problems,

(e.g.: "C:\FlashProjects\loaderMaxTest4\"). Long paths with spaces can make it confusing.

 

HTH

A different Karl

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...