Sub Clips In Movie Clips

Ok, I have continually run into this so i guess i just don't understand some foundation to how AS3 works.
So, I have a movie clip in the library (ClipA) - it is linked to a class.
Inside Clip A there are 3 other Movie Clips (SubClip1, SubClip2, SubClip3).
When I place ClipA on the stage i want to adjust the frame that each of the SubClips are on.
BUT, when I try to set them to a frame in ClipA's class file i get an error like this:
     1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:DisplayObject.
If i do something like this it works:
    this.getChildByName("SubClip1").x = 10;
But this wont:
    this.getChildByName("SubClip1").gotoAndStop(10);
What am i not understanding? Why can't i adjust sub clips?

From the other error message you were getting, it indicated a DisplayObject under in the compiler's scrutiny.  A DisplayObject will most definitely have x and y position properties, so there's no issue there.  But a DisplayObject is not necessarily a MovieClip, so it may not have a gotoAndPlay method... so you sometimes have to give the compiler a slap on the back of the head by telling it explicitly what type of object it's looking at.
There are some things that in my opinion don't stand up to reason (or being reasonable) with how AS3 works, but there are others who see sense in it all.

Similar Messages

  • Movie clips within movie clips

    I have a movie clip (I'll call it B_mov) inside another movie
    clip (A_mov). When you click a button in A_mov, B_mov plays. At the
    end of B_mov, I used stop(); to make it stop. How do I return to
    A_mov from there? I assume this is ActionScript territory.
    This is coming from someone who has just taken his first baby
    step into AS, navigating a single timeline via buttons, but I have
    no idea how to move between different timelines.
    Is this something that can be easily explained? If it's
    really complicated, I don't want to burden anyone.
    ...Would I be better off finding an online AS tutorial? Can
    someone please point me in the right direction?

    supaaman,
    > I have a movie clip (I'll call it B_mov) inside another
    > movie clip (A_mov). When you click a button in
    > A_mov, B_mov plays.
    Okay.
    > At the end of B_mov, I used stop(); to make it stop.
    Makes sense so far. :)
    > How do I return to A_mov from there? I assume this
    > is ActionScript territory.
    Well, you've already entered ActionScript territory by
    programming your
    button and adding that stop() action, so that's a good thing.
    When you say
    "return to A_mov," what do you mean? What would like like
    A_mov to do at
    this point?
    > This is coming from someone who has just taken his
    > first baby step into AS, navigating a single timeline
    via
    > buttons, but I have no idea how to move between
    > different timelines.
    Timelines are synonymous with movie clips, and movie clips
    are defined
    by something called the MovieClip class. In fact, all objects
    in
    ActionScript are defined by corresponding classes (text
    fields are defined
    by the TextField class, arrays by the Array class, and so
    on).
    Thinking of it this way, you can consult the MovieClip class
    entry of
    the ActionScript Language Reference (the Help panel) to find
    out everything
    you need to know about movie clips. The characteristics of
    the object are
    called properties (you'll find references to width, height, x
    and y
    position, etc.). Things the object can do, such as stop(),
    play(), and the
    like, are called methods. Things the object can react to --
    mouse clicks,
    for example -- are called events.
    You haven't stated what version of ActionScript you're
    using, and the
    exact wording of your code depends on that, but for example,
    in ActionScript
    2.0, you'll find that movie clips have a _parent property (in
    ActionScript
    3.0, it's simply parent). This property allows the movie clip
    in question
    to refer to its parent timeline (that is, its parent movie
    clip). That
    might be a step in the right direction for you, but I'm not
    sure what you
    have in mind.
    Instead of simply invoking stop() in the final keyframe of
    B_mov, you
    might do something like this:
    stop();
    _parent.play();
    ... which invokes the MovieClip.stop() method on B_mov's
    timline (because
    that's where the reference to stop() appears: in B_mov's
    timeline) and then
    makes a reference to B_mov's parent via the MovieClip._parent
    property.
    That reference therefore invokes MovieClip.play() on A_mov.
    The reason it works here is entirely because of the point of
    view from
    which the code operates: namely, keyframes in B_mov's
    timeline. If your
    code were all on the main timeline, your methods would be the
    same -- stop()
    and play() -- but your object references would be different.
    Does that make sense?
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Buttons in Movie Clips, Movie Clips in Movie Clips

    Here goes. I have a scene with a button in the timeline, that
    targets a frame in a movie clip, which is essentially the content
    area of the layout. this is the code used:
    on (release) {
    textmov.gotoAndPlay ("challenge");
    This works fine and dandy. Now the problem. Within this
    "Content" movie clip, i have another movie clip with a button in
    it. This clip is designed to tween in then upon clicking a close
    button tween out. When I test it the button doesn't have rollovers
    like and I can't get it to talk to the clip above it to play the
    close tween.

    > I am still struggling with the fact, that upon testing,
    buttons in movie clips
    > do not exhibit their various states. Up, Over etc. I'm
    relatively sure that you
    > can have buttons in Movie Clips. I've also noticed that
    any graphic symbols
    > within a Movie Clip produce the hand, when the mouse
    cursor is Over them, just
    > like a button would. All of this happens, when testing
    in the FlashPlayer.
    is there any place you could kindly upload the source file
    for me to check ?
    > Do buttons operate independently of the Movie Clip
    timeline they are placed in?
    that is correct, button should work independently to movie
    clip.
    it only react to mouse upon entering the HIT state (which is
    invisible to user)
    and stops reacting once the mouse is off that state.
    > I have one Movie Clip with a one frame time line, should
    a Button symbol work
    > it it?
    of course it should work...
    Try to upload the source, let us check it out for you, spare
    you time on guessing :)
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • AC 2.0 Movie Clips with Movie Clips

    Can I write actions on the main movie frame that apply to
    movie clips that are inside other movie clips? Actions just seem to
    not do anything to them?

    yes, but you must wait until those movieclips exist and you
    must use the correct path reference to them.

  • Clip speed - moves clips that follow

    Hello,
    I was wondering if I can change the speed of a clip without it affecting the position of every clip that follows?
    I know I can copy that clip to a new track, lock all other tracks and proceed... but that seems so awkward.
    Have I understood something wrong? Am I doing something wrong?
    Thanks for your input!

    This is how the changing the speed of a clip would behave prior to the current version of FCP. My method of dealing with this is to keep another sequence (called work) open just for making some changes like speed changes.
    If you have the current version of FCP then you want to use the change speed tool and uncheck ripple sequence. You watch a clip on its use here.
    http://www.apple.com/finalcutstudio/whats-new.html#finalcutpro
    o| TOnyTOny |o

  • Movie clip stops playing for no reason

    I am making a banner that has multiple movie clips sharing the same area, creating different rainbow effects when different areas (invisible buttons) are moused over.
    First of all I couldn't figure out if there was a way to have one invisible button over the whole area that changed to a different colored effect with each mouse over (first mouse over the black and whites would change to reds, second would change it to blues, third would change it to browns, etc.). Since I couldn't figure this out I settled on creating three buttons covering a third of the banner each, so when the mouse passes over one button it changes to reds, over another button it changes to blues, over the third it changes to browns.
    The effects are movie clips where each frame has another stripe changing color so it goes in a wave effect from one to the next, and then goes back to white and black in the same manner.  The first frame of each movie clip I had to turn into a nested movie clip so I could turn the alpha to 0, since I was going to have these color effect movie clips on top of one another in the main timeline on different layers, and so you could see the effect even if that color layer wasn't on top. I used the same nested movie clip with zero alpha for the first frame of each color effect clip (reds movie clip, blues movie clip, etc), so I dont' know if that's an issue.
    Anyway, it seemed to work fine for a while, but after working on it for a while longer (and not getting any further since I removed most of the changes I made), now when I test the movie the mouse over does not seem to work correctly. It works fine, seemingly, for the first time I mouse over each button, but in order to have it work again I have to mouse over the button twice, and then it will pause randomly during a part of the clip and I have to move my mouse back over for the movie clip to continue.
    I can't tell if this is because of the overlapping movie clips, or because my buttons are messed up, or if my actionscript is messed up, or if the timeline has to be longer, or what. Currently the timeline is 55 frames, the same as each movie clip.
    I put a movieclip_instance.stop(); command in the first frame of the main timeline, is there a better way to do this? Should I put the stop command in the movie clip itself?
    Here is a section of my AS in the main timeline, this is my first time programming ever, in any language, and trying to learn from the internet is more difficult than I thought it would be.
    redmovie.stop();
    red_btn.addEventListener(MouseEvent.ROLL_OVER, playRed);
    function playRed(event:MouseEvent):void
              redmovie.play();

    I am not sure of what the problem is, so I don't know if this will help or not.  One thing I might suggest is that you use gotoAndPlay(1) instead of play().  That way, if your movieclip is in the middle of playing it won't continue but will start from the beginning.
    You could use one button to have the different movieclips play in sequence if you prefer that.  You would just need to have some form of counter that keeps track of which is the next to play. Somethin like...
    var mcCounter:uint = 0; // start at 0 since an array is being used to identify which movieclip to play
    var mcs:Array = new Array(redmovie, bluemovie, brownmovie);
    only_btn.addEventListener(MouseEvent.ROLL_OVER, playMC);
    function playMC(event:MouseEvent):void
             mcs[mcCounter].play();                  // tell the current mc to play
             mcCounter += 1;                            // increment for the next mc
             if(mcCounter == 3) mcCounter = 0;  // reset the counter if it exceeds the array

  • Making movie clips play in reverse in AS 3.0

    Hey all. I'm changing all my files to AS 3.0 because of some
    new elements I'd like to use in flash CS4.
    Here:
    http://www.iaw-atlanta.com/IvyLeague1-13-09.html
    I have the menu navigation at the bottom with 4 buttons. When the
    buttons are moused over they ascend and when they are moused out
    the movie plays in reverse so that they descend. Basically in the
    movie clip, I have it stopped as well as gotoAndPlay the next frame
    when the button is moused over and then have a script telling it to
    reverse when moused out. I know how to do this in AS 2.0 but how
    can I translate the script to 3.0?

    DjPhantasy5,
    > Ok thanks, I'll see what he also has to say as well.
    Actually, NedWebs pretty much nailed it. :) The approach
    you've taken
    is an interesting one, because it scales all the way back to
    Flash Player 5,
    which didn't yet support the MovieClip.onEnterFrame event.
    Without that
    event, you need something like your "controller" symbol -- a
    separate
    looping timeline -- to perform code that depends on frame
    loops.
    Available as of Flash Player 6, that event would allow you
    to
    consolidate your code a bit by putting it all in a single
    frame and avoiding
    the extra movie clip symbol. That doesn't mean your approach
    is wrong, by
    any stretch. In fact, it's good to know your options, because
    if you ever
    need to publish to Flash Player 5, you'll probably do best to
    use the setup
    you've taken.
    I'll demonstrate onEnterFrame in just a bit, in case you
    want to take a
    look at that.
    >> there's no _root reference in AS3, but you can use a
    >> MovieClip(this.parent) (which replaces what _parent
    >> used to do) to locate something outside of the
    immediate
    >> movieclip.
    The term "parent," in this context, is technically a
    property of the
    MovieClip class, which means all movie clips in AS3 have
    access to the
    "parent" feature, which points to the timeline that contains
    the movie clip
    in question. Buttons also feature a "parent" property. In
    AS2, this
    property acted exactly the same, only it was preceeded by an
    underscore.
    In fact, NedWebs' suggested code works the same in your
    existin file.
    Instead of this:
    // Your existing code ...
    if (_root.animation._currentframe>1) {
    _root.animation.prevFrame();
    this.gotoAndPlay(2)
    if (_root.animation._currentframe<=1) {
    this.gotoAndStop(1);
    ... you could be using this:
    // Alternative code ...
    if (_parent.animation._currentframe>1) {
    _parent.animation.prevFrame();
    gotoAndPlay(2)
    if (_parent.animation._currentframe<=1) {
    gotoAndStop(1);
    ... because from this scope -- that is, from this point of
    view -- the
    MovieClip._parent property points to the same timeline that
    _root does.
    That changes, of course, based on how deeply nested the
    current scope is.
    The term "this" in the above code is optional, because Flash
    understands
    what scope you're in. From the point of view of this code,
    _parent is
    understood to refer to the current scope's parent timeline,
    just like
    gotoAndPlay() is understood to refer to the current scope's
    own timeline.
    You could precede either of those by "this" or not.
    Many people will argue that _root is probably best avoided,
    only because
    it's a slippery slope. It doesn't always refer to the main
    timeline you
    think it does, depending on whether or not your SWF is loaded
    into another
    SWF at runtime. Meanwhile, _parent *always* refers to the
    immediately
    parent timeline.
    So when you look at it that way, this perfectly valid AS2:
    if (_parent.animation._currentframe>1) {
    ... isn't much different at all from its AS3 counterpart:
    if (MovieClip(parent).animation.currentFrame>1) {
    It would be nicer if you didn't need to cast the parent
    reference as a
    movie clip here, but if you don't, AS3 doesn't realize that
    the scope in
    question is a movie clip.
    >> You can string them along as...
    >> MovieClip(this.parent.parent)
    Exactly.
    >> Your _currentframe in the the controller becomes
    >> currentFrame. That's about it. The rest of what I
    >> saw will fly as is.
    Not quite. AS3 doesn't support the on() or onClipEvent()
    functions, so
    you won't be able to attach your code direction to the
    button. Instead,
    you'll have to put it in a keyframe -- which you can also do
    with AS2. It's
    a good idea, in any case, because it allows you to put all
    your code in one
    place, making it easier to find.
    Here's a quick note on direct attachment:
    http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent
    To convert your existing FLA structure to AS3, you might,
    for example,
    do this:
    animation.buttonMode = true;
    animation.addEventListener(MouseEvent.ROLL_OUT, outHandler);
    animation.addEventListener(MouseEvent.ROLL_OVER,
    overHandler);
    function outHandler(evt:MouseEvent):void {
    controller.gotoAndPlay(2);
    function overHandler(evt:MouseEvent):void {
    controller.gotoAndPlay(4);
    That takes care of the on(rollout) and on(rollover) code in
    your current
    version. The first line (buttonMode) is only necessary
    because I got rid of
    the button symbol and, instead, associated the event handlers
    directly with
    your animation clip. (Movie clips handle button-style events,
    too, so you
    don't need the button.) In AS3, event handling is very
    straightforward:
    you reference the object (here, animation), invoke its
    inherited
    addEventListener() method, then pass in two parameters: a)
    the event to
    listen for, and b) the function to perform when that event
    occurs.
    You can see that spelled out above. In AS2, there are quite
    a few ways
    to handle events, including on()/onClipEvent(), so it's
    harder to know when
    to use what approach. For buttons and movie clips, the
    princple works the
    same as I just showed, but the syntax is different.
    Let's take a quick look at reducing all this code by using
    the
    onEnterFrame event. First, check out this AS2 version:
    animation.onRollOut = outHandler;
    animation.onRollOver = overHandler;
    function outHandler():Void {
    this.onEnterFrame = reversePlay;
    function overHandler():Void {
    this.onEnterFrame = null;
    this.play();
    function reversePlay():Void {
    this.prevFrame();
    All of that code would appear in frame 1. You don't need the
    controller
    movie clip. The animation clip no longer contains an orb
    button, because
    we're using animation itself as the "button". (You can always
    see what
    functionality any object has by looking up its class. If
    you're dealing
    with a movie clip, look up the MovieClip class. See the
    Properties heading
    to find out what characteristics the object has, see Methods
    to find out
    what the object can do, and see Events to find out what the
    object can react
    to.)
    In the above code, it's all laid out pretty easily. This is
    AS2,
    remember. We have two events we're listening for:
    MovieClip.onRollOut and
    MovieClip.onRollOver. Those events are established for the
    animation movie
    clip by way of its instance name, and associated with
    corresponding custom
    functions. The outHandler() function associates yet another
    function to the
    MovieClip.onEnterFrame event of the animation clip. Very
    simply, it
    instructs animation to perform the custom reversePlay()
    function every time
    it encounters an onEnterFrame event. The overHandler()
    function kills that
    association by nulling it out, and telling animation to play,
    via the
    MovieClip.play() method. Finally, the reversePlay() function
    simply invokes
    MovieClip.prevFrame() on the animation clip.
    Here's the AS3 version:
    animation.buttonMode = true;
    animation.addEventListener(MouseEvent.ROLL_OUT, outHandler);
    animation.addEventListener(MouseEvent.ROLL_OVER,
    overHandler);
    function outHandler(evt:MouseEvent):void {
    animation.addEventListener(Event.ENTER_FRAME, reversePlay);
    function overHandler(evt:MouseEvent):void {
    animation.removeEventListener(Event.ENTER_FRAME,
    reversePlay);
    animation.play();
    function reversePlay(evt:Event):void {
    evt.target.prevFrame();
    It looks wordier, but if you look carefully, you'll see that
    it's
    essentially the same thing. The main difference is the way
    scope works in
    AS3. In AS2, there are numerous references to "this", because
    the event
    handler functions operate in the same scope as the object to
    which the
    association is made. In AS3, the references aren't to "this",
    but rather to
    the same animation clip by its *intance name*, because in
    AS3, the scope
    operates in the same timeline in which the code appears
    (namely, in this
    case, the main timeline).
    In the reversePlay() function, in order to emulate a "this"
    sort of
    setup, I'm referring to the parameter that gets passed to all
    event handler
    functions in AS3. I happened to name it "evt" (for event),
    but you can call
    it what you like. In the case of reversePlay(), the evt
    parameter refers to
    an instance of the Event class, which has a target property.
    The target
    property refers to the object that dispatched the event --
    happens to be
    animation, in this case. So evt.target, in this context,
    refers to
    animation, which is what I invoke the MovieClip.prevFrame()
    method on.
    I've uploaded a handful of FLA files to my server. I won't
    keep them
    there forever ... maybe a couple weeks, as of this post:
    http://www.quip.net/RewindTestAS3.fla
    http://www.quip.net/RewindTestAS3_new.fla
    http://www.quip.net/RewindTestAS2_new.fla
    David Stiller
    Co-author, ActionScript 3.0 Quick Reference Guide
    http://tinyurl.com/2s28a5
    "Luck is the residue of good design."

  • Please help! Nested Movie Clips as navigation bar

    Hi everyone,
    I just had my first flash lesson a couple of days  ago, but decided to venture myself into trying to build a navigation  tool bar with movie clips grouped together. My intention is that once  the mouse rolls over one particular movie clip, another movie clip fades  in under it (my version of a "drop down" menu). Just so it happens, the  movie clip that fades in, is also comprised of particular movie clips  with their own behaviors (roll over tween effects).
    I can make  each individual movie clip behave as it should, but I cannot get them to  work once they are pieced together. I'm attaching a link that contains  the file I'm talking about (submenu), in the hopes that one of you good  Samaritans would take a look at it and tell me where I went wrong.
    Hopefully   I haven't absolutely shocked you guys with my level of ignorance.
    http://docs.google.com/fileview?id=0B09iy1xwVTUYZmY0NjdhM2EtZDRjYS00MGNlLWJmNmEtMDJmOTI4ZT ZjYWFi&hl=en
    Gaby

    its just with the frame labels you have given every where.
    and its the same "over" and "out"
    the player is confused to play which one fist
    i removed some lables and saw that it works partially. (did not debug the whole fla)
    hope you will got the way

  • Navigating between two movie clips

    Within my animation I have two movie clips, one movie clip "clipA" runs to a certain point then a series of buttons appear when you hit the button it loads another movie clip "clipB" into the first movie clip "clipA".
    Whith in the second movie clip "clipB" I would like to be able to, at a certain frame navigate to a different frame within "clipA" is this possible to do with actionscript 2.0

    In clipB's main timeline you can use _parent.gotoAndPlay.... the _parent targets clipA

  • Is there a way to clear ALL event listeners, stop all movie clips, etc?

    Is there a syntax for this?
    I have a movie that has 15 frames. Each frame has embedded movie clips within movie clips, tons of animations and event listeners. None is needed except when they are on the stage, on the frame. However, the animations continue even when the frame is left.
    For instance, I have a frame that has a dynamically rendered animation of leaves falling from a tree. When the frame is left, the leaves continue to fall.
    There are many instances of this type of thing happening.
    Ideally, I would love to just be able to clear everything when a new frame is loaded, since none of the animations or event listeners need to carry over from one frame to another.
    Is there a way to do this without the thousands of lines of code it would take to manually remove every single animation and event listener and sound, etc, from the stage?
    Thanks so much!!
    Amber

    you have to manually do that.
    or, you could convert each frame to a swf.  load each swf when needed and, if you're publishing for fp 10+, you can apply unloadAndStop() to kill all streams in the loaded swf and ready those assets for gc.

  • Flash Movie Clip Run Very Slow

    I have about 10 of "coconut tree" Movie Clips, 1 clouds movie
    clip, 1sea movie clip. The problem is when i run all of the movie
    clips together, the animation run very slow. Can anyone help me
    please................................................
    thanks

    It's hard to tell without knowing what those movie clips
    contain. If they contain raster images (bitmaps), have tons of
    points, utilize a lot of alpha tweening, etc. it could be the
    cause. How does it run with each movie clip running by itself? Are
    coconut trees vector or raster? If vector, can you optimize the
    shapes any to reduce the number of points?
    (Modify>Shape>Optimize)

  • Move clips from timeline to event sub folder?

    Aloha,
    Is there a way to move clips in the timeline that I have cleaned into a sub folder in an event library?
    I come from a non FCP background and still trying to wrap my mind/workflow around the FCP formula.  Generally I clean clips and drop "some" into a "to be used later" folder. 
    Example - While on location I might shoot some location shots while im waiting around.  The locations shots will use in the last 3 mintues of a 25 minute finished project.  When I get to post I edit and clean all clips in the order they are received.  When I find the location clips I simply move them to a folder labled "to be used later".  When I get to the section of the project/timeline were the clips are needed I drag them or the entire folder into the timeline.  
    I see how to make a folder inside an event but I am not able to drag a clips from the timeline to this created folder.  I have tryied to hold down Shift, CMD, OPT, CTRL and have no sucess.
    Thanks you for your time and help.
    Frederick
    Marbelle

    Aloha Fox,
    Thanks for taking the time to answer my questions.  I feel you really understood my concern and gave me some good viable options.
    There is a lot for me to learn and unlearn. I have been editing for over 16 years and most of that time I was using Edius. This is big paradigm shift coming to the Mac and FCPX. 
    The idea for me is to edit the video and move the "to be used later clips" into a bin/folder instead of moving them to the location in the timeline were they will be used at that very moment.  Its just a preference, I know plenty folks would just move the clip to the location.  Edit software is just a tool I have to decide if FCPX is the right tool for me. 
    Thank you again Fox for your time and understanding of my question. 
    Be blessed,
    Frederick
    Marbelle

  • Menu made in movie clip - with sub-section we can click on to go to another frame

    I would like some help about that:
    I want to do a menu made all in movie clip (NO button). In
    this menu, when we click on one of the part (sub-section) of the
    button (which is a mc), we must go to another frame in the main
    scene.
    It is working for the roll-over and mousedown for my button
    (with the _up, _over and _down labels). But it's not working then
    to put, i don't know, another movie clip inside with alpha 0 to
    make another onRelease and then gotoAndStop(20); ...
    Here is the code I have in the main scene (first frame):
    stop();
    mon_clip_mc.onRelease = function() {
    //this._root.gotoAndStop(20);
    And here is the code I have in the first frame of the movie
    clip of the button:
    stop();
    I'd really appreciate some help! Thanx

    lalapinerouge,
    as far as I can see with your method for buttons, is that it
    only reads 1 button inside mon_clip_mc..
    I cant figure out why, i've tested it over, made new fla's
    with your method, and i still cant get it to work, nor do I
    understand why..
    I need to study abit more.
    Maybe someone in the Forum will have a look at this topic,
    and know what's going on with your method.
    In the mean time, heres a submenu I made for a site a while
    ago. This doesnt use timeline actionscript, ( because i was a
    newbie then ) =)
    if you have a look through the whole FLA, ( it's quite abit)
    you can get an Idea of how i do my movie clip buttons, till this
    day, i still use the same method, only i use mainly timeline
    actionscript..
    the main point to notice is that EVERY button ( even submenu
    ) is it's own movieclip...no button in there holds multiple sub
    buttons inside... This gives you complete control of each button,
    and endless possibilities for animation, tweens, and anything extra
    you would want to add to a button.
    Sorry I couldnt help you figure out your problem fully. Im
    still going to mess around with it abit more to see if i can figure
    it out..
    Hope you can addopt some useful info from this FLA.
    HERE

  • Video fading in, but not out in movie clip.

    Hi.
    I need to run a video which I can turn off and on on top of other flash content.
    Since I also need to add sub titles I decided to import the video clip into a movie clip. The movie clip now has as many frames as the video.
    I added the subtitles by keyframing a text line in the movie clip and synched it up with the movie. (this was not real easy..)
    I placed an instance of the movie clip on my main stage in frame 10. I added an on and and off button that simply would take you to a later frame without the movie clip instance, and back to frame 10 again if you want to see the video again. This worked well. 
    To make the transistions elegant I wanted to fade the video in and out. So on the main stage in frame 10 I placed this action script:
    (+ gave my movieclip the instance name mc)
    stop();
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    var myTween:Tween = new Tween (mc,"_alpha",Strong.easeIn,0,100,2,true);
    which nicely fades the video in when the playhead gets to frame 10.
    There is another part of the script that should be able to tell the upcoming end of the movie clip and fade it out:
    myTween.onMotionFinished = function () {
       new Tween (mc,"_alpha",Strong.easeOut,100,0,2,true);
    This however I can not get to work:
    1)  If I place this code in frame 10, the video first fades in but immideately fades out again.
    2)  I tried to put the code 15 frames from the end of the movie clip, and that did not work.
    3)  I tried to put the code 15 frames from the end of the movie clip and add _parent.  and that did not work either.
    Can this be made to work, and if so how?
    If not, please let me know if you have any other proven approach to suggest.
    ggaarde

    Hi Ned
    This does not work for me.
    Again the instance of the movieclip is on the main timeline in frame 10 with stop action
    I have put the code you suggested in frame 13 of the main time line. also with a stop action.
    Then in the movieclip I have put this code approx 100 frames from the end of the clip:
    _parent.gotoAndPlay(13);
    How else would he main movieclip know when to start the fadeout?
    The myTween.onMotionFinished = function should maybe detect it, but i have not had luck using it. The only time it works is like described in my first post, but it triggers right away and fades out as soon as it is done with the fade in.
    Is there a way to tell it on which frame in the mc it should start the fade out?
    ggaarde

  • Attempt to move main timeline from inside a movie clip breaks menu buttons.

    I am attempting to have the main timeline move from a stopped position over a movie clip to frame 1, where my start menu is.
    The code I'm using does move the timeline but in doing so it somehow breaks the 4 buttons I have in frame 1.
    My code in the movie clip:
    stop()
    function replayMovie(event:MouseEvent):void
    MovieClip(parent).gotoAndStop(1);
    Menu.addEventListener(MouseEvent.CLICK, replayMovie);
    My code in frame 1 of the main timeline:
    stop();
    function bo(event:MouseEvent):void
    gotoAndPlay(21)
    SoundMixer.stopAll()
    espesp.addEventListener(MouseEvent.CLICK, bo);
    function ho(event:MouseEvent):void
    gotoAndPlay(31)
    SoundMixer.stopAll()
    espeng.addEventListener(MouseEvent.CLICK, ho);
    function yo(event:MouseEvent):void
    gotoAndPlay(41)
    SoundMixer.stopAll()
    engesp.addEventListener(MouseEvent.CLICK, yo);
    function go(event:MouseEvent):void
    gotoAndPlay(51)
    SoundMixer.stopAll()
    engeng.addEventListener(MouseEvent.CLICK, go);
    The error output when I use my Menu button at the end of the movie clip.
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at SSubjunctiveProjNewgrounds_fla::MainTimeline/frame1()
    at flash.display::MovieClip/gotoAndStop()
    at SSubjunctiveProjNewgrounds_fla::Esp_5/replayMovie()
    Any help would be greatly appreciated.

    For the sake of space, I'll leave out all the package declarations and class declarations and just talk about the functions.
    First, the Game class, it has two functions.  The first one is the constructor function and it launches at the beginning of the game:  First the Game function:
    public function Game():void
    //Game code goes here
    }//Game
    We want to listen for someone to click the mouse on the MenuPage, so lets create a new MenuPage and add a listener to the button contiained within it.
    public function Game():void
    menuPage = new MenuPage;
    menuPage.startButton.addEventListener(MouseEvent.CLICK, startGame);
    addChild(menuPage);
    }//Game
    You will notice that before I declared a variable var menuPage:MenuPage, but that's all I did was declare it.  I didn't really make a new instance of it, I just set aside space for it.  In the first line within the Game function, I'm actually turning that variable into a new instance of a MenuPage.
    We don't have a picture of this imaginary menuPage instance, but lets' assume that in our MenuPage MovieClip in the library, we created a SimpleButton called startButton.  Here, I'm adding an EventListener that patiently waits for someone to click that button.  Once we receive that event, Flash is told to call the startGame function.
    As you get better at this, you'll get into custom events, and the eventListener for the button will exist in the MenuPage class file, or even in another class file that you create just for the button.  Something like StartButton.as  But for now, we can do it as above.
    Now the startGame function:
              public function startGame(evt:MouseEvent):void
    //Remove the start Page
    //Add the zombie
    //Add the gun
    }//startGame
    And we'll replace those comments with real code.  It follows along with what we just did above.
    public function startGame(evt:MouseEvent):void
    zombie = new Zombie;
    addChild(zombie);
    gun = new Gun;
    addChild(gun);
    And we also want to clean up some by removing the menuPage, and throwing out the eventListener.
    public function startGame(evt:MouseEvent):void
    zombie = new Zombie;
    addChild(zombie);
    gun = new Gun;
    addChild(gun);
    menuPage.startButton.removeEventListener(MouseEvent.Click,startGame);
    removeChild(menuPage);
    }//startGame
    Now our Game class is complete.
    The Zombie Class
    public function zombieWalk(evt:Event):void
    this.addEventListener(Event.ENTER_FRAME,zombieWalk);
    this.x = this.x + 10;
    }//zombieWalk
    Notice we've added a function to the Zombie Class.
    The first function adds an EventListener to the zombie.  We can use the word this and actionScript knows we're talking about the zombie that the class is written for.  This listener fires off every frame.  If our FLA file is set to 12fps, then 12 times every second it will call on the zombieWalk function.
    The zombie walk function moves the zombie 10 pixels to the right every time the function is called.
    On a more advanced level, you'll want to add animation in the MovieClip to move the zombie legs.  You'll also want to use Timer events to space out how often the funtion fires and not ENTER_FRAME events.  And you'll want to use a static constant to establish how far the zombie moves.  We have it now set to 10 pixels, but that can get irritating if we want to change that value later.  But again, baby steps.
    And finally, the Gun class
    public function Gun():void
    this.addEventListener(MouseEvent.CLICK, fireGun);
    }//function
    public function fireGun(evt:MouseEvent):void
    this.gotoAndPlay(2);
    }//fireGun
    First we add an EventListener for when someone clicks on the gun.  Once this happens, the listener calls on the fireGun function.
    The fireGun function takes advantage of the frames within the Gun MovieClip.  Say we have three frames in the Gun MovieClip.  The first is just a picture of the gun.  The second is the gun with a flash coming out of the nozzle.  And the third is the gun at rest again.  The line this.gotoAndPlay(2) sends the gun to the second frame with the flash graphic.
    For this to work, each frame in the Gun MovieClip has to have some stop and play commands.
    But.. you said no code on our timeline!! Liar!
    I know.  This is the exception.  You will need basic stop() commands and gotoAndPlay commands to loop animations.  Any MovieClip that has more than one frame will need something to control it.
    So our Gun MovieCLip has the following:
    Frame 1: stop();
    Frame 2: no actionScript... and I mean nothing, not even the words, "no actionScript"
    Frame 3: gotoAndStop(1);
    This will loop the gun to the beginning and wait for the next time the user clicks the gun.
    Advanced features of the Gun class might include a Bullet.as sub-class that creates a bullet MovieClip to fly across the screen.  Sound to play when the shooting takes place.  Object collision detection to see if the bullet hits the target.  And a means by which a custom event will tell the Game.as class that a zombie has been hit and it should be removed from the stage.
    As you go down the rabbit hole of ActionScript 3, you will find yourself at a point where it's just a matter of getting the syntax right for all the built in functions and classes.  Arrays, Loaders, casting variable types.. all that stuff will come.
    I hope this has been helfpul.  It's been on my to-do list for a long time.  When I first started out, no one could provide me with basic answers for how all these classes and whatnot worked.  After teaching myself AS3 for 2 years and reading a gabillion books, I think I've gotten to a point where I'm pretty comfortable with it all.

Maybe you are looking for