A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: currentFrameLabel, different layers

Hybrid View

  1. #1
    Member
    Join Date
    May 2009
    Posts
    34

    currentFrameLabel, different layers

    In my Timeline I have 4 layers, each with labels on different keyframes. I have the following code, which obeys to my first layer:

    Actionscript Code:
    private function Frame(event:Event) {

                if (currentFrameLabel!=null) {

                    obj.doSomething();
                }
            }

    How can I make AS3 to detect the specific "currentFrameLabel" of a named layer?

    Thanks in advance.

  2. #2
    MindGem Graphics Inc. JediMind's Avatar
    Join Date
    Nov 2001
    Location
    Stockholm/Sweden
    Posts
    407
    The Layer names is just in for the developer view, it's not anything that will show up or be trackable in playtime. Your Labels is the runtime version of layers.

    Inside a MovieClip you can set a label for a frame, say "gameover".

    if(life<1)
    {
    movieClipName.gotoAndStop("gameover");
    }

  3. #3
    MindGem Graphics Inc. JediMind's Avatar
    Join Date
    Nov 2001
    Location
    Stockholm/Sweden
    Posts
    407
    if(MovieClipName.currentFrameLabel != "null")
    {
    trace("well, it's not the frame called "null" anyways. And besides, you can't use Datasaved names for your vars or labels");
    }

  4. #4
    Member
    Join Date
    May 2009
    Posts
    34
    Thanks JediMind,

    This complicates my plans, as I'm working with a AS3 to work only on keyframes. For this I label every keyframe on a layer and run the code (if currentFrameLabel != null). If what you say is true, and labels are the only thing close to "layer", then I'd have to label several keyframes with the same name. This throws warnings, however.

    Why would I have to name every keyframe on a layer as "xxx? Well, I have several instances that have to work during the keyframes of different layers. This makes it impossible for my code to detect if the currentframeLabel is not null and of some name, if AS3 doesn't allow me to use duplicate label names.

    Any suggestions, please?

  5. #5
    MindGem Graphics Inc. JediMind's Avatar
    Join Date
    Nov 2001
    Location
    Stockholm/Sweden
    Posts
    407
    Quote Originally Posted by protoemocional View Post
    Thanks JediMind,

    This complicates my plans, as I'm working with a AS3 to work only on keyframes. For this I label every keyframe on a layer and run the code (if currentFrameLabel != null). If what you say is true, and labels are the only thing close to "layer", then I'd have to label several keyframes with the same name. This throws warnings, however.

    Why would I have to name every keyframe on a layer as "xxx? Well, I have several instances that have to work during the keyframes of different layers. This makes it impossible for my code to detect if the currentframeLabel is not null and of some name, if AS3 doesn't allow me to use duplicate label names.

    Any suggestions, please?

    Say you have 3 keyframes where only the middle one is called "christmas".
    You could go theoreticly like this,
    function Test()
    {
    if(currentFrameLabel != "christmas")
    {
    play();
    }
    else
    {
    stop();
    }
    }
    but it's not going to work because at the moment when the function checks what the framelabel is it may or may not be called christmas, as the movieclip is playing and switches frames every 24times per second or what you set your speed to. It's not reliable and very unstable way to solve it.

    I think you complicated the way to handle your problem. If you can explain what your goal is I'm sure we can help you solve it in a much easier way, and easier for you too.

  6. #6
    Member
    Join Date
    May 2009
    Posts
    34
    Please bare with me; here goes my project:

    I'm using Flash for frame-by-frame animation. I have a very small stage with a grid in order to place tiny MovieClips within it. These MC's –or "heads"– are driving the animation in the manner of a "snake" game, where I can duplicate the head's previous positions, giving a "body" array.

    I want to avoid duplicating bodies for each keyframe, so I'm resorting to AS3 and JSFL to do the hard work. These are the problems:

    1) I'm depending on ENTER_FRAME to trigger (if a head's length is >= 1) the duplicating process. As a head might have a different rate than the fps, I need a way to select ONLY when a keyframe is located. This is because keyframe means change. Frame doesn't.

    2) Different heads are placed, for legibility's sake, at different layers. This makes my approach difficult as I can't seem to find a way for AS3 to detect if there is a label AND which type of label it is (in order to differentiate between layers). Flash doesn't allow duplicate label names.

    3) Currently my head duplicating class, Snake(), doesn't know to directly reference one specific head-MC that is on stage.

    Below is my .FLA with the two .AS; please note that currently Snake.as doesn't seem to work because I can't find a way to reference an element on Stage from a subclass. It also isn't supposed to be referencing statically to one head (pl1), but the head that will be given in the constructor method:
    Attached Files Attached Files

  7. #7
    Junior Member
    Join Date
    Sep 2010
    Location
    Singapore
    Posts
    12
    you can try currentLabel instead of currentFrameLabel; that is if you really want to use keyframe.

    i suggest you make use of functions instead of using keyframes to generate actions.
    im not really sure whats your plan. besides you cannot have more than 1 frame label in 1 frame. even if your label is located in different layers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center