The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Extremely rudimentary ActionScript concept

AgelessDrifterAgelessDrifter Registered User regular
edited December 2007 in Help / Advice Forum
This question will strike many of you as utterly retarded, I've no doubt, but I've really, *really* tried to find the solution without having to ask for it, to no avail.

I have an animation. It is 100 frames. Within the animation, I have a movieclip type symbol of a man, which is ten frames. The man is a stick-figure. His head, torso (arms+body), and legs, are each their own movie clips. Each of those is ten frames.

On the main timeline, the Man movieclip walks across the stage. His legs and arms move in sync, in their ten-frame looped animation.

At 70 frames, on the main timeline, the man stops moving across the stage.

How do I make his legs and arms stop moving at this point?

"I hate when people use quotes in their signatures." - AgelessDrifter
AgelessDrifter on

Posts

  • AgelessDrifterAgelessDrifter Registered User regular
    edited December 2007
    halp =/

    AgelessDrifter on
    "I hate when people use quotes in their signatures." - AgelessDrifter
  • AdrienAdrien Registered User regular
    edited December 2007
    Do you need to use AS to do this? If this is the kind of functionality you need, I'm guessing you don't have big plans for it. It's probably simpler to avoid the script and just change the symbol to a Graphic at that point.

    If you do need to use script, for whatever reason, I'd suggest finding a tutorial, as it'd likely take longer to explain it. This is very basic stuff.

    Adrien on
    tmkm.jpg
  • RevolutionaryRevolutionary Registered User regular
    edited December 2007
    At frame 70, you would add some code similar to this:

    _root.man.leg.stop();

    This would be ActionScript 2.0, and even that I haven't used in a while so it may be slightly different.

    Revolutionary on
  • AgelessDrifterAgelessDrifter Registered User regular
    edited December 2007
    Do you need to use AS to do this? If this is the kind of functionality you need, I'm guessing you don't have big plans for it. It's probably simpler to avoid the script and just change the symbol to a Graphic at that point.

    If you do need to use script, for whatever reason, I'd suggest finding a tutorial, as it'd likely take longer to explain it. This is very basic stuff.
    Thanks, I hadn't thought of that.

    I did look through a number of tutorials, but they all seem to skip over the type of things I'm trying to figure out (IE very basic stuff).

    Really, all I'm trying to do with this project is get a method down for basic animation. I asked a question here a few weeks ago about an animation I was working on, in which I was using a one-level configuration (no movie clips or embedded movie clips), and between here and a few other places, the consensus seemed to be that working in embedded movie clips is the way to go for most animations. So that's what I'm trying to learn to do. I'm just not familiar with the process.

    AgelessDrifter on
    "I hate when people use quotes in their signatures." - AgelessDrifter
  • AgelessDrifterAgelessDrifter Registered User regular
    edited December 2007
    Turning it into a graphic didn't help. =/



    The animation for that clip (the man as a whole) stops, but the embedded clips within that graphic (the feet and arms) still play. Is the only way to stop that going to be to make the foot motion 70 frames long? It seems like there would have to be a simpler and more practical way.




    Another question: what is the syntax error in this code? I keep getting a return error of "Extra characters found after program". I see nothing wrong here -- in fact, I ripped it straight from a tutorial.
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)) {
    this._y -= 4;
    }
    if (Key.isDown(Key.DOWN)) {
    this._y += 4;
    }
    if (Key.isDown(Key.LEFT)) {
    this._x -= 4;
    }
    if (Key.isDown(Key.RIGHT)) {
    this._x += 4;
    }
    
    }
    

    AgelessDrifter on
    "I hate when people use quotes in their signatures." - AgelessDrifter
  • TechnicalityTechnicality Registered User regular
    edited December 2007
    One simple way is to create a keyframe at 70, click on the man, select modify->break apart from the main menu, then click on the arms/feet and modify->break apart them too.

    The most elegant way is the one Revolutionary mentioned though. The key with doing it that way is to make sure you give everything its own instance name (in the movieclip properties), then just stop the animation on the main timeline with:
    man.stop();
    man.legs.stop();
    man.arms.stop();
    (where your animated man movieclip is named "man", and it contains movieclips named "arms" and "legs")


    Also, there is no syntax error in that code. I doublechecked it by drawing a box, converting it to movieclip, clicking on box, pasting in the code and it worked fine. If you are using ActionScript 2 your problem is definitely elsewhere.

    Technicality on
    handt.jpg tor.jpg

  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited December 2007
    Ageless are you doing Actionscript 3 or something?

    First of all, don't turn anything into graphics, that would be dumb.

    Second, don't use _root. - Actionscript should be centralized and _root encourages you to just throw shit wherever in your Flash documents making them harder to maintain. It doesn't really matter in something this small but you might as well get it out of your system.


    Your problem is you have your man animating and when you stop him on frame 70 his appendages keep moving.

    Well, you didn't specify how you were animating the man, but let's assume you have the man as an MC and you are tweening him across the stage, and within the "man" movie clip you have the arms and legs on an infinite loop.

    First of all you want to make sure that your movie clips on the stage have Instance Names, you can find this in the bottom panel of Flash towards the left, name them mc_man, mc_leg, etc.

    Now, on the frame wherein your guy stops moving, create a fresh layer if you don't already have an Actionscript layer and you basically want to create a series of stops on that frame.

    So, if your Man is stopping automatically because it's the end of the tween, then all you need to do is say

    man.leg.stop();

    and so on.

    As for this
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)) {
    this._y -= 4;
    }
    if (Key.isDown(Key.DOWN)) {
    this._y += 4;
    }
    if (Key.isDown(Key.LEFT)) {
    this._x -= 4;
    }
    if (Key.isDown(Key.RIGHT)) {
    this._x += 4;
    }
    
    }
    

    I think you are going about this the wrong way (at least in AS2). You want this key press events to only exist after a certain frame?

    What you would do (or rather, what I would do) is establish these event handlers on Frame 1 of the main timeline. Then you add a line something along the lines of

    this.enabled = false;

    Where this is the MC who has these event handlers.

    This SHOULD prevent this event handler code from executing until you re-enable the MC.

    Then you just proceed to the frame where you want the events to start working and add in a

    this.enabled = true;

    I think that is sound unless you are dealing with AS3, which had it's own unique brand of lunacy.

    Jasconius on
    this is a discord of mostly PA people interested in fighting games: https://discord.gg/DZWa97d5rz

    we also talk about other random shit and clown upon each other
Sign In or Register to comment.