I might not write English well because I’m an Asian. and I have some problem about my project.
I am just a beginner.
I saw Flash on website in Thailand.
this!!
http://79room.net/throwMe_step4.swf
But it used Actionscript 2.0
content.setMask(mcMask);
content.onPress = function()
{
var left = mcMask._x+(mcMask._width-this._width);
var top = mcMask._y;
var right = mcMask._x;
var bottom = mcMask._y;
this.startDrag(false,left,top,right,bottom);
this.oldMouseX = _xmouse;
this.onEnterFrame = findDelta;
}
content.onRelease = content.onReleaseOutside = function()
{
this.stopDrag();
this.onEnterFrame = slowDown;
}
function findDelta()
{
this.deltaX = (_xmouse - this.oldMouseX)*10;
this.oldMouseX = _xmouse
}
function slowDown()
{
if(this._x + this.deltaX > mcMask._x)
this.deltaX = mcMask._x - this._x;
if(this._x + this.deltaX < mcMask._x+mcMask._width-this._width)
this.deltaX = mcMask._x+mcMask._width-this._width-this._x;
if(Math.abs(this.deltaX * 0.8) > 0.1)
{
this._x+=this.deltaX*0.2;
this.deltaX*=0.8;
}
else
delete this.onEnterFrame;
}
I would like to do this project by Actionscript 3.0
And this is code as3
import flash.events.MouseEvent;
import flash.events.Event;
var Left:int = McMask.x + (McMask.width - Rectant.width);
var Top = McMask.y;
var Right = McMask.x;
var Bottom = McMask.y;
var rectangle:Rectangle = new Rectangle(Right,Bottom,Left,Top);
var oldMouseX:int;
var deltaX:int;
Rectant.mask = McMask;
Rectant.addEventListener(MouseEvent.MOUSE_DOWN, RectantDown);
function RectantDown(event:MouseEvent):void
{
Rectant.addEventListener(MouseEvent.MOUSE_UP, RectantUp);
Rectant.removeEventListener(MouseEvent.MOUSE_DOWN, RectantDown);
Rectant.startDrag(false,rectangle);
oldMouseX = mouseX;
Rectant.addEventListener(Event.ENTER_FRAME, RectantMove);
}
function RectantUp(event:MouseEvent):void
{
Rectant.addEventListener(MouseEvent.MOUSE_DOWN, RectantDown);
Rectant.removeEventListener(MouseEvent.MOUSE_UP, RectantUp);
Rectant.stopDrag();
Rectant.removeEventListener(Event.ENTER_FRAME, RectantMove);
Rectant.addEventListener(Event.ENTER_FRAME, onSlowDown);
}
function RectantMove(event:Event):void
{
deltaX = mouseX - oldMouseX;
oldMouseX = mouseX;
}
function onSlowDown(event:Event):void
{
if (Rectant.x + deltaX > McMask.x)
{
deltaX = McMask.x - Rectant.x;
}
if (Rectant.x + deltaX < McMask.x + McMask.width - Rectant.width)
{
deltaX = McMask.x + McMask.width - Rectant.width - Rectant.x;
}
if (Math.abs(deltaX * 1) > 0.1)
{
Rectant.x += deltaX * 0.2;
deltaX *= 1;
}
else
{
removeEventListener(Event.ENTER_FRAME, onSlowDown);
}
}
And this is my project.
http://79room.net/TestThrow.swf
But it’s not work!!! it’s not looks like original project.
please tell me. How can I solve it? and explain to me please.
Thank you very much!!