openspace.initialize

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

Moderators: Lapo, Bax

Post Reply
morgflast
Posts: 9
Joined: 04 Sep 2008, 15:21

openspace.initialize

Post by morgflast »

I had another question about the openspace libraries.

I am trying to call

Code: Select all

os.initialize(smartFox, this)			
The error I got was:
ReferenceError: Error #1069: Property loaderInfo not found on vw.app.modules.OpenSpaceCodeModule and there is no default value.
at com.smartfoxserver.openspace.avatar::AvatarsManager/createAvatar()
at com.smartfoxserver.openspace.mvc::IsoEngineModel/createAvatar()
at com.smartfoxserver.openspace::OpenSpace/createMyAvatar()
at vw.app.modules::OpenSpaceCodeModule/onOpenSpaceMapRendered()[/Users/djacobs7/svn/vw_client/src/vw/app/modules/OpenSpaceCodeModule.as:221]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.smartfoxserver.openspace::OpenSpace/forwardOpenSpaceEvent()
at com.smartfoxserver.openspace::OpenSpace/onMapRendered()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.smartfoxserver.openspace.mvc::IsoEngineModel/onMapBuilt()
at com.smartfoxserver.openspace.map::MapManager/onMapGenerationCompleted()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.smartfoxserver.openspace.utils.executor::MultiFrameExecutor/runStep()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Presumably, I got this error because 'this' was of the wrong type. I was wondering what type of object 'this' would have to be. My goal is to code an IAvatarMovieClip in Flex, and then be able to tell openspace the name of the class that defines the avatar, without having to compile the IAvatarMovieClip into a swf and then importing it afterwards (which works just fine, but is not what I want to do.)

Openspace and Smartfox are great, by the way,
Daniel
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

If you check the examples provided with OpenSpace, you'll see that we pass as second parameter of the initialize method a reference (avatarsLibrary) to the content of the Loader which loads the external SWF containing the AvatarMovieClip class (and all the assets it makes use of).
OpenSpace then instantiate the AvatarMovieClip class from that SWF's library like this:

Code: Select all

var appDomain:ApplicationDomain = avatarsLibrary.loaderInfo.applicationDomain
var aClass:Class = Class(appDomain.getDefinition(avatarClassName))
var avatarMovieClip:IAvatarMovieClip = new aClass() as IAvatarMovieClip
where "avatarClassName" is the name you provided in the OpenSpace configuration xml file.
So if you pass "this", OpenSpace looks for the avatar class in your application's library.
Paolo Bax
The SmartFoxServer Team
Post Reply