|
-
coordinate problem
Hi,
https://onedrive.live.com/redir?resi...int=file%2cfla
I'm not sure if I'm doing this right, but this link here is to view the file I can't post here due to size limitations.
I'm having a problem with my file where I'm attaching a clip on stage to then move around depending on some variables I don't seem to understand.
The mentioned clip is a smiley in a chat and I'd like to limit its moving range attaching it to a board clip on stage instead of the main timeline, but my smiley still keeps going past the bottom screen. I can't see the reason why.
This is the code for setting up the avatar smiley. Appreciate anyone seeing where the issue is.
Code:
var areaW:Number = board._width;
var areaH:Number = board._height;
var avatarW:Number = 40;
var avatarH:Number = 40;
var myMouse:Object = {};
myMouse.onMouseDown = function() {
if (inited) {
if (!_global.isBusy) {
var px:Number = Math.round(board.avatarMC._xmouse);
var py:Number = Math.round(board.avatarMC._ymouse);
smartfox.setUserVariables({px:px, py:py, init:false});
onEnterFrame = function ():Void {
var floor:Function = Math.floor;
myAvatar._x += (px-myAvatar._x)/6;
myAvatar._y += (py-myAvatar._y)/6;
};
}
}
};
smartfox.onJoinRoom = function(roomObj:Object)
{
cleanAvatars();
var roomId:Number = roomObj.getId();
var userList:Object = roomObj.getUserList();
resetRoomSelected(roomId);
_global.currentRoom = roomObj;
currentRoom.htmlText = "Current room: <b>" + roomObj.getName() + "</b>";
userList_lb.removeAll();
for (var i:String in userList)
{
var user:User = userList[i];
var uName:String = user.getName();
var uId:Number = user.getId();
userList_lb.addItem(uName, uId);
if (uName != _global.myName)
{
var uVars:Object = user.getVariables();
var mc:MovieClip = avatarMC.attachMovie("smiley", "smiley_" + uId, Number(uId));
mc._x = uVars.px;
mc._y = uVars.py;
mc.character.gotoAndStop(uVars.gender);
mc.name.text = uName;
}
}
setupMyAvatar();
}
smartfox.onUserEnterRoom = function(fromRoom, user)
{
var userId:Number = user.getId();
var userName:String = user.getName();
userList_lb.addItem(userName, userId);
userList_lb.sortItemsBy("label", "ASC");
updateRoomStatus(fromRoom);
var mc:MovieClip = avatarMC.attachMovie("smiley", "smiley_" + userId);
mc._x = user.variables["px"];
mc._y = user.variables["py"];
mc.name.text = userName;
mc.character.gotoAndStop(user.variables["gender"]);
}
var inited:Boolean = false;
var myAvatar:MovieClip;
smartfox.onUserVariablesUpdate = function(user:User)
{
var currRoom:Number = this.getActiveRoom();
var id:Number = user.getId();
var uVars:Object = user.getVariables();
var mc:MovieClip;
if (uVars.init)
{
mc = avatarMC.attachMovie("smiley", "smiley_" + id, Number(id));
mc._x = uVars.px;
mc._y = uVars.py;
mc.character.gotoAndStop(uVars.gender);
mc.name.text = user.getName();
}
else
{
mc = avatarMC["smiley_" + id];
onEnterFrame = function ():Void
{
var floor:Function = Math.floor;
mc._x += (uVars.px - mc._x) / 6;
mc._y += (uVars.py - mc._y) / 6;
};
}
}
function setupMyAvatar()
{
if (!inited)
{
myAvatar = board.avatarMC.attachMovie("smiley", "smiley_" + smartfox.myUserId, 99999);
myAvatar._xscale = 50;
myAvatar._yscale = 50;
myAvatar.character.gotoAndStop(gender);
myAvatar.name.text = _global.myName;
var px:Number = Math.round(Math.random() * (areaW - myAvatar._width / 2));
var py:Number = Math.round(Math.random() * (areaH - myAvatar._height / 2));
myAvatar._x = px;
myAvatar._y = py;
smartfox.setUserVariables({px:px, py:py, gender:gender, init:true});
// Testing ONLY!!!
trace("Variables SET")
trace("---------------------------------------------")
trace("myID : " + smartfox.myUserId)
var self = smartfox.getRoom(smartfox.activeRoomId).getUser(smartfox.myUserId)
trace("User Obj: " + self)
trace("Vars: " + self.variables)
trace("px: " + self.variables["px"])
trace("py: " + self.variables["py"])
trace("Gender: " + self.variables["gender"])
inited = true;
Mouse.addListener(myMouse);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|