Avatar Creation in Flash

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

TiagoR
Posts: 83
Joined: 15 Mar 2010, 11:42
Location: Portugal

Post 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.
TR
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

TiagoR, I described two approaches in my last post: which of the two is not working for you?
Paolo Bax
The SmartFoxServer Team
TiagoR
Posts: 83
Joined: 15 Mar 2010, 11:42
Location: Portugal

Post 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 :)
TR
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Post 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?
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Post 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: Ð
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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?
Paolo Bax
The SmartFoxServer Team
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Post by gl0om »

bax wrote:gl0om,
Are you able to compile that fla to a swf file, without errors?
Yes
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Are you following the "external library" approach correctly, creating the application domain in which you load the swf correctly?
Paolo Bax
The SmartFoxServer Team
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Post 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)
	}
	...
}
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Post 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
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Post 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
Nepaleno
Posts: 22
Joined: 06 May 2010, 06:28

Post 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.
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Post 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?
Post Reply