dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: movieClip in a variable??

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    13

    movieClip in a variable??

    I have four buttons currently set up to do all sorts of stuff in a flash file.
    What I'd like to do is have them all point to the currently displayed movie clip on my main timeline.

    At the moment they're set up to test the addChild and removeChild functionality I've written and it seems ok.
    I would like to trigger removeChild and addChild by the last frame in a movie clip and have my buttons send a play command to my movie clip.
    That way the clip plays to the end before removing itself and adding a new movie clip.

    The movie clip that I would like to trigger the addChild and removeChild functions is actually one of four movie clips so I need to declare play(); and send it to the current movie clip regardless of which one is on the stage.
    I was thinking about declaring a variable to contain my movie clip so that I can just say play(awesomeMovieClipVariable);
    and awesomeMovieClipVariable will be equal to the currently loaded movie Clip.
    I can't figure out how to declare a variable and send my movieClip in to the variable.

    if(sceneTracer = 2);
    variableName = mc_copy1

    if(sceneTracer = 3);
    variableName = mc_copy2

    if(sceneTracer = 4);
    variableName = mcCopy3

    with the play command being something like
    play(variableName);???

    I thought it would be something like this...

    does this make sense??
    you can see what I have so far just here:
    http://www.finga-ninja.com/upload/upload.html


    and the .fla file just here:
    http://www.finga-ninja.com/upload/upload.fla

    I have added frame labels to the final frame of each instance of mc_copy1 mc_copy2 and mc_copy3 to allow a conditional statement something like...
    if (current frame of that movie clip = frame label) but I don't know how to set that up...

    I'll deal with that next probably.
    This is my first as3 project after watching a tutorial. Sorry if I'm bein a <div>

  2. #2
    Flash Intermediate XenElement's Avatar
    Join Date
    Sep 2008
    Location
    At my computer
    Posts
    196
    That makes sense, it seems that you're doing most everything correctly, except for one thing. It's NEVER a good idea to remove a MovieClip by itself.

    i.e. you can't say put removeChild(this) on the last frame. What you need to do is have a check that says

    if (myMovie.currentFrame == myMovie.totalFrames){
    removeChild(myMovie)
    }

    Other than that you should be good. It just can't remove itself, as it's not inside itself.

    Good luck with your AS3!
    In the process of designing a quirky little game engine called gulp. Check out it's progress below: @ my blog.

    ---

    Check out my blog at XenElement.com

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    13
    Well I was hoping to do this...
    Basically, "deleteChildFromStage();" and "addChildToStage();" are both functions that I've tested by triggering them with buttons. deleteChildfromStage simply removes the variable "player" that's holding one of my movieClips (20 is the last frame).
    addChildToStage adds one of four movieClips to the variable "player" and then adds "player" to the stage and the movieclip plays.

    I want to trigger my functions like this but I don't know how to run them from inside a conditional statement??
    if(MovieClip(player).currentFrame == 20)
    {
    deleteChildFromStage();
    addChildToStage();

    }
    This is my first as3 project ever.
    http://finga-ninja.com/upload/upload.html
    http://finga-ninja.com/upload/upload.fla

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