Hi Guys,
How would you check to see whether an avatar your mouse is hovering over is your avatar? How can you see who's avatar it is?
Thanks!
Checking Ownership of Avatar
Re: Checking Ownership of Avatar
The CLICK, ROLL_OVER, ROLL_OUT events contain the "id" parameter. That's the user id of the avatar's owner.
You can check if it is equal to the current user's id, like this:
You can check if it is equal to the current user's id, like this:
Code: Select all
if (evt.params.id == sfs.mySelf.id)
{
trace("that's me!");
}
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: Checking Ownership of Avatar
Hi Bax,
Thanks for replying. I've tried this, however it's not recognising 'Params'. Here's my basic setup:
/avatar/AvatarCharacter.as, Line 969, Column 46 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 972, Column 12 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 1002, Column 46 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 1005, Column 37 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 1005, Column 50 1120: Access of undefined property sfs.
Do you know what I'm missing?
Thanks!
Thanks for replying. I've tried this, however it's not recognising 'Params'. Here's my basic setup:
Code: Select all
package com.cavia.avatar {
import com.cavia.ui.ChatBubbleMC;
import com.cavia.ui.ThumbsUpIconMC;
import com.greensock.TimelineMax;
import com.greensock.TweenAlign;
import com.greensock.TweenMax;
import com.greensock.loading.DataLoader;
import com.smartfoxserver.openspace.engine.control.events.MapInteractionEvent;
import com.smartfoxserver.openspace.engine.model.avatar.Avatar;
import com.smartfoxserver.openspace.shared.view.items.Tile;
//Added to try and see if this has the missing 'Params'.
import com.smartfoxserver.openspace.engine.control.events.OpenSpaceEvent;
import com.cavia.openspace.AvatarManager;
import com.cavia.openspace.MapEditingManager;
import com.cavia.openspace.MapInteractionManager;
import com.cavia.openspace.MapsLoadingManager;
import com.cavia.smartfox.SFSEventHandlers;
import com.smartfoxserver.openspace.components.flash.OpenSpace;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
Code: Select all
public function onMouseOverAvatar(evt:MouseEvent)
{
trace("Here Nige - evt.params.id: " + evt.params.id);
trace("Here Nige - global.MyUserID: " + global.MyUserID);
if (evt.params.id != global.MyUserID)
{
this.pThumbIconMC.visible = true;
}
if (this.pThumbsupTimeline != null) {
this.pThumbsupTimeline.kill();
}
var myTimeline:TimelineMax = new TimelineMax();
pThumbsupTimeline = myTimeline;
myTimeline.insertMultiple([new TweenMax(this.pThumbIconMC, 0.5, {alpha: 1.0})], 0, TweenAlign.START, 0.0);
myTimeline.insertMultiple([new TweenMax(this.pThumbIconMC, 0.5, {alpha: 1.0})], 3.0, TweenAlign.SEQUENCE, 3.0);
myTimeline.insertMultiple([new TweenMax(this.pThumbIconMC, 0.5, {alpha: 0.0})], 3.0, TweenAlign.SEQUENCE, 6.0);
}
public function onMouseOutAvatar(evt:MouseEvent)
{
//this.pThumbIconMC.visible = false;
}
public function onMouseThumbsUp(evt:MouseEvent)
{
//this.pThumbIconMC.visible = false;
//trace("Thumbs Up Clicked lets try again");
//global.MyThumbsUp = 1;
trace("Here Nige - evt.params.id: " + evt.params.id);
trace("Here Nige - global.MyUserID: " + global.MyUserID);
if (global.MyThumbsUp > 0 && evt.params.id != sfs.mySelf.id)
{
var request:URLRequest = new URLRequest("http://www.somewebsite.com/game_site/php/clientUpdateUserInfo.php");
var data:URLVariables = new URLVariables();
data.a = "upThumb";
data.sk = "hash";
data.Dat = global.MyFacebookID;
request.data = data;
request.method = URLRequestMethod.POST;
var loader:DataLoader = new DataLoader(request, {name:"userInfo"});
loader.load();
global.MyThumbsUp -= 1;
global.CaviaMapViewer.ui_header.thumbs_up_count.text = String(global.MyThumbsUp);
}
}
/avatar/AvatarCharacter.as, Line 969, Column 46 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 972, Column 12 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 1002, Column 46 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 1005, Column 37 1119: Access of possibly undefined property params through a reference with static type flash.events:MouseEvent.
/avatar/AvatarCharacter.as, Line 1005, Column 50 1120: Access of undefined property sfs.
Do you know what I'm missing?
Thanks!
Re: Checking Ownership of Avatar
The returned events are of type AvatarEvent, not MouseEvent. That's why they don't contain the "params" property.
You need something like this:
and:
You need something like this:
Code: Select all
openSpace.addEventListener(AvatarEvent.ROLL_OVER, onAvatarRollOver);
and:
Code: Select all
public function onAvatarRollOver(evt: AvatarEvent):void
{
var avatarId:int = evt.params.id;
}
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Return to “OpenSpace v2 discussions and help”
Who is online
Users browsing this forum: No registered users and 30 guests