private var DemoAvatar:Class;
private var myAvatar:*;
private function onAvatarSwfLoaded(evt:Event):void
{
DemoAvatar = avatarAppDomain.getDefinition('DemoAvatar') as Class;
myAvatar = openSpace.getMyAvatar() as DemoAvatar;
}
So every time I needed to use my DemoAvatar's methods I called them through myAvatar. But I'm sure there is simpler way to do this.
Another solution is that you declare myAvatarSymbol, avatarGraphics and what else in the DemoAvatar class, then open the actionscript properties panel of the DemoAvatarContainer.fla file and uncheck the Automatically declare stage instances flag.
In this way you should be able to compile the DemoAvatarContainer.fla and also reference the DemoAvatar class in your project.
bax wrote:Another solution is that you declare myAvatarSymbol, avatarGraphics and what else in the DemoAvatar class, then open the actionscript properties panel of the DemoAvatarContainer.fla file and uncheck the Automatically declare stage instances flag.
In this way you should be able to compile the DemoAvatarContainer.fla and also reference the DemoAvatar class in your project.
Well, this is exactly what I've done.
p.s.: I heard that you'll show us a new example with avatar soon. But when is it "soon"? I'm dreaming about this example
I'm trying to addChild from library in set skin function.
Object which I'm trying to add has MovieClip class and this class isn't changable. On adding attempt I receive message that object myst be of DisplayObject class. Why? Avatar class is child of MovieClip...
I can't understand how to work with skin object, how to add accessories to avatar, how to manage with it's state. Is there any examples or manuals about this?
What about checking the avatar example we provide? (ok, it is part of the OpenSpace Flex example, but the inner behavior of the avatar class -DemoAvatar.as- is always the same)
bax wrote:What about checking the avatar example we provide? (ok, it is part of the OpenSpace Flex example, but the inner behavior of the avatar class -DemoAvatar.as- is always the same)
Actually I work with your DemoAvatar.as from Flex example... Maybe I use old version of it, but there's no a single line about managing avatar's outlook.
gl0om wrote:Actually I work with your DemoAvatar.as from Flex example... Maybe I use old version of it, but there's no a single line about managing avatar's outlook.
If the swf file containing the avatars has the assets in it (which means movieclips in the library, with a linkage name assigned), then it is just a matter of adding a child to the displaylist. Can you please show the code not working?
override public function set skin(data:Object):void
{
trace("DemoAvatar: skin set to", data)
_skin = data;
if (_skin != null)
{
avatarGraphics.addChild(_skin.hat);
}
}
I suppose skin.hat contains a string, or a number. Why are you trying passing it to the addChild method? As you can read in the ActionScript documentation, the addChild method expects a DisplayObject to be passed.
So, assuming your avatars library contains a movieclip with its linkage name set to the skin.hat value (for example "panama"), then you should do something like this:
Interesting issue, glo0m... we didn't think about it when proposing the simplified SWC approach. The problem is this: the "panama" class is not referenced in your DemoAvatar class, so the compiler doesn't include it in the final SWF. So when you call the getDefinitionByName at runtime, Flash is not able to find the "panama" class. The simple solution is this: in your DemoAvatar class add something like this: var tmp:panama. This forces the compiler to include the "panama" class in the final SWF. The problem with this approach is that you have to reference ALL the avatar customization assets, which is not practical.
The best solution is to use the external SWF file loading approach.
We are now working on a full example showing avatar customization both in Flex and Flash, similar to the one we had in OpenSpace 1. We will make it available within a few days.