Official website for Web Designer - defining the internet through beautiful design
FOLLOW US ON:
Author: Dave Harfield
8th April 2009

Create 3D Dioramas in Flash

13 And a kind of z

13 And a kind of z

Create 3D Dioramas in Flash

Flash doesn’t have a built-in property for a z value as it has for x and y. We will create our own z value for each MC, so we know how far in the fish tank each one is. On line 61, start by setting the value 40 on ‘fish04’, which is furthest away. Then line 30 on ‘coral04’, which is a bit closer, etc.

14 Movie Clip events

Create 3D Dioramas in Flash

Disable the corals for any mouse events on line 70, or else you’ll have a hard time triggering the fish that may be partly overlapped by the corals. On line 75, we are adding mouse rollover/roll-out Event Listeners to all the fish Movie Clips, which we use to trigger functions on line 87 and 90.

15 Glowing fishes

Create 3D Dioramas in Flash

On line 88 in the fish Movie Clip rollover method, we are adding a White Glow filter with 100 per cent Alpha and 20px Blur to the Movie Clip, which quickly fades in on 0.1sec. And on line 91, the rollout triggers a Tween that fades the Glow back to zero per cent Alpha in 0.4sec.

16 Mouse movement

Create 3D Dioramas in Flash

Keep track of mouse movement by adding a MouseEvent Listener to the stage on line 84. This triggers a function that moves the MCs around depending on where you move the mouse. Just position the different Movie Clips’ x and y values in relation to the mouse x and y values.

17 Reposition clips

Create 3D Dioramas in Flash

On line 94, calculate how many pixels the pointer is from the centre on both the x and y axis to get the new position of the Movie Clips. Chuck each Movie Clip’s original x and y properties and the new z value in the TweenMax method to Tween them to their new positions in 1.2sec.

18 Finish off

Create 3D Dioramas in Flash

Now we’re ready to test. Save all files and publish for HTML and you are done! Now you can play around and tweak it in your own way. Maybe add motion blur to the reposition Tweens? Have a look around at http://blog.greensock.com/tweenmaxas3 for a complete description.

Pages: 1 2 3 4

Tags: ,
  • Tell a Friend
  • Follow our Twitter to find out about all the latest web development, news, reviews, previews, interviews, features and a whole more.

    One Comment »

    • suntradetop said:

      My son is my son till he has got him a wife, but my daughter is my daughter all the days of her life

    What's your opinion?

    Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

    Be nice. Keep it clean. Stay on topic. No spam.

    * Required fields