Page 2 of 3

Posted: 10 May 2010, 08:40
by TiagoR
Hi,
the example you provided is the same as before, and unfortunally i get the same results from it :?

The only thing i get from the avatar is this output:
"AVATAR CREATION ERROR: Missing 'DemoAvatar' class definition in avatars application domain for 'demo' avatar type "

although i think i got everything like mentioned in the documentation.

A pratical example would be nice, since there seems to be alot of questions regarding this matter.

Posted: 10 May 2010, 09:16
by Bax
TiagoR, I described two approaches in my last post: which of the two is not working for you?

Posted: 10 May 2010, 09:29
by TiagoR
Thnks for que quick reply, i am using the 1st aproach, but in the meanwhile i reviewed the code and found that i missed something :oops: after ive loaded the swf file at runtime in my application i was forgetting to set the Openspace avatarAppDomain property :oops:
Now its working :roll:

Thnks for the help, and sorry for any trouble :)

Posted: 10 May 2010, 22:39
by gl0om
I get warning when using createMyAvatar

Code: Select all

[WARNING] An error occurred while creating avatar '0': Invalid main avatar class definition for 'demo' avatar type: class must extend Avatar
"demo's" mainClass is "DemoAvatar"
And Yes, DemoAvatar extends Avatar class

Code: Select all

package
{
	import com.smartfoxserver.openspace.engine.model.avatar.Avatar;
	import com.smartfoxserver.openspace.shared.view.items.Tile;
	
	import flash.geom.Rectangle;
	import flash.display.*; // This import is required or Flash CS3 won't be able to compile; no issues with CS4 instead

	public class DemoAvatar extends Avatar
	{....
What am I doing wrong?

Posted: 11 May 2010, 07:22
by Bax
I suppose you are using the "external library" approach. In this case you probably have an issue with the application domain in which you load the avatars swf file. As the IOpenSpace.avatarAppDomain property description says in the client API reference, that application domain must have the main application domain as its parent. Otherwise OpenSpace will "see" a different Avatar class definition which doesn't match with the one you are extending in your avatar.

Posted: 11 May 2010, 08:14
by gl0om
bax wrote:In this case you probably have an issue with the application domain in which you load the avatars swf file. As the IOpenSpace.avatarAppDomain property description says in the client API reference, that application domain must have the main application domain as its parent.
I made some changes and now I have this:

Code: Select all

[WARNING] An error occurred while creating avatar '3': Error #1056: Ð

Posted: 11 May 2010, 09:32
by Bax
gl0om,
DemoAvatar.as is the class definition linked to a movieclip in the DemoAvatarContainer.fla file. Are you able to compile that fla to a swf file, without errors?

Posted: 11 May 2010, 09:43
by gl0om
bax wrote:gl0om,
Are you able to compile that fla to a swf file, without errors?
Yes

Posted: 11 May 2010, 13:00
by Bax
Are you following the "external library" approach correctly, creating the application domain in which you load the swf correctly?

Posted: 11 May 2010, 13:22
by gl0om
bax wrote:Are you following the "external library" approach correctly, creating the application domain in which you load the swf correctly?
I'm not sure. Here's my code

Code: Select all

private function init(e:Event = null):void 
{
	removeEventListener(Event.ADDED_TO_STAGE, init);
	swfLibrariesAppDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
	openSpace.skinAppDomain = swfLibrariesAppDomain;
	openSpace.bgAppDomain = swfLibrariesAppDomain;
	openSpace.avatarAppDomain = swfLibrariesAppDomain;
	...
}

private function loadMapAssets(skinSwfFilenames:Array, bgSwfFilenames:Array):void
{
	...
	var fileNames:Array = skinSwfFilenames.concat(bgSwfFilenames)
	fileNames.push("DemoAvatarContainer.swf");
	...
	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMapSwfFileLoaded)

	...
	{					
		var request:URLRequest = new URLRequest("libraries/" + fileNames[i])
		var context:LoaderContext = new LoaderContext(false, swfLibrariesAppDomain)
		logTrace("loader created for "+ fileNames[i])
		loader.load(request, context)
	}
	...
}

Posted: 11 May 2010, 22:33
by gl0om
There was no definision for myAvatarSymbol and avatarGraphics in DemoAvatar.as from flex.zip.

So I added these 2 lines

public var myAvatarSymbol:*;
public var avatarGraphics:*;

Now everything seems to be fine

Posted: 12 May 2010, 07:03
by Bax
gl0om wrote:
bax wrote:Are you following the "external library" approach correctly, creating the application domain in which you load the swf correctly?
I'm not sure. Here's my code
...
Not sure? Did you read my earlier post in which I describe the two approaches?
Anyway, as you are loading an external SWF file, you are using an external library.
DemoAvatar.as doesn't contain a definition of myAvatarSymbol and avatarGraphics because those are movieclips inside the DemoAvatar movieclip contained in the DemoAvatarContainer.fla file.

Posted: 12 May 2010, 14:06
by gl0om
bax wrote: Not sure? Did you read my earlier post in which I describe the two approaches?
Anyway, as you are loading an external SWF file, you are using an external library.
DemoAvatar.as doesn't contain a definition of myAvatarSymbol and avatarGraphics because those are movieclips inside the DemoAvatar movieclip contained in the DemoAvatarContainer.fla file.
Yes, I did. As it works fine now, I suppose that I did everything well. But I can't understand why my project should be compiled without definition of
myAvatarSymbol and avatarGraphics in DemoAvatar.as. My project simply don't know about these objects in DemoAvatar.swf and compilator tells me that it can't find these objects in DemoAvatar.as

Posted: 13 May 2010, 06:17
by Nepaleno
My project simply don't know about these objects in DemoAvatar.swf and compilator tells me that it can't find these objects in DemoAvatar.as
You don't have to include DemoAvatar.as in your main project. It is used when you compile your avatar library swf file, so it takes those myAvatarSymbol and avatarGraphics definitions from there.

Posted: 14 May 2010, 08:29
by gl0om
Nepaleno wrote: You don't have to include DemoAvatar.as in your main project. It is used when you compile your avatar library swf file, so it takes those myAvatarSymbol and avatarGraphics definitions from there.
And what if I use DemoVatar class in my project? Compilator will stuck on line where the reference on DemoAvatar is. Because in DemoAvatar.as it'll find the implementation of myAvatarSymbol, but this myAvatarSymbol is defined in SWF file, not in DemoAvatar.as ...
I suppose that compilator doesn't check SWF file for possible definitions, or it does?