onAdminMessage Depth

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Joff
Posts: 5
Joined: 03 Mar 2006, 15:46

onAdminMessage Depth

Postby Joff » 03 Mar 2006, 16:34

Hi people, just learning things at the moment.

Ive got a game running and when you login and the username is taken the admin message pops up telling me its in use but when im logged in and i swear the admin message doesnt appear.

I can see my userlist go grey as if its disabled but thats all.

I think its to do with the depth of the popup window

anybody got an idea on how to resolve it? ive tried changing the 9999 in the showWindow function but no joy.

Thanks

P.S. Has this forum got a search function?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Mar 2006, 17:15

Hello Joff,
anybody got an idea on how to resolve it? ive tried changing the 9999 in the showWindow

question... do you handle the onAdminMessage event? it's not clear from your message.
P.S. Has this forum got a search function?


Of course. See the top menu? The 2nd option from the left, right after FAQ

:)
Lapo
--
gotoAndPlay()
...addicted to flash games
Joff
Posts: 5
Joined: 03 Mar 2006, 15:46

Postby Joff » 03 Mar 2006, 19:55

Oh yeah! Thanks

Yeah i do handle it.

At the moment im making the admin message appear in my chat window so i know its working.

Im 99% sure its the depth because if i do _root.getNextHighestDepth() its the number after the max depth that attachmovie will work in which is 1048575.

How can reset all my depths?

Thanks
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 04 Mar 2006, 08:33

This is a flash issue.
Beacause you use components (the chat examples that come with SFS do - the scrollbar, the roomList etc), a component placed at authorTime on stage will recieve a very high depth when compiled.
Then everything get's even worse. Even if you manage to attach (wich you should be able) a movieClip at the getNextHighestDept() that depths are usualy nonRemovable depths and you won't be able to remove a movieClip from such a depth with myMc.removeMovieClip() unless you make a swapDepth before to put that mc on a removable depth like 666 :P.

You have multiple options.
1. The nasty One.
Placeing all your elements from ActionScript and not directly on stage.
This gives you control over the depths of all elements.

2. Buidling ca depth controler that sorts your objects based on a property like myRealDepth set by you on each object and issues a mc.swapDepths(mc.myRealDepth) for each element from the stage. Problem is that i don't know if you can attach your own properties to componets...

3. The easy One.
Arrangeing your stage into movieClips. Like all the chat ellements should be into a movieClip named chat in _root.
Then place other elements (even empty movieClip placeholders) on stage at any depth you want. You could have movieClips like board, playerInfo etc... This depths will be respected when you compile your swf and is the most organized way to place your elements on stage with as little extra code as possible (in my oppinion).

Hope it helps :)
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
Joff
Posts: 5
Joined: 03 Mar 2006, 15:46

Postby Joff » 06 Mar 2006, 13:12

Thanks

Ive started to put things in movieclips and setting their depth

I still seem to be getting

_root.getNextHighestDepth(): 1048576

How can i work out which item is making my next depth really high?

Is it just a case of trial and error?

Ta
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 06 Mar 2006, 13:23

The flash components are doing this ;)
If you remove the components from your stage then the maxDepth should not be such a high number.
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
Joff
Posts: 5
Joined: 03 Mar 2006, 15:46

Postby Joff » 06 Mar 2006, 13:26

But i need them, ive put them in movieclips and given tha clip a depth

do you mean use AS to put them on the stage?
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 06 Mar 2006, 14:09

Sorry for this. It seems I was talking about somethings withouth having a full grasp on the subject.
The fact is that I don't usually use components.
When I encountered this problem I just made a container on a layer above the componets and user container.getNextHighestDepth();
I never messed with the components' depths.

Weird problem is that _root.getNextHighestDepth() returns a big number even if you don't have a component on stage (you added it on stage, but then deleted it at a later time).
So an empty stage would return that same highest depth. I didn't knew this until I tested it now.

So, part of my previous post is kind of stupid. But you can still use empty containers placed at authoring time and attach your movieclips directly into them instead using the root that gives you this kind of problems. Just don't attach directly into _root when you use components, because this weird problem appears. Even it my component doens't "live" in the stage at compile time it still "disturbs" the getNextHighestDepth();

Another wierd thing is the following setup.
mc1 in _root. Attach a button component (or any component) o stage.
_root.getNextHighestDepth(); - returns 1048576
mc1.getNextHighestDepth(); - returns 0

// delete the component from your stage (but not from library
the output is the same
// paste the component into the mc1.
I would have expected the output to be 0 and 1048576 but it's the same as the first one.

So it seems that only my third method "the easy one" would work fine... although I wouldn't bet all my money on it 8)
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Mar 2006, 14:27

mmm... interesting! :shock:

I've tried a little more experiment:

1 - create a shiny new flash doc
2 - trace(_root.getNextHighestDepth())

It says --> 0

Then:

1 - drag a component on stage
2 - remove it from stage

It says --> 1048576

Now if your run this code:

Code: Select all

for (var i in this)
{
   trace(i + " -> " + this[i] + " --> " + typeof(this[i]) + " | lev: " + this[i].getDepth() )
}


and surprise, surprise! Here's the output:

$version -> WIN 8,0,22,0 --> string | lev: undefined
reserved -> _level0.reserved --> movieclip | lev: 1048575
focusManager -> _level0.focusManager --> movieclip | lev: 1048574

a couple of objects are reserving those level numbers, hence the problem

hope it helps... at least to understandy why ...

:?
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 06 Mar 2006, 15:36

Thing is that this is how components work. If you drag a component into an empty stage and then delete it you will notice that your swf is not 0kb in size when exported. The component is actually exported for the first frame. You need to delete it from the library or uncheck the Export For ActionScript checkbox in the Linkage pannel.

All the attached classes gets compiled into the swf if you don't do this. Weird thing is that the depths shouldn't be affected if the classes aren't actually instantiated. But this is a fact, we now know of it and you can only try to workaround this as if was any other limitation.
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Mar 2006, 15:55

Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 111 guests