swf skin is not loading in the first time

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

Moderators: Lapo, Bax

kuzniz
Posts: 19
Joined: 05 Jan 2012, 07:21

swf skin is not loading in the first time

Postby kuzniz » 07 Mar 2013, 23:32

./Hi,

I am using the example class for loading the map. using a custom map.

when I clear the browser cache, usually ( not all time) the skin library is not loaded and when openSpace.renderMap() method is called the skins are not painted on the map , causeing user confusion.
when refreshing the page (F5) the skin is been loaded and the map show ok.

can you help me in a way to solve this problem ?

my skin library is 1.6M my background is 800K.

shachar
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: swf skin is not loading in the first time

Postby Bax » 08 Mar 2013, 08:26

Are you waiting for the library swf loading completion before loading the map? I guess not.
Paolo Bax
The SmartFoxServer Team
kuzniz
Posts: 19
Joined: 05 Jan 2012, 07:21

Re: swf skin is not loading in the first time

Postby kuzniz » 16 Mar 2013, 18:00

Hi,

I am using the sample code
----------------------------------------------
mapAssetsLibrariesAppDomain = new ApplicationDomain()
var fileNames:Array = skinSwfFilenames.concat(bgSwfFilenames)
loadCounter = fileNames.length
tempLoaders = [] // We have to keep a reference to the loaders to avoid a bug in the Flash Player: http://bugs.adobe.com/jira/browse/FB-13014

if (loadCounter > 0)
{
main.logTrace("External swf files to be loaded: " + fileNames)

for (var i:int = 0; i < loadCounter; i++)
{
var loader:Loader = new Loader()
tempLoaders.push(loader)

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMapSwfFileLoaded)

var request:URLRequest = new URLRequest("libraries/" + fileNames[i])
var context:LoaderContext = new LoaderContext(false, mapAssetsLibrariesAppDomain)

loader.load(request, context)
}
}
else
onMapSwfFileLoaded(null)
}

/**
* swf file loaded: when all the required swf files are loaded, map rendering can be launched.
*/
private function onMapSwfFileLoaded(evt:Event):void
{
loadCounter--

if (loadCounter <= 0)
{
main.LoadMapText.text=ResourceManager.getInstance().getString('expo','ALL_ASSET_MSG')
//Alert.show("External libraries loaded, now the loaded map can be rendered");
main.logTrace("External libraries loaded, now the loaded map can be rendered")

// The same value is passed to both skinAppDomain and bgAppDomain parameters: check the comment to loadMapAssets method above.
openSpace.skinAppDomain = mapAssetsLibrariesAppDomain
openSpace.bgAppDomain = mapAssetsLibrariesAppDomain

// Render map
openSpace.renderMap()
}
}


------------------------------------------------

In it the listener is loading all the attach swf (loadCounter = fileNames.length) to the map and only then render the map ( if (loadCounter <= 0 .... openSpace.renderMap(). ).



shachar
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: swf skin is not loading in the first time

Postby Bax » 17 Mar 2013, 11:04

It is difficult to help. If you check the example we provide with OpenSpace, everything works fine.
So there must be something wrong with your code. Are you able to point out the differences between your code and our code?
Paolo Bax
The SmartFoxServer Team
kuzniz
Posts: 19
Joined: 05 Jan 2012, 07:21

Re: swf skin is not loading in the first time

Postby kuzniz » 24 May 2013, 19:33

just the skin file is bigger , the loading code is exatlly the same
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: swf skin is not loading in the first time

Postby Bax » 25 May 2013, 08:45

I would like to embed the skin swf in the flash file.
some thing like :

[Embed(source="libraries/elements.swf", mimeType="application/octet-stream")]
public var elements:Class;

and it load it directly ( with out a url request ) as I don't get it loaded all the time some time the user get room without stuff in it....
is it possible ? how ?


This should be possible.
You should be able to modify the code described here: http://openspace-engine.com/static/clie ... nAppDomain (default skins loading system)
with the approach described here: http://userflex.wordpress.com/2012/04/1 ... nimations/
Let us know how it goes.
Paolo Bax
The SmartFoxServer Team
radiateur
Posts: 62
Joined: 15 Aug 2011, 08:14

Re: swf skin is not loading in the first time

Postby radiateur » 01 Jun 2013, 10:46

Hi,


I think that the avatarSkin loader is the really weak part of openspace. As i told it in a previous post this kind of social games need huge number of avatars' skins to become attractive. Loading every avatars skins is not a really good options for online games, it's just a default solution to avoid problems during first load...
But loading avatar skins only when needed is not explained at all in the doc, there's absolutly no ressources on the web or the forum about it, and it looks like we need to override default openspace system to achieve this

So as the only "good" solution seems to be to load every skins before we lauch openspace, I'm looking after the same thing than kuzniz, but i don't understand the first link you sent Bax.

Could you explain this a little more? Can we only change the avatar skin download/embed link in openspace? Because mapSkins loading system in openspace is good, it can be split in multiple swf, and loaded only when needed. It would not be a good option to load them "before" a player need to display them.

Thanks,
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: swf skin is not loading in the first time

Postby Bax » 02 Jun 2013, 11:07

In OpenSpace you can't load each avatar skin separately. As you said avatars skins can be a huge number. If each must be loaded separately by thousands of users, the http server serving those files could be overwhelmed by the requests. For this reason we decided to go with the approach of a single swf containing all the skins. I don't understand why this doesn't work for you.

Anyway you could explore the possibility of having a "smart" avatars library. A swf file that instead of containing all the skin is capable of loading them on demand. I'm not sure how to achieve this, but it is a path to explore.
Paolo Bax
The SmartFoxServer Team
radiateur
Posts: 62
Joined: 15 Aug 2011, 08:14

Re: swf skin is not loading in the first time

Postby radiateur » 06 Jun 2013, 18:25

Well if it's server related, i would have prefer to load each avatar skins separtly because apache/nginx process would have been used for a small amount of time and released faster.
In my experience it's better for server performance than to send big files to many concurrent clients during a long time, cause it's "freeze" apache/nginx process, and block server slot avaibility. (this is exactly what cause poor apache performance, and maxclient reached, with big php scripts which hold server processes for a too long time)
I use nginx for serving every static files in a cdn way, and i prefer to manage myself a huge amount of loadings like this on the server side than to loose players because they have to wait for a looooong time for one file to be fully loaded : it's a poor user experience.

But well, we can't do this, so that's like that and that's all.

SO I think that a good way to avoid strange behaviors with big avatar swf files, is to load this file BEFORE openspace calls it at runtime. Like this, when openspace call it, the browser would send the swf file previously loaded from the browser cache. :) That's what i'll try myself ;)
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: swf skin is not loading in the first time

Postby Bax » 07 Jun 2013, 08:47

As I explained in my previous post, you could try to create a "smart library". A very small swf library which in turn contains the logic to load the avatar assets "on demand". I think I've seen this in the past, made by the studio which developed Football Village with OpenSpace. Unfortunately I don't have more details to help you in implementing my suggestion.

a good way to avoid strange behaviors with big avatar swf files, is to load this file BEFORE openspace calls it at runtime

Actually that's how it already works. OpenSpace is not responsible of loading the avatar assets, but you have to load it before OpenSpace needs to render an avatar.
Paolo Bax
The SmartFoxServer Team
radiateur
Posts: 62
Joined: 15 Aug 2011, 08:14

Re: swf skin is not loading in the first time

Postby radiateur » 07 Jun 2013, 16:07

Well i do not have enough skill to struggle with this myself (you know i finally achieved to do a localtoglobal yesterday after 2 day of struggle, and i finally use getBound(); ;) )
I know that openspace load the avatar file since it fired, but i was really talking about loading when players connect to the global game swf (the one who fire openspace too) By this way e would load it 2 times, but the second time would come from the browser cache.

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 9 guests