[Actionscript] [Away3d] Three-dimensional photo display demo

Source: Internet
Author: User
Tags addchild

This demo is to familiarize yourself with Away3d and Tweenlite, is a prototype of three-dimensional picture display, do not exclude the possibility of continuing to write a complete three-dimensional album.

To master the effect of animation display, the key is to understand the movement of objects in Away3d and camera movement.

In addition, a very simple loader shell was written to load the external SWF.

Demonstrate:

http://www.kxbd.com/mylab_as/090220TweenAnd3D/

Animation document class:

1package {
2/**//**
3 * Author:aken Li (http://www.kxbd.com)
4 * date:2009-03-02
5 * Dependencies:away3d 2.3, Tweenlite 10
6 */
7 Import away3d.cameras.*;
8 Import away3d.containers.*;
9 Import away3d.core.base.*;
Import away3d.core.math.*;
Import away3d.core.utils.*;
Import Away3d.events.MouseEvent3D;
Import away3d.primitives.*;
Import away3d.materials.*;
Import Away3d.core.render.Renderer;
16
Import GS. Tweenlite;
Import gs.easing.*
Import GS. Overwritemanager;
20
Import flash.display.*;
Import flash.events.*;
23
public class Num08 extends MovieClip {
The private var view:view3d;
-private var objarr:array = [];
The private var objnum:uint = 4;
private Var Objcontainer:objectcontainer3d;
private Var cam:camera3d;
private var Movecontainer:boolean = true;
to private var Islarge:boolean = false;
The private var islookat:uint;
33
The Public Function Num08 () {
Init ();
36}
37
Private Function init () {
Overwritemanager.init (Overwritemanager.auto);
40
view = new View3D ({x:400, y:300});
AddChild (view);
View.renderer = renderer.intersecting_objects;
44
The cam = new Camera3d ({x:0, y:0, z:-1000});
Cam.lookat (New Number3d (0, 0, 0));
View.camera = Cam;
48
Objcontainer = new Objectcontainer3d ();
for (var i = 0; i < Objnum; i++) {
Wuyi var obj:plane = Makeplane (i);
Obj.usehandcursor = true;
Objarr.push (obj);
Objcontainer.addchild (obj);
55}
View.scene.addChild (Objcontainer);
57
Objnum for (i = 0; i < i++) {
_mobj var = objarr[i];
Tweenlite.to (_mobj, (5-i) * 0.5,
y:150 * i-225, DELAY:I * 0.5, Ease:Elastic.easeOut,
Oncomplete:comfunc, Oncompleteparams:[i, _mobj]};
63}
Tweenlite.to (Objcontainer, 3, {rotationx:360, rotationy:360, rotationz:360, Oncomplete:addoverfx});
65
AddEventListener (Event.enter_frame, Render);
AddEventListener (Event.added_to_stage,function () {
Stage.addeventlistener (Mouseevent.click, Clickscene);
69});
70}
71
The Private function Comfunc (I:uint, Mobj:plane) {
Movecontainer = false;
mobj.z = 0
Mobj.addonmousedown (Clickobj);
76}
77
The Private Function Addoverfx () {
(var i = 0; i < Objnum; i++) {
Objarr[i].addonmouseover (Moveupobj);
Bayi Objarr[i].addonmouseout (movedownobj);
82}
83}
84
The Private Function Removeoverfx () {
for (var i = 0; i < Objnum; i++) {
Objarr[i].removeonmouseover (Moveupobj);
Objarr[i].removeonmouseout (Movedownobj);
89}
90}
91
The Private Function Moveupobj (E:mouseevent3d) {
Tweenlite.to (E.object, 0.5, {z:-50});
94}
95
Private Function Movedownobj (E:mouseevent3d) {
Tweenlite.to (E.object, 0.5, {z:0});
98}
99
The Private Function Clickobj (E:mouseevent3d) {
The var _obj = E.object;
102 var _clicked = Objarr.indexof (_obj);
if (!islarge) {
Removeoverfx ();
Enlargepic (_obj);
IsLarge = true;
}else if (_clicked==islookat) {
108 Addoverfx ();
109 Diminishpic (_obj);
IsLarge = false;
}else {
112 Diminishpic (Objarr[islookat]);
113 Enlargepic (_obj);
114 IsLarge = true;
115}
116}
117
118 Private Function Clickscene (e:mouseevent) {
119 if (E.target==stage&&islarge) {
Addoverfx ();
121 diminishpic (Objarr[islookat]);
122 IsLarge = false;
123}
124}
125
126 Private Function Enlargepic (obj) {
127 Islookat = Objarr.indexof (obj);
128 Tweenlite.to (Objcontainer, 1, {z:-650});
129 tweenlite.to (CAM, 1, {y:obj.y});
130 tweenlite.to (obj, 1, {z:-50});
131 obj.material = new Bitmapmaterial (Cast.bitmap ("imgB0" + (islookat+1)));
132}
133
134 Private Function Diminishpic (obj) {
135 tweenlite.to (Objcontainer, 1, {z:0});
136 tweenlite.to (CAM, 1, {y:0});
137 tweenlite.to (obj, 1, {z:0});
138 obj.material = new Bitmapmaterial (Cast.bitmap ("img0" + (islookat+1)));
139}
140
The Render private function (e:event) {
View.render ();
143 Objcontainer.rotationx =-view.mousey * 0.1;
144 Objcontainer.rotationy = View.mousex * 0.1;
145}
146
147 Private Function Makeplane (i:uint):P Lane {
148 var obj = new Plane ({material: "Blue#white", width:200, height:150, Segmentsw:6, segmentsh:4});
149 Obj.bothsides = true;
obj.material = new Bitmapmaterial (Cast.bitmap ("img0" + (i+1));
151 Obj.back = new Bitmapmaterial (Cast.bitmap ("img05"));
152 Obj.yup = false;
153 obj.x = 0;
154 obj.y = 650;
Obj.z = i;
156 Obj.name = i + 1;
157 return obj;
158}
159
160}
161
162}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.