Announcement Announcement Module
Collapse
No announcement yet.
Advance Movie Clip While Draging (AS3) Page Title Module
Move Remove Collapse
Search Search Module
Collapse

Advertisement Advertisement Module
Collapse

Latest Topics Latest Topics Module
Collapse

  • Elmore
    Reply to Feedback on portfolio pieces, please
    Elmore
    I'm going to be blunt because it won't do you any good if I sugar-coat the truth. I'm not in a position to hire anyone, so you can take my opinions for what they're worth, but my initial impression of...
    Today, 07:40 AM
  • left_hand_black
    Reply to Feedback on portfolio pieces, please
    left_hand_black
    this took an eternity....
    Today, 04:01 AM
  • Nobert
    Comment on The ellipse...
    Nobert
    KitchWitch!
    Yesterday, 11:31 PM
  • Nobert
    Reply to Experience vs education.
    Nobert
    Whatever it may mean coming from me, which isn't much, I support you in spirit. One of the reasons I got interested in graphic design was that I thought it was very much a "proof is in the pudding"...
    Yesterday, 11:30 PM
  • KitchWitch
    Reply to Portfolio Weeding
    KitchWitch
    Hi Kesey and welcome to GDF.

    We ask all new members to read very important links here and here. These explain the rules, how the forum runs and a few inside jokes. No, you haven't done anything...
    Yesterday, 10:32 PM

X
Conversation Detail Module
Collapse
  • 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

    Mediabistro A division of Prometheus Global Media home | site map | advertising/sponsorships | careers | contact us | help courses | browse jobs | freelancers | content | member benefits | reprints & permissions terms of use | privacy policy Copyright © 2015 Mediabistro Inc.
    Working...
    X