-
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);
}
}
-
.
Hi Cap,
I can you what that is straight away from having seen the files before.
It is the alignment of the avatars and the text box within the smiley character
-
.
-
Hmmm...
you mean I should change the registration point?
-
.
Cap,
If you look inside the smiley avatar you will see that the figure is situated well below the cntre and the text box takes up all of that area.
I have changed it in the above attached file, I move the male one frame forward so you can where he is, you might wish to put him back on the second frame, or make it invisible on that frame, it helps for alignment to be able to see it.
Last edited by fruitbeard; 11-29-2014 at 10:03 AM.
-
I more or less see what you mean and just aligned it differently, but I have rezised and decreased the size of the board clip and the character goes past its edge limits
-
.
Cap,
I would suggest that you make the board clip smaller than the whole movie as the smiley goes over the input box and over the user list.
Or you could always do some if else statements, if (smiley._y > stage.Height - smiley._height){ smiley._Y = stage.height - smiley._height}
and so on
-
That's what I want to do eventually to set up new variables and make the character bounce off the walls (the board clip's limits).
Right now , I've resized it to 800 x 600 but the character keeps going past it. That's what 's making me wonder. From the code pasted above, I thought the area is defined as the clip's limits.
-
.
Hi Cap,
you are missing some code to contain the mouse click.
PHP Code:
myMouse.onMouseDown = function() { if (inited) { if (!_global.isBusy) { if (board.hitTest(_root._xmouse, _root._ymouse)) { 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; }; } } } };
board.hitTest(_root._xmouse, _root._ymouse)
this will get you a step closer to what you are wanting.
-
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
|