Hi
Thanks for the info.
i’m doing the app for a university project. once it’s done you guys are more than welcome to it.
it is pretty messy code atm i haven’t done object-oriented code in quite a while and things like the keyboard are hard coded (which i know is far from good...a little bit of xml and actionscript would be better) but time is now my biggest enemy with the work.
I’ve found this pretty entertaining so far and will hopefully help contribute once i’m done with uni (only a couple of months)...need to improve my hardware though...the screen is the bare minimum
also i have made a number of changes to Seth Sandlers class LockMedia - from grepping through the directory no one has made use of it aside from me, but i think it is a pretty useful class (a user can grab their personal space and move it around and any shapes currently owned (ie colliding with it) follow it.
original code
public class LockMedia {
public static function lockMediaFromCanvas(newParent:DisplayObject, oldParent:DisplayObject, thisChild:DisplayObject, locked:Boolean = false) {
if (locked == true) {
//Set Adjust position
var newPos = CoordinateTools.localToLocal(thisChild, newParent);
//Adjust scale
thisChild.scaleX = oldParent.scaleX * thisChild.scaleX;
thisChild.scaleY = oldParent.scaleY * thisChild.scaleY;
//Add to new parent (pop off of current parent/canvas);
newParent.addChild(thisChild);
//Adjust rotation
thisChild.rotation += oldParent.rotation;
//Adjust position
thisChild.x = newPos.x;
thisChild.y = newPos.y;
}
if (locked == false) {
//Adjust scale
thisChild.scaleX = thisChild.scaleX/oldParent.scaleX;
thisChild.scaleY = thisChild.scaleY/oldParent.scaleX;
//Set Adjust position
var newPos = CoordinateTools.localToLocal(thisChild, oldParent);
thisChild.x = (newPos.x);
thisChild.y = (newPos.y);
//Adjust rotation
thisChild.rotation -= oldParent.rotation;
//Add back to old parent (pop back onto old parent/canvas);
oldParent.addChild(thisChild);
}
}
}
}
for my application i found that the scaling and rotation had not worked as expected… i am unsure whether it is because the code is untested/wrong or because he wrote it with something different in mind.
my version
package app.core.action{
import flash.display.Sprite;
import flash.display.*;
import flash.geom.Point;
import app.core.utl.CoordinateTools;
public class LockMedia {
public static function lockMediaFromCanvas(newParent:DisplayObject, oldParent:DisplayObject, thisChild:DisplayObject, locked:Boolean = false) {
if (locked == true) {
//Set Adjust position
var newPos = CoordinateTools.localToLocal(thisChild, newParent);
//Adjust scale
thisChild.scaleX = thisChild.scaleX / newParent.scaleX;
thisChild.scaleY = thisChild.scaleY / newParent.scaleY;
//Add to new parent (pop off of current parent/canvas);
newParent.addChild(thisChild);
//Adjust rotation
thisChild.rotation -= newParent.rotation;
//Adjust position
thisChild.x = newPos.x;
thisChild.y = newPos.y;
}
if (locked == false) {
//Adjust scale
thisChild.scaleX = thisChild.scaleX * newParent.scaleX;
thisChild.scaleY = thisChild.scaleY * newParent.scaleY;
//Set Adjust position
var newPos = CoordinateTools.localToLocal(thisChild, oldParent);
thisChild.x = (newPos.x);
thisChild.y = (newPos.y);
//Adjust rotation
thisChild.rotation += newParent.rotation;
//Add back to old parent (pop back onto old parent/canvas);
oldParent.addChild(thisChild);
}
}
}
}
i haven’t tested this with the scenario of the oldParent having a scale X/Y other than 1.
my question is how would i contribute this version to the community would i make it my own class and submit it along side his or would i suggest replacing his (last thing i want to do is step on someone’s toes...especially if the code is correct for his particular application). i have never done any contributions to a project, so i don’t really know the dynamics of working in a community (also haven’t really used svn but i’m sure that’s easy enough to understand).