- Home
- Tutorials
- Flash
- Intermediate
- 3D Menu in Flash CS3/CS4 using Flash Player 10 3D API

Code Part 5 - Functions (sub-part 2) FINAL PAGE YAY
Jesse Nicholson
I'm a flash developer in Ontario Canada, I run my own business and I love pushing the limits of flash and exploring the latest developments from Adobe. I have developed a way to author flash 10 in the flash CS3 IDE and would like to begin posting articles on working with the new features (specifically 3d).
View all articles by Jesse NicholsonThe last three functions are the enter frame event to handle all of the filter updating for the depth of field simulation, and the rollover/rollout events for the menu buttons. Lets finish this;
function updatePos(e:Event):void
{
myFilter1.blurX = -(mySpace.z + f1.z) / 80;
myFilter2.blurX = (mySpace.z + f2.z) / 80;
myFilter3.blurX = (mySpace.z + f3.z) / 80;
myFilter4.blurX = (mySpace.z + f4.z) / 80;
myFilter5.blurX = (mySpace.z + f5.z) / 80;
myFilter6.blurX = (mySpace.z + f6.z) / 80;
//
myFilter1.blurY = myFilter1.blurX;
myFilter2.blurY = myFilter2.blurX;
myFilter3.blurY = myFilter3.blurX;
myFilter4.blurY = myFilter4.blurX;
myFilter5.blurY = myFilter5.blurX;
myFilter6.blurY = myFilter6.blurX;
//
f1.filters = [myFilter1];
f2.filters = [myFilter2];
f3.filters = [myFilter3];
f4.filters = [myFilter4];
f5.filters = [myFilter5];
f6.filters = [myFilter6];
//
SimpleZSorter.sortClips(mySpace);
}
The ENTER_FRAME function here uses some simple math to determine just how blurred each menu item should be. It works like this: it calculates the difference between where the parent clip is on the Z axis and where the children clips are on their Z axis. For the first item you put a '-' before the calculations so that the value returned is negative. That's because you're only ever going to see this item zoom in from behind the viewport, so you really only need to see it blur back in.
The SimpleZSorter class is great because it automatically sorts the depths of all items inside of the parent clip. That is, the depth as in the stage/display depth (child index), not the physical or Z depth. This keep items that are physically further away behind items that are physically closer (Z property). Great stuff.
function bOver(e:MouseEvent):void
{
if(e.target == b1){
Tweener.addTween(b1, {x:753.1, time:1});
}else if(e.target == b2){
Tweener.addTween(b2, {x:808.8, time:1});
}else if(e.target == b3){
Tweener.addTween(b3, {x:881.2, time:1});
}else if(e.target == b4){
Tweener.addTween(b4, {x:925.9, time:1});
}else if(e.target == b5){
Tweener.addTween(b5, {x:796.7, time:1});
}else if(e.target == b6){
Tweener.addTween(b6, {x:845, time:1});
}
}
//
function bOut(e:MouseEvent):void
{
if(e.target == b1){
Tweener.addTween(b1, {x:773.1, time:1});
}else if(e.target == b2){
Tweener.addTween(b2, {x:828.8, time:1});
}else if(e.target == b3){
Tweener.addTween(b3, {x:901.2, time:1});
}else if(e.target == b4){
Tweener.addTween(b4, {x:945.9, time:1});
}else if(e.target == b5){
Tweener.addTween(b5, {x:816.7, time:1});
}else if(e.target == b6){
Tweener.addTween(b6, {x:865, time:1});
}
}
The bOver and bOut functions are pretty straight forward. Keep in mind that the values entered into the tweens in these functions are relative to your buttons exact positions on the stage. All you're doing here is determining which button you rolled over/off of and shifting it's X property by 20 pixels. So, for example in bOut if your b1's x property on the stage was 100, you would want that tween value to be x:100 because that tween is designed to return the button to it's original positions. Vise/versa for the bOver function.
Anyway once the code is done and you actually get to use this I hope you enjoy. All of my customers have loved it, it's quite a selling feature. I am chaging my website design in a couple of months so I don't care if people do something similar. I do encourage everyone to personalize this as much as possible. You can go really cookey and make the items kind of FLY/SWING in from the back right and into focus or even add a spin to the animations where the items rotate on their Y axis all kinds of stuff. This is just a kind of platform on which I suspect you'll improve and expand the functions. If you have any questions you can email me ascensionsystems@gmail.com and I'll be sure to bring the question back to the forum to address it in a post some place or another.
Spread The Word
Related Links
14 Responses to "3D Menu in Flash CS3/CS4 using Flash Player 10 3D API" 
|
said this on 03 Dec 2008 1:07:21 PM CST
is there some reason why
|
|
said this on 03 Dec 2008 1:14:15 PM CST
Josh,
Thanks for posti |
|
said this on 03 Dec 2008 1:29:14 PM CST
Okay, nevermind..........
You use the zipTo functi [as] function z addEventListener(Eve if(e.target == b1) Tweener.addTween(myS }else if(e.target == b2 Tweener.addTween(my }else if(e.target == b Tweener.addTween(m }else if(e.target == Tweener.addTween( }else if(e.target == Tweener.addTween }else if(e.target = Tweener.addTwee } } function r { remove }[/a You'll notice I add |
|
said this on 03 Dec 2008 2:33:18 PM CST
Thanks for the quick resp
|
|
said this on 03 Dec 2008 2:51:29 PM CST
Brilliant, it rests at ze
|
|
said this on 04 Dec 2008 1:00:38 AM CST
Seems that moving <code>a
I guess I'm a |
|
said this on 04 Dec 2008 10:01:06 AM CST
Remember on the fourth pa
addE Tween That'll |
|
said this on 16 Jan 2009 6:24:55 AM CST
quick question...I am try
so |
|
said this on 03 Oct 2009 1:50:15 PM CST
You can actually use moti
|
|
said this on 03 Oct 2009 1:41:21 PM CST
Hi!
I've got these liste 1046: Ty 1046: 1061: Cal 1180: Call t 1172 I have only flash.g Hav |
|
said this on 03 Oct 2009 1:43:53 PM CST
1172: Definition flash.ge
I have only fla What ca |
|
said this on 03 Oct 2009 1:44:29 PM CST
1172: Definition flash.ge
I have only fla What ca |
|
said this on 03 Oct 2009 1:45:33 PM CST
1172: Definition flash.ge
I have only fla What ca |
|
said this on 14 Oct 2009 6:05:07 AM CST
I am sorry for duplicates
I made |


Author/Admin)