Announcement

Collapse
No announcement yet.

Advance Movie Clip While Draging (AS3)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Advance Movie Clip While Draging (AS3)

    Ok, so I've been trying to learn AS3 and I've got a pretty good handle on being able to "read" it, but I'm having a hard time trying to wrap my head around "writing" it.

    What I am trying to do is clicking on a movie clip and dragging it, but as I drag it I want it to advance frame by frame (for example, I drag the movie clip one pixel from the original place and the movie clip would advance one frame)

    So, right now, I just have a movie clip on my stage and here is the actionscript for it...

    Code:
    grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
    
    function dragGrow(event:MouseEvent):void
    {
        grow_mc.nextFrame();
        grow_mc.startDrag();
        grow_mc.removeEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
        grow_mc.addEventListener(MouseEvent.MOUSE_UP, dropGrow);
    }
    
    function dropGrow(event:MouseEvent):void
    {
        grow_mc.stopDrag();
        grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
        grow_mc.removeEventListener(MouseEvent.MOUSE_UP, dropGrow);
    }
    Of course, it only advances one frame on the MOUSE_DOWN, so to get it to advance again I would need to "drop" it and then click on it to start dragging.

    Also, I wonder, should I just make a mathematical function since the tween is just scaling the object?

    Just kind of stuck.. any insight would be much appreciated. Thanks in advance.
    [insert clever signature here]

  • #2
    Code:
    grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
    
    function dragGrow(event:MouseEvent):void
    {
        grow_mc.startDrag();
        grow_mc.removeEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
        grow_mc.addEventListener(MouseEvent.MOUSE_UP, dropGrow);
        
        
        grow_mc.addEventListener(MouseEvent.MOUSE_MOVE, advanceGrow);
        function advanceGrow(event:MouseEvent):void
        {
            grow_mc.nextFrame();
        }
    }
    
    function dropGrow(event:MouseEvent):void
    {
        grow_mc.stopDrag();
        grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
        grow_mc.removeEventListener(MouseEvent.MOUSE_UP, dropGrow);
    }
    Ok, so made a couple of changes... and I got it to advance while dragging... I'm going to keep tweaking with it though because it would be kind of cool for it to be relative to a certain point, like if I could make it appear as if the user was "dragging" the object closer to them... so when you drag it to the right it grows, but when you drag it to the left it shrinks.

    Sorry if this thread is annoying, but I figure in the least it could potentially spark a couple of ideas or answer a future question.
    [insert clever signature here]

    Comment

    Search

    Collapse

    Sponsor

    Collapse

    Incredible Stock

    Latest Topics

    Collapse

    • John G
      Reply to Tips for my website
      John G
      well, 933px width on the footer looks off. My QA guys would give me hell about 'outline:0'. And there's some weird crap happening with error messaging in the map.
      QA would also give me crap about...
      Today, 02:04 AM
    • PrintDriver
      Reply to Chinese last name and racism.
      PrintDriver
      Because I do serious work for serious clients, they want to work with serious professionals.
      It's not that I don't try to find the folks behind those aliases. But time is money and I'm usually only...
      Today, 01:22 AM
    • PrintDriver
      Reply to Just Graduated... What Now?
      PrintDriver
      E, I've found lately that young graduates have no idea what direction they want to go in this field. They just don't know what is available to them out there.

      Kira,
      This University...
      Today, 12:07 AM
    • PrintDriver
      Reply to Anyone minds critiquing this Behance Project of Mine??
      PrintDriver
      Ah, sorry. I forget you aren't from around here.

      The LinkedIn thing, if you scroll down has the usage rules showing clear space and whatnot.
      The download is how they package their logo...
      Yesterday, 11:33 PM
    • PrintDriver
      Comment on Two little questions concerning the Pen Tool.
      PrintDriver
      I'd use the Blob brush, and the convert anchor tool more than the pen tool. And a Wacom.
      About 30-45 minutes maybe.

      It's quite possible live trace would do an adequate job on something...
      Yesterday, 11:10 PM
    GDF A division of Mediabistro Holdings Adweek | Mediabistro | Clio | Film Expo Group Contact Us | Terms of Use | Privacy Policy Copyright 2016 Mediabistro Holdings
    Working...
    X