Jump to content
Search Community

Leo75

Members
  • Posts

    21
  • Joined

  • Last visited

Leo75's Achievements

0

Reputation

  1. Thanks a lot! Its looking great. Yes, the code is quite messy as i told u b4. I plan to refactor it as i have more time, since it is just a hobbie. Thanks again. Kind regards, Leo.
  2. Any light at the end of the tunnel? The Matrix just moves on negative positions. The Matrix cant have x or y positives. Kind regards. Leo.
  3. I am pretty sure its something simple that i got stuck with or i just cant see... There is a small limitation, that u will see, that the matrix cant move beyond 0,0. Just less than 0,0.
  4. Thanks for the help. The code is a little messy, but once u run it u will understand what i am trying to do. Its messy but it is simple. Everything that u need, its attached. I just started with kirupa. Kind regards, Leo. to_green_sock.zip
  5. Would u mind if i send u the entire code that i am using so u can have a look why it is not working? It worked like a charm with the example that i gave. But with the main app that i am working with as a hobbie, it just didnt work.
  6. For some reason that i dont know, it works with the example that i provided but not with what i am doing...
  7. Thanks A LOT ! Working great! Regards, Leo.
  8. Just like google maps... lets say. Throws the mc and it will eventually stop smoothly...
  9. I just tested it... Looking nice BUT its coming back to a certain position. I need it to just go and then stop smoothly... I am able to move it around, but keeps comming back to a certain position... Here is the code: import com.greensock.*; import com.greensock.plugins.*; import com.greensock.easing.*; import flash.display.*; import flash.geom.*; import flash.events.*; import flash.utils.*; TweenPlugin.activate([ThrowPropsPlugin]); var bounds:Rectangle = new Rectangle(0, 0, 800, 600); var t1:uint, t2:uint, y1:Number, y2:Number, x1:Number, x2:Number, xOverlap:Number, xOffset:Number, yOverlap:Number, yOffset:Number; mc_square.addEventListener(MouseEvent.MOUSE_DOWN, start_drag); function mouseMoveHandler(event:MouseEvent):void { var y:Number = this.mouseY - yOffset; //if mc's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior) if (y > bounds.top) { mc_square.y = (y + bounds.top) * 0.5; } else if (y < bounds.top - yOverlap) { mc_square.y = (y + bounds.top - yOverlap) * 0.5; } else { mc_square.y = y; } var x:Number = this.mouseX - xOffset; if (x > bounds.left) { mc_square.x = (x + bounds.left) * 0.5; } else if (x < bounds.left - xOverlap) { mc_square.x = (x + bounds.left - xOverlap) * 0.5; } else { mc_square.x = x; } var t:uint = getTimer(); //if the frame rate is too high, we won't be able to track the velocity as well, so only update the values 20 times per second if (t - t2 > 50) { x2 = x1; x1 = mc_square.x; y2 = y1; t2 = t1; y1 = mc_square.y; t1 = t; } event.updateAfterEvent(); } function start_drag(e:MouseEvent):void { TweenLite.killTweensOf(mc_square); x1 = x2 = mc_square.x; xOffset = this.mouseX - mc_square.x; xOverlap = Math.max(0, mc_square.width - bounds.width); y1 = y2 = mc_square.y; yOffset = this.mouseY - mc_square.y; yOverlap = Math.max(0, mc_square.height - bounds.height); t1 = t2 = getTimer(); mc_square.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); mc_square.stage.addEventListener(MouseEvent.MOUSE_UP, stop_drag); } function stop_drag(e:MouseEvent):void { mc_square.stage.removeEventListener(MouseEvent.MOUSE_UP, stop_drag); mc_square.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); var time:Number = (getTimer() - t2) / 1000; var xVelocity:Number = (mc_square.x - x2) / time; var yVelocity:Number = (mc_square.y - y2) / time; ThrowPropsPlugin.to(mc_square, {throwProps:{ y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:300}, x:{velocity:xVelocity, max:bounds.left, min:bounds.left - xOverlap, resistance:300} }, ease:Strong.easeOut }, 10, 0.3, 1); } Amazing work u guys are doing! Thanks. Leo.
  10. Thanks a lot... the com folder is already in my fla folder... i am just wondering about the imports... which one to import... i am using the example that u pasted here that was from the code that i am trying to make drag and throw... Thanks for the attention and quick reply... Regards, Leo.
  11. I am back... so, using the previous example with the demo zip that i have now... how do i proceed? By the way, i am a newbie on AS3 Flash. Regards, Leo.
  12. Thanks, just got the bonus zip file. Is this a 24/7 forum? I will start working on it and will come back later. Kind regards, Leo.
×
×
  • Create New...