My favorites
|
Sign in
undolibrary
Undolog coding repository
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
‹r49
r177
Source path:
svn
/
trunk
/
as3
/
piclens
/
PicLens.as
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package {
/*
** @name : PicLens.as
** @description : Test PicLens in Flash
** @author : =undo=
** @web : http://www.undolog.com
** @email : g.fazioli@undolog.com
**
** @ver : 1.0
*/
import flash.display.*;
import flash.events.*;
import flash.text.*;
import fl.transitions.*;
import fl.transitions.easing.*;
/*
** Import Papervision3D 2.0
*/
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.materials.*;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
/*
** Import UndoLibrary
*/
import undolibrary.ui.*;
//
public class PicLens extends Sprite {
// define constant
private const THUMBNAIL_WIDTH:uint = 300;
private const THUMBNAIL_HEIGHT:uint = 300;
private const THUMBNAIL_MARGIN:uint = 50;
private const THUMBNAIL_NUMBER:uint = 99;
private const CAMERA_ZOOM:uint = 3;
// properties
private var __slider:Knob;
private var __max:Number;
private var __imagexml:XML;
private var __thnumber:Number = 0;
private var __imgarray:Array = [];
private var __matarray:Array = [];
// test knob controls
private var __focusCamera:Knob;
private var __zoomCamera:Knob;
private var __fooTargetPosition:Knob;
// PV3D 2.0
private var __bv:BasicView;
private var __fooTarget:DisplayObject3D;
private var __material:BitmapAssetMaterial;
/*
** Constructor
*/
function PicLens() {
addEventListener(Event.ADDED_TO_STAGE, init );
}
/*
** @name : init()
*/
private function init( e:Event ):void {
initPapervision();
initMaterials();
initObjects();
initControls();
initListeners();
}
/*
** @name : initPapervision()
** @description : inizializza l'ambiente papervision
*/
private function initPapervision():void {
__bv = new BasicView(640, 480, false, true);
addChild( __bv );
__bv.camera.zoom = 2;
}
/*
** @name : initMaterials()
** @description : creo 100 piani con un'immagine - sia da RSS che non
*/
private function initMaterials():void {
__thnumber = THUMBNAIL_NUMBER;
var k = 0;
var i;
//
for(i=0; i < __thnumber; i++) {
__matarray.push( new BitmapAssetMaterial("foto1") );
k++;
}
}
/*
** @name : initObjects()
*+ @description : crea il rettabgolo 3*100
*/
private function initObjects():void {
__fooTarget = new DisplayObject3D();
//
var sx:Number = -THUMBNAIL_WIDTH*4;
var sy:Number = THUMBNAIL_HEIGHT*1.5;
var sz:Number = 0;
//
var xx:Number = 0
var yy:Number = 0;
var zz:Number = 0;
//
__fooTarget.z = sz + 10;
//
for(var i=0; i < __thnumber; i++) {
__matarray[i].smooth = true;
__matarray[i].interactive = true;
var photo1:Plane= new Plane( __matarray[i], THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 0, 0);
xx = sx + ( (THUMBNAIL_WIDTH+THUMBNAIL_MARGIN) * Math.floor( i/3 ) );
__bv.scene.addChild(photo1);
photo1.x = xx;
photo1.y = sy + (yy - (THUMBNAIL_HEIGHT+THUMBNAIL_MARGIN)*(i%3));
photo1.z = sz + zz;
photo1.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK,
function(e:InteractiveScene3DEvent):void {
new Tween(e.displayObject3D, 'z', Strong.easeOut, e.displayObject3D.z, 5000, 1, true);
}
);
}
__max = xx;
__bv.cameraAsCamera3D.target = __fooTarget;
}
/*
** @name : initControl()
** @description : aggiungo un semplice slider per scorrere e ricreare l'effetto PicLens
*/
private function initControls():void {
var panel:Sprite = new Sprite();
addChild( panel );
with( panel.graphics ) {
beginFill( 0x333333 );
drawRect( 0, 0, stage.stageWidth, 100 );
endFill();
}
panel.y = stage.stageHeight - 100;
// slider principale
__slider = new Knob();
panel.addChild( __slider );
__slider.x = 5;
__slider.y = panel.height - 25;
__slider.Color = 0x111111;
__slider.KnobColor = 0x0088ff;
__slider.Width = stage.stageWidth-10;
__slider.KnobWidth = 20;
__slider.Height = __slider.KnobHeight = 20;
__slider.Max = __max;
//
__focusCamera = new Knob();
panel.addChild( __focusCamera );
__focusCamera.x = 80;
__focusCamera.y = 5;
__focusCamera.KnobWidth = 10;
__focusCamera.KnobColor = 0xff9900;
__focusCamera.Min = 50;
__focusCamera.Max = 400;
__focusCamera.Value = __bv.cameraAsCamera3D.focus;
createLabel(__focusCamera, 'focus');
//
__zoomCamera = new Knob();
panel.addChild( __zoomCamera );
__zoomCamera.x = 80;
__zoomCamera.y = 25;
__zoomCamera.KnobWidth = 10;
__zoomCamera.KnobColor = 0xff9900;
__zoomCamera.Min = 0;
__zoomCamera.Max = 10;
__zoomCamera.Value = __bv.cameraAsCamera3D.zoom;
createLabel(__zoomCamera, 'zoom');
//
__fooTargetPosition = new Knob();
panel.addChild( __fooTargetPosition );
__fooTargetPosition.x = 80;
__fooTargetPosition.y = 45;
__fooTargetPosition.KnobWidth = 10;
__fooTargetPosition.KnobColor = 0xff9900;
__fooTargetPosition.Min = -1000;
__fooTargetPosition.Max = 1000;
__fooTargetPosition.Value = __fooTarget.z;
createLabel(__fooTargetPosition, 'target');
}
/*
** @name : createLabel()
*/
private function createLabel(s:Knob, l:String ):void {
var lab:LabelText = new LabelText();
lab.autoSize = true;
lab.label.text = l.toUpperCase();
lab.x = -60;
s.addChild( lab );
//
var val:LabelText = new LabelText();
val.name = 'labeliana';
val.autoSize = true;
val.label.text = String( Math.round( s.Value ) ).toUpperCase();
val.x = 200;
s.addChild( val );
//
s.addEventListener( KnobEvent.CHANGE,
function(e:KnobEvent):void {
e.currentTarget.getChildByName('labeliana').label.text = String( Math.round( e.Value ) );
}
);
}
/*
** @name : initListeners()
** @description : impostazione degli eventi
*/
private function initListeners():void {
addEventListener( Event.ENTER_FRAME, render );
}
/*
** @prototype
*/
private function render(e:Event):void {
__bv.cameraAsCamera3D.zoom = __zoomCamera.Value;
__bv.cameraAsCamera3D.focus = __focusCamera.Value;
__bv.cameraAsCamera3D.x += (( __slider.Value - __bv.cameraAsCamera3D.x)/10)/2.2;
__fooTarget.x += (( __slider.Value - __fooTarget.x)/5)/2.2;
__fooTarget.z = __fooTargetPosition.Value;
__bv.singleRender();
}
}
}
Show details
Hide details
Change log
r52
by g.fazi...@undolog.com on Jun 13, 2008
Diff
[No log message]
Go to:
/trunk/as3/piclens/PicLens.as
/trunk/as3/piclens/piclens.fla
/trunk/as3/undoloader/loader.fla
Project members,
sign in
to write a code review
Older revisions
r49
by g.fazi...@undolog.com on Jun 12, 2008
Diff
[No log message]
All revisions of this file
File info
Size: 6817 bytes, 237 lines
View raw file
Hosted by