Page 3 of 3
Posted: 14 May 2010, 13:51
by Nepaleno
gl0om wrote:And what if I use DemoVatar class in my project? Compilator will stuck on line where the reference on DemoAvatar is.
The solution I used was getting DemoAvatar class definition from loaded swf file's application domain.
Code: Select all
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.
Posted: 15 May 2010, 05:57
by Bax
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.
Posted: 20 May 2010, 12:09
by gl0om
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

Posted: 26 May 2010, 11:29
by gl0om
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?
Posted: 26 May 2010, 11:45
by Bax
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)
Posted: 26 May 2010, 11:50
by gl0om
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.
Posted: 27 May 2010, 07:27
by Bax
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?
Posted: 27 May 2010, 17:16
by gl0om
Code: Select all
override public function set skin(data:Object):void
{
trace("DemoAvatar: skin set to", data)
_skin = data;
if (_skin != null)
{
avatarGraphics.addChild(_skin.hat);
}
}
Posted: 27 May 2010, 21:38
by Bax
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:
Code: Select all
var hatClass:Class = getDefinitionByName(skin.hat) as Class
var hatMC:MovieClip = new hatClass:Class() as MovieClip
avatarGraphics.addChild(hatMC)
Posted: 27 May 2010, 21:55
by gl0om
oops
Indeed it was string in _skin.hat
I forgot that addChild requires DisplayObject and passed it's name... Sorry

Posted: 29 May 2010, 09:15
by gl0om
Now I have such error:
ReferenceError: Error #1065: Variable panama is not defined
But, panama movieclip exists in DemoAvatarContainer.fla and it exported as panama. Is there any other place where I should define panama?
Posted: 29 May 2010, 16:11
by Bax
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.
Posted: 29 May 2010, 20:49
by gl0om
I suggest I didn't understand the solution you adviced, or it just doesn't work
I'm waiting for you example very much. I hope it'll set all my questions.
Posted: 08 Jun 2010, 19:53
by Bax
OpenSpace 2.0.1 has been released. It contains a full Flash example.