home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 112
/
jogo-disk-112.iso
/
Games
/
pixieland_puzzle.swf
/
scripts
/
__Packages
/
someFrogs
/
Puzzles
/
JigsawGroup.as
next >
Wrap
Text File
|
2010-07-14
|
6KB
|
171 lines
class someFrogs.Puzzles.JigsawGroup extends someFrogs.Lake.MaskedPiece
{
static var symbolName = "JigsawGroup";
static var symbolOwner = someFrogs.Puzzles.JigsawGroup;
var className = "JigsawGroup";
var pieces_count = 1;
var rot_steps = 4;
var enabled = false;
var active = false;
function JigsawGroup()
{
super();
this.rot_angle = 360 / this.rot_steps;
if(this.groupProps.ri == undefined)
{
this.groupProps.ri = 0;
}
this._x = this.groupProps.x;
this._y = this.groupProps.y;
this.rotateGroup(this.groupProps.ri);
this.ini_depth = this.getDepth();
this.setEnabled(this._parent.enabled);
}
function setEnabled(eFl)
{
if(this.enabled != eFl)
{
this.enabled = eFl;
var _loc2_ = new Color(this.pic_mc);
if(eFl)
{
_loc2_.setTransform({ra:100,ga:100,ba:100});
this.onPress = this.IamPressed;
this.onRelease = this.onReleaseOutside = this.IamReleased;
}
else
{
this.onPress = this.onRelease = this.onReleaseOutside = null;
_loc2_.setTransform(this._parent.disabled_color);
§§push(this.stopDrag());
}
}
}
function IamPressed()
{
this._parent.childPressed(this);
this.startDrag(false,this.drag_area_fixed.l,this.drag_area_fixed.t,this.drag_area_fixed.r,this.drag_area_fixed.b);
}
function IamReleased()
{
this.put_me_to(this._x,this._y);
this._parent.childReleased(this);
this.stopDrag();
}
function blink(steps)
{
if(steps > 0)
{
this.blink_cnt = Number(steps);
}
if(this.blink_cnt > 0)
{
if(this.onEnterFrame != this.blink)
{
this.onEnterFrame = this.blink;
}
else
{
this.blink_cnt = this.blink_cnt - 1;
var _loc2_ = 50 * Math.sin(1.5 * this.blink_cnt);
this.blinkColor(_loc2_);
}
}
else
{
delete this.onEnterFrame;
}
}
function takeMe(obj)
{
if(obj != this)
{
this.extendMaskedArea(obj.piecesArr);
this.groupProps.xb = Math.min(this.groupProps.xb,obj.groupProps.xb);
this.groupProps.yb = Math.min(this.groupProps.yb,obj.groupProps.yb);
this.groupProps.xe = Math.max(this.groupProps.xe,obj.groupProps.xe);
this.groupProps.ye = Math.max(this.groupProps.ye,obj.groupProps.ye);
this.ini_depth = Math.min(this.ini_depth,obj.ini_depth);
this.pieces_count += obj.pieces_count;
this.put_me_to(this._x,this._y);
}
}
function rotateGroup(ccw)
{
this.put_me_to(this._x,this._y);
ccw = Math.abs(ccw) <= 0 ? 0 : ccw;
this.groupProps.ri = Math.round(ccw + this.groupProps.ri);
var _loc2_ = Math.floor(this.groupProps.ri / this.rot_steps);
if(_loc2_ != 0)
{
this.groupProps.ri -= _loc2_ * this.rot_steps;
}
var _loc3_ = this.rot_angle * this.groupProps.ri;
this._rotation = _loc3_;
var _loc4_ = this.rot_tranform(_loc3_,{cx:(this.groupProps.xb + this.groupProps.xe) / 2,cy:(this.groupProps.yb + this.groupProps.ye) / 2});
this.put_me_to(this.groupProps.x + _loc4_.x,this.groupProps.y + _loc4_.y);
}
function put_me_to(x, y)
{
this.displacement = this.rot_tranform(this._rotation,{cx:(this.groupProps.xb + this.groupProps.xe) / 2,cy:(this.groupProps.yb + this.groupProps.ye) / 2});
this.fix_drag_area();
x = Math.min(x,this.drag_area_fixed.r);
x = Math.max(x,this.drag_area_fixed.l);
y = Math.min(y,this.drag_area_fixed.b);
y = Math.max(y,this.drag_area_fixed.t);
this._x = x;
this._y = y;
this.groupProps.x = x - this.displacement.x;
this.groupProps.y = y - this.displacement.y;
}
function fix_drag_area(Void)
{
var _loc4_ = this.rot_angle * this.groupProps.ri;
var _loc3_ = this.rot_tranform(_loc4_,{cx:(this.groupProps.xe - this.groupProps.xb) / 2,cy:(this.groupProps.ye - this.groupProps.yb) / 2});
var _loc2_ = new Object();
_loc2_.xb = Math.min(this.groupProps.xb + _loc3_.x,this.groupProps.xe - _loc3_.x);
_loc2_.yb = Math.min(this.groupProps.yb + _loc3_.y,this.groupProps.ye - _loc3_.y);
_loc2_.xe = Math.max(this.groupProps.xb + _loc3_.x,this.groupProps.xe - _loc3_.x);
_loc2_.ye = Math.max(this.groupProps.yb + _loc3_.y,this.groupProps.ye - _loc3_.y);
this.drag_area_fixed = new Object();
this.drag_area_fixed.l = this._parent.dragArea.l + this.displacement.x - _loc2_.xb;
this.drag_area_fixed.t = this._parent.dragArea.t + this.displacement.y - _loc2_.yb;
this.drag_area_fixed.r = this._parent.dragArea.r + this.displacement.x - _loc2_.xe;
this.drag_area_fixed.b = this._parent.dragArea.b + this.displacement.y - _loc2_.ye;
}
function rot_tranform(a, to)
{
a = a * 3.141592653589793 / 180;
var _loc4_ = Math.atan(to.cy / to.cx);
var _loc3_ = Math.sqrt(Math.pow(to.cx,2) + Math.pow(to.cy,2));
return {x:to.cx - _loc3_ * Math.cos(a + _loc4_),y:to.cy - _loc3_ * Math.sin(a + _loc4_)};
}
function activeColor(act)
{
var _loc2_ = new Color(this.ground_mc);
if(act)
{
_loc2_.setRGB(Number(this.borderSelected));
}
else
{
_loc2_.setRGB(Number(this.border));
}
}
function blinkColor(vl)
{
var _loc3_ = new Color(this);
var _loc2_ = String(vl);
_loc3_.setTransform({rb:_loc2_,gb:_loc2_,bb:_loc2_});
}
function size(Void)
{
super.size();
}
function init(Void)
{
this.displacement = {x:0,y:0};
super.init();
}
}