Professional Web Applications Themes

how do i put a mask layer ABOVE dynamically created objects? - Macromedia Flash Actionscript

i have created some actionscript and a couple of symbols that create a very pleasing sparkle effect. i would like to modify my FLA so that these sparklies ONLY appear on a dress (like sequins or something) on a character on my stage. these characters are going to be some unusual curvy shape and will change as the characters move. my problem is that my pleasing sparklie effect only seems to work if i assign each newly created and randomly placed sparkle a new depth value that is different from all previously assigned values. i use the follow code to ...

  1. #1

    Default how do i put a mask layer ABOVE dynamically created objects?

    i have created some actionscript and a couple of symbols that create a very pleasing sparkle effect. i would like to modify my FLA so that these sparklies ONLY appear on a dress (like sequins or something) on a character on my stage. these characters are going to be some unusual curvy shape and will change as the characters move. my problem is that my pleasing sparklie effect only seems to work if i assign each newly created and randomly placed sparkle a new depth value that is different from all previously assigned values.

    i use the follow code to create and randomly place movie objects on my movie object (which is a square at the moment). i want to put a mask layer ABOVE these sparkles but am not sure how to do so...any thoughts? another possibility is that i could come up with a more complex scheme for placing my sparkles so that i don't need to mask anything...they simply are constrained to appear only in a certain area by some kind of equation...this sounds tough though...my math skills are not so good.

    anyways...the code...each of these newly created objects automatically removes itself upon running its own last frame.

    ACTIONSCRIPT
    //====
    _global.intSparkleDensity = 25;
    _global.intCurrentSparkleID = 0;
    _global.intDepth = this.getDepth()+1; // tried using this for depth value but no dice...each sparkle needs it own depth apparently.
    // these values are used to constrain the possible locations of new sparkles
    //...a simple square shape at the moment
    _global.intMaxX = this._width;
    _global.intMaxY = this._height;

    //function defined to create precisely intSparkleDensity new sparkles every frame
    this.onEnterFrame = function() {
    for (i=0; i<intSparkleDensity; i++) {
    intCurrentSparkleID++;

    // i wanted to constrain the depth space of my sparkles
    // to some reasonable number less than the maximum allowed
    // depth which is something like 16,000 or something
    if (intCurrentSparkleID>1000) {
    intCurrentSparkleID = 0;
    }
    strSparkleID = String(intCurrentSparkleID);
    this.attachMovie("one_sparkle", strSparkleID, intCurrentSparkleID);
    intRndX = Math.random()*intMaxX;
    intRndY = Math.random()*intMaxY;
    this[strSparkleID]._x = intRndX;
    this[strSparkleID]._y = intRndY;
    }
    };
    //====

    as you might notice, my sparkles are always on top of EVERYTHING...if i want anything to pass in front of them or mask them, it must be dynamically created and its depth must be greater (or less?? how does this work) than 1000 or whatever.




    sneakyimp webforumsuser@macromedia.com Guest

  2. #2

    Default Re:how do i put a mask layer ABOVE dynamically created objects?

    You get only one sparkle per depth because that's how Flash works. Each layer (not level) can hold only one object. When you load a new object into a layer, it replaces the object currently in that layer.

    I'm fairly new to Action Script yet, but couldn't you place your mask on a high enough level that it will always be on top of everything else?


    Knight Miniatures webforumsuser@macromedia.com Guest

  3. #3

    Default Re: how do i put a mask layer ABOVE dynamically created objects?

    movieclipname.setMask(maskclip) > as dictionary. Another way is to put all
    dynamic movieclip creation in a movieclip and put that one on the main
    timeline under a manually drawn mask.

    John

    --
    ----------------------------------------------------------------------------
    -----------
    RESOURCES
    [url]http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash[/url]
    ----------------------------------------------------------------------------
    -----------
    TUTORIALS at
    [url]www.laiverd.com[/url]
    Flash & PHP Emailform
    Using textfiles in Flash
    ----------------------------------------------------------------------------
    -----------


    Laiverd.COM Guest

  4. #4

    Default Re: how do i put a mask layer ABOVE dynamically created objects?

    ooo...thanks John.

    i had tried putting the mask into the same movie object that creates the sparkles, but it didn't work. if i put the movie that creates the sparkles into another movie, i can easily create a layer above it with a mask. this is a bit confusing...i thought those sparkles at depths ranging up to 1000 would surely be above all my manually created layers...i forgot that flash reserves some layers for manually created objects.

    so anyway...that worked!
    1) place movie that creates dynamic sparkles into another movie
    2) create a mask layer above it in the parent movie.

    THANKS guys.


    sneakyimp webforumsuser@macromedia.com Guest

Similar Threads

  1. Replies: 0
    Last Post: December 8th, 09:32 AM
  2. B&W image into layer mask?
    By Nancy Jacobs in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 1
    Last Post: August 20th, 07:48 PM
  3. paste into layer (using mask)
    By steve bullman in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 2
    Last Post: August 15th, 12:10 PM
  4. PS6 - A Layer Mask Solution?
    By PhilipFFennessy in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 10
    Last Post: August 14th, 08:11 PM
  5. PE2: Selecting and painting a layer having a Hidden Power Tools' layer mask?
    By Richard Hirschman in forum Adobe Photoshop Elements
    Replies: 6
    Last Post: August 7th, 03:05 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