Tag Archives: error

Quick Tip – Return Vector Array


If you try to return a Vector typed array in flash, you’ll get the following error.

public function getMainItems():Vector
{
	//Length of Main items
	MainItemLn = xml.item.length();

	//Vector class of MainItems
	var MainVO:Vector     = new Vector.<VOItem>(MainItemLn,true);

	for(var i:int = 0; i < MainItemLn; ++i)
	{
		MainVO[i]        = new VOItem();
		MainVO[i].id     = i;
		MainVO[i].title  = xml.item[i].@title;
		MainVO[i].img = xml.item[i].@img;
	}

	return MainVO
}

1067: Implicit coercion of a value of type __AS3__.vec:Vector.<com.Gallery:VOItem> to an unrelated type __AS3__.vec:Vector.

It is because Vector.<VOItem> isn’t the same type as Vector. That means;

public function getMainItems():Vector.<VOItem>
{
	//Length of Main items
	MainItemLn = xml.item.length();

	//Vector class of MainItems
	var MainVO:Vector     = new Vector.<VOItem>(MainItemLn,true);

	for(var i:int = 0; i < MainItemLn; ++i)
	{
		MainVO[i]        = new VOItem();
		MainVO[i].id     = i;
		MainVO[i].title  = xml.item[i].@title;
		MainVO[i].img = xml.item[i].@img;
	}

	return MainVO
}

And you can get your Vector array values like;

trace(getMainItems()[0].title);
//or
trace(getMainItems()[1].title);
//and so on..
.
.
.

**Note: VOItem is my custom Value Object Class. It doesn’t matter what it is. It can be movieclip, sprite, etc…

text=Error #2036: Load Never Completed.

While I was preparing my web site, I didn’t get this error from Flash’s debugger. However, when I uploaded content to my server I got this error from IE. In Firefox there is no such error. But I can’t see the the image that should be loaded.

Today I’ve fixed it with a “WEIRD” way. I use xml for my mp3Player and when you select a song from playlist, player acquires image path, file name and info text about composition. So , firstly

I checked my xml file for the slip in spellings. The first mistake of mine is capital letter issue,
– For Example path of the file is
<song id=”1″ songname=”something” image=”images/audio.jpg” info=”bla blal blalal”></song>

list goes like this.  In action script class I typed it “Image“. Somehow flash ignored this and loaded related jpg file correctly. So I updated all “image” words to “Image“. But it wasn’t fixed.

After lots of experiments, I changed the name of image file from”audio” to “something_else” and WEIRDLY it worked 🙂

Really I have no idea about that. May be it is a bug. Because “audio” is so general word.

So if you encountered such an error, try to change your file names something like password 🙂

– dont forget to delete browser’s cache, history…

-carefully check your xml paths.