Professional Web Applications Themes

Dynamically placing a movie clip on a layer - Macromedia Flash Actionscript

This is undoubtedly a trivial question, but I'm a new user in the middle of learning Flash and am having trouble with Actionscript. I have a sequence which draws an animated background and leaves it in place. I have a layer above this background in which I want to dynamically load and play movie clips depending on a user's menu choices; as each choice is selected (using "onRelease"), whatever movie clip is currently loaded onto that layer should be cleared and replaced by the movie clip that was selected. I can't figure out how to write the code that should ...

  1. #1

    Default Dynamically placing a movie clip on a layer

    This is undoubtedly a trivial question, but I'm a new user in the middle of
    learning Flash and am having trouble with Actionscript. I have a sequence
    which draws an animated background and leaves it in place. I have a layer
    above this background in which I want to dynamically load and play movie clips
    depending on a user's menu choices; as each choice is selected (using
    "onRelease"), whatever movie clip is currently loaded onto that layer should be
    cleared and replaced by the movie clip that was selected. I can't figure out
    how to write the code that should follow onRelease. Since this has to be a
    pretty common thing, is there a FAQ or a library of sample code fragments that
    I can look at to see where I'm going wrong? Thanks in advance!

    PeteGould Guest

  2. #2

    Default Re: Dynamically placing a movie clip on a layer

    layers don't exist outside the authoring environment. however, depths do and
    you background movieclip is probably at depth -16,382 or so. you can load a
    swf file into your movie (onRelease, if you wish) and specify a depth above
    this. for example, attached to a frame you could use:

    _root.createEmptyMovieClip("targetMC",-1000); //creates an empty movieclip at
    depth -1000
    myButton.onRelease=function(){
    targetMC.loadMovie("yourswf.swf"); //yourswf.swf will load into depth -1000
    }


    kglad Guest

  3. #3

    Default Re: Dynamically placing a movie clip on a layer

    Cool -- thanks. That's actually an alternative to what I was looking for,
    which was to load the movie clip out of the LIbrary using attachMovie. Turns
    out I had done EVERYTHING right except one thing: there was a stop() on the
    first frame of the movie I was testing with, left over from when it was
    actually embedded in the main timeline. So of course it was being loaded just
    fine; it just wasn't visible. BTW -- when using loadMovie, is there a way to
    tell it what frame to start on once it's loaded, or will it always start from
    frame 1?

    PeteGould Guest

  4. #4

    Default Re: Dynamically placing a movie clip on a layer

    a loaded (or attached) movie will always start playing from frame 1.
    kglad Guest

  5. #5

    Default Re: Dynamically placing a movie clip on a layer

    Thanks -- it's all working now (got lots more to learn though!)

    Pete


    PeteGould Guest

  6. #6

    Default Re: Dynamically placing a movie clip on a layer

    you're welcome.
    kglad Guest

Similar Threads

  1. Placing a layer over dropdown boxes
    By sazarelli in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: December 12th, 05:19 PM
  2. Adding listener to dynamically created empty movie clip.
    By Phantom_guitarist in forum Macromedia Flash
    Replies: 0
    Last Post: February 18th, 03:25 PM
  3. Replies: 0
    Last Post: February 9th, 11:05 PM
  4. Duplicate Movie Clip in a Duplicated Movie Clip...
    By TommyHilfiger webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 2nd, 08:40 AM
  5. Problem placing data grid in movie clip
    By charleuts webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: January 30th, 03:42 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139