Flash Tutorials
How to Create Randomly Flying Away Movie
How to Place Flat Subject in Space
How to Place Flat Subject in Space (Russian)
How to Use loadMovie Function
How to Skew the Object
How to Load XML File
English Russian

How to place flat subject in space...
This lesson is for the people, who know geometry and Flash enough.

In the lesson How to skew... we described, how to skew the movie clip. In this lesson we shall use this method.
Let's place the flat object on the sphere. Changing the radius of sphere and the placement of object on it, we can cover all the points of space and all locations.
We shall begin from geometry.
Assume, that we want to place the square on the sphere. We pick the square because the calculations with it more easier than with other geometrical figure, and any flat geometrical figure can be covered by squares.
See pic.1.

Pic.1
Co-ordinates in space (Xv, Yv, Zv) is drawen so, that axis Xv points to us. Co-ordinates on plane (X, Y) is picked so, that axis X coincides with axis Yv, and Y - with axis Zv. Let's name co-ordinates of the point M in space (xv, yv, zv), and co-ordinates of it on plane (x, y). Then:
x = yv(1)
y = zv
Assume, we want to place the yellow square with size 1*1 by the sphere with the centre in the point (0, 0, 0) and radius R, this square looks as parallelogram on the picture. Let's create the rules of portrayal of the square in space: upper and lower sides are horizontal (despite of it contradicts to perspective rules) (if it does not spinning around its own centre), and left and right sides will be tilted by the rule, that we shall create now. The algorithm is simple: we shall change horizontal and vertical the sizes of our square, rotate it, press it from up to down and turn back.
Let's figure out what the degree of squeezing the horizontal and vertical the sizes of the square.

Pic.2
Pic.3
From pic.2:
l = cos α,
because the size of the square side equals to 1, and α we can find next way:
x
cos α = ------,
Rxy
where:
            
Rxy = x2 + y2
From pic.3:
h = cos β,
x
cos β = ------,
Rxz
where:
            
Rxz = x2 + z2


Pic.4
On the pic.4 we can see the parallelogram in one of the points of the spere. Sizes of the squares on any of the pictures do not equal to its size on the other pictures but it does not matter for us. Let's name the left lower angle of the parallelogram by γ. Then:
h
cos β = ------,
sin γ
and γ we can find from this: tg γ is derivative of red ellipse on pic.1 in the point named by M. Formula of this ellipse is:
x2y2
------ + ------ = 1,
a2R2
where R is the radius of the sphere. To find a, substitute co-ordinates of point M on plane for x and y in this formula (let's name them (xm, ym), we know them from (1)). So:
xm2ym2
------ + ------ = 1,
a2R2
and here is:
xm2R2
a2 = ------------,
R2 - ym2
Assuming that we know a (actually, it is enough to know a2):
            
/x2
y = R√1 -  ----,
a2
R x
tg γ = y' = -  ---------------------.
            
/x2
y = a21 -  ----
a2
Now the last thing that we have to do. See pic.5.

Pic.5
The yellow parallelogram is the parallelogram that we want to have. To make it from the square, we have to decrease horizontal and vertical sizes of initial square to p and q correspondingly (we shall
m
find them), rotate on φ, squeeze  ------ times (φ, m and n we have to find, too) and rotate
n
back on σ (it is marked on pic.5 by dotted arc, we shall determine it, too).
Let's calculate p and q. From similarity of the triangles ACD and CDK ([DK] is perpendicular dropped from the point named by D on the diagonal d):
dq
------ = ------,
qg
where g is the length of the segment [KC]. Hence:
        
q = d g
and g we can find from the triangle ACD1:
g = cos τ.
Here is:
d2 = l2 + w2 - 2 l w cos γ,
where d is the biggest diagonal of the parallelogram, l and w are lengths of its sides, and cos γ is the angle between w and l. Let's calculate smaller diagonal f of the parallelogram:
f2 = l2 + w2 - 2 l w cos (180° - γ) = l2 + w2 + 2 l w cos γ,
and here is from the triangle-quater of the parallelogram:
a2d2
------ = ------ + w2 - d w cos τ,
44
and here is from this:
d2w2
------ + w2 - ------
44
cos τ = ---------------------------.
d w
So, τ we already have found. Let's find the angle named by φ:
g
sin φ = ------,
q
The coefficient of squeezing δ is:
m
δ = ------,
k
            
k = q2 - g2,
            
m = m2 - g2.
The "back" rotation angle is:
σ = 180° - γ - τ.
All the calculations are done now. Now we are turning to Flash.
Let's create a Symbol named by FlatT. It the FlatT create a Symbol named by FlatT_, in FlatT_ - Symbol named by FlatT__, and at last in it draw such chipped square:
. Give the names to the created objects. FlatT__ inside FlatT_ name by mvFlatT__, FlatT_ inside FlatT name by mvFlatT_, and FlatT on the scene name by mvFlatT. We shall use FlatT and FlatT_ for deformation of the flat object, FlatT__ - to rotate the flat object in its own plane around its centre. ActionScript will be inside FlatT only. Imitation of the object named by mvFlatT in space will be made by the function placeOnSphere(xc,yc,vn,amn,nclF,nclB,vl), where xc, yc are co-ordinates of the sphere centre, vn - object with three fields vn.x_, vn.y_ and vn.z_ - co-ordinates of the object centre, that we want to look like moving in space, amn - rotation angle of the flat object in its own plane around its centre, nclF - the color of the forward side of the flat object, nclB - the color of the back side, and vl - the object like vn but for light source. Variable names are very close to the names that we used in the geometrical part of this lesson. The code of script can be optimized but after this it will not like geometrical part. Here is the code of this function:
4	 function  placeOnSphere(xc,yc,vn,amn,nclF,nclB,vl)
5	 {
6	   var rad;
7	   var l_,h_,w_;
8	   var vf;
9	   var tan_gamma;
10	   var q_;var  oe;
11	
12	   if(Math.abs(vn.x_)<0.001)
13	     vn.x_=0;
14	   if(Math.abs(vn.y_)<0.001)
15	     vn.y_=0;
16	   if(Math.abs(vn.z_)<0.001)
17	     vn.z_=0;
18	   XM=vn.x_;YM=vn.y_;ZM=vn.z_;
19	   rad=Math.sqrt(vn.x_*vn.x_+vn.y_*vn.y_+vn.z_*vn.z_);
20	
21	   vf=new Object();
22	   vf.x_=vn.y_;vf.y_=vn.z_;
23	
24	   placeXYZ(xc,yc,vf);
25	
26	   mirrorM(vn);
27	
28	   tan_gamma=def_tan_gamma(rad,vf);
29	   l_=defL_(vn);
30	   h_=defH_(rad,vn);
31	   if(tan_gamma!='i')
32	   {
33	     if(vn.y_>=0)
34	       gamma=Math.PI+Math.atan(tan_gamma);
35	     else
36	       gamma=Math.PI-Math.atan(tan_gamma);
37	   }
38	   else
39	     gamma=Math.PI/2;
40	   w_=h_/Math.sin(gamma);
41	
42	   oe=new Object();
43	   q_=defQ_(l_,w_,gamma,oe);
44	   mvFlatT_._xscale=oe.p_*100;
45	   mvFlatT_._yscale=q_*100;
46	   mvFlatT_._rotation=oe.fi/Math.PI*180;
47	   if(vn.y_*vn.z_<0)
48	     mvFlatT_._rotation=-mvFlatT_._rotation;
49	   _yscale=oe.delta*100;
50	   _rotation=oe.sigma/Math.PI*180;
51	   if(vn.y_*vn.z_<0)
52	     _rotation=-_rotation;
53	
54	   rotateN(vn,amn);
55	
56	   if(vl!=null)
57	     lightM(vn,nclF,nclB,vl);
58	 }
Internal variables of this function:
rad - sphere radius.
l_,h_,w_ - l, h, w from the geometrical part of this lesson.
vf - the object with the co-cordinates vf.x_ and vf.y_ on the plane (x and y).
tan_gamma - tg γ.
q_ - something close to q - fraction of the initial length (vertical size) of the flat object.
oe - object with the fields p_, g_, delta, fi, sigma - p, g, δ, φ and σ correspondingly. The field p_, like the field q_ is also fraction of the initial length (horizontal size) of the flat object.
Lines 12 - 17 are for checking of co-ordinates if they are too small, it is better to assign them to zero to avoid inaccurate calculations. In the line 18 we assign global variables for external using.
In the line 19 we calculate radius of the sphere on which we want to stick mvFlat.
In the lines 21 and 22 we create the object vf (co-ordinates on plane).
In the line 24 we call the function placeXYZ(xc,yc,vf), that places the mvFlat in the specific point of the screen.
In the line 26 the function mirrorM(vn) converts the mvFlat, if it is on the back side of the sphere.
In the line 28 the function def_tan_gamma returns tg γ, if it exists, or 'i' otherwise. The lines 29 and 30 calculate l_ and h_, the lines 31 - 42, to our mind, do not need comments.
In the line 43 the function defQ_(l_,w_,gamma,oe) returns q_, and assigns all the fields of object oe.
Further (the lines 44 - 48) we change length and width of the mvFlatT_, and rotate it. In the line 49 we squeeze the mvFlatT from up to down, and in the lines 50 - 52 rutate back. Pay attention that the first time we rotate the mvFlatT_, but backwards we rotate the mvFlatT.
In the line 54 we rotate the object around its centre on the angle amn, and in 57th - light up if vl is not null.
Here is other method of the FlatT:
function  attachSymbol(ssn)
{
mvFlatT_.mvFlatT__._visible=0;
mvFlatT_.attachMovie(ssn,'mvFlatTAt__',1);
}
It allows us to replace the mvFlatT__ on any object we have.
Other function we shall not describe because you can find them in FLA. If you have questions, do not hesitate to ask us, we shall answer them.
How can we use it?..
Example. Flat Object On the Sphere Download

Other Example. Octahedron
Download Source

Other Example.

Download(here is the old previous algorithm but it is very close to above-stated)
Remarks
tadacip
2017-04-19 10:52:42
http://cialisgenericbuyrx.com
/
Anadia daily Ovar viagra medicamento Vale de Cambra v is for viagra Ovar cialis o que ?
Cara menyembuhkan
pneumonia

2017-03-13 22:47:09
http://www.obatasamuratala
mi.net/cara-herbal-menye
thank u so much admin and sorry permission share in here :)
Brainstorm
2017-03-03 06:15:54
https://www.promoocodes.c
om
I really like this thank you so much. i am very glad to see this. It was truly an interesting article.
cialis
2017-02-28 04:24:08
http://cia1sideffects.com/
Pregnancy and breast-feeding: Professional is not approved for use of women.
Obat Ginjal Bengkak
2017-02-14 01:47:24
http://penyembuhanyangala
mi.blogspot.co.id/2015/12
web stte ts truly useful t ilso enjoy the look, tt's tncredtble!. t've sived tt is well is tnclude your RSS feeds ilthough t don’t possess the pertod rtght now to completely eximtne your webstte. t'll be tn two or eich diy. thinks to getttng i wonderful webstte
cheap
2017-01-25 02:46:01
http://v1buyonline.com/
Records, improves alerts for work fast and then came.
method to hack pixel g
un 3d

2016-12-24 10:16:31
http://blitzbrigadehacker.com
visit and get simplest method to hack pixel gun 3d game played online.
fast
2016-12-21 11:10:27
http://viafast12v.com/
But not before asking for more .
Target Promo Codes
2016-12-10 04:42:23
https://www.couponpitara.co
m/offers/target/
Thanks for posting the how to place the object in a flat surface keep posting
discount
2016-11-24 02:20:23
http://c9superactive.com/
Your best source for buying high quality Super P-Force at Zefat, Mevo Betar online.
viagra
2016-10-19 09:49:11
http://sale5viagonline.com/
How to buy online, buy viagra from canada buy viagra for women .
viagra_pills
2016-09-15 02:34:20
http://vr9onlinesale.com/

franky
2012-07-26 01:31:01
great& smart &nice...
dicky
2011-10-08 08:42:32
http://www.dickyunrealworld
.blogspot.com
nice and comlicated
warna somarathna
2011-08-18 23:10:02
Very nice tutorial!
true religion
2010-10-19 21:13:55
http://www.cheap-jeans.org
/
Your article was good, ah, I love it. Hope to have more words for us to read! I wish you all the best! !
RakeshN
2007-10-24 08:03:35
RKnaagar@yahoo.com
Outstanding_Mind-blowing
manuel
2007-09-19 09:54:34
none
the best
Dahlia
2007-08-31 06:00:47
dahlia83@rediffmail.com
Great tutorial..!Nice work
unknown
2007-08-20 11:46:48
the code is pretty difficult to copy :| the line numbers are selected too... it's great, though
Sas
2007-03-19 21:22:43
Why, i can not open source code (macromedia unformated) THK
joesephhardson
2007-03-15 13:23:27
i need email
Marian
2007-02-23 08:17:41
http://www.pureflash.net
nice work.
saimon69
2007-02-15 15:56:54
http://www.nextstagedigital.
com/
What about a tutorial where to place text around a cylinder that can be rotated full 3d in isometric space?
sherina
2007-02-07 01:33:26
gemini_girlz_88@yahoo.com
haluuu....
it's amazing
but i cannot do it
:'(
huhuuuu
debasish
2006-12-12 05:21:20
debasish_tri@redifmail.com
It's too good. All the best
for your great implementation process in animation concepts
amaal
2006-11-05 10:04:32
amaal_zohny@yahoo.com
Very nice tutorial! i need tutorials to learn more about mathimatical scripts what ur advice ??!!
val
2006-04-10 08:24:31
waleexas@yahoo.co.uk
http://www.paint33ng.3x.ro
Super......I like that ! ! !
I want more....
lubnan
2006-02-13 09:11:36
lubnan_83@hotmail.com
yeah real nice work! But it's a bit to complicated!!
rafael parra
2005-12-14 20:35:22
rafaelparra@intercable.net.v
e
Just to congratulate.
I would not even attempt to follow your instructions. At my level this simply unbelievable.
robin
2005-12-07 23:52:39
Genius! Thank you. Very good tut! Wish I had your math skills..
Swift3D you guys say? You cant do this with Swift3D!
oldarney
2005-11-15 14:43:22
i hate math so now ive decided to get the swiff 3d plugin for 3ds max.
Dan
2005-11-08 23:42:11
sarcus11@rogers.com
Good turtorial but after that I think I will shell out for Swift 3D.
Dilemmas
2005-10-04 22:53:26
k1j1k@hotmail.com
very nice tutorial~! but its really complicated... :S i dont get much of the math ...
HoTDaWg
2005-07-23 16:48:25
Dude, I try my hardest to get away from math! Still pretty good!
NTD
2005-04-21 06:20:30
Very nice tutorial. You have a very good understanding of Math and Actionscript.
kuroneko
2005-04-06 07:55:43
very complicated one, yet very useful, thanks
Hendri
2005-03-22 20:20:17
web-designs@pinahans.org
http://www.garnisun.com
Hm..ou are creative !!!
WebMaster ActionScrip
ter

2004-12-22 07:08:22
http://www.batterydrink.com

Na weon si me sobra caleta de cerebro pa hacer esta wea inutil, lo que me falta es tirmpo, chuala
Daniel
2004-12-09 21:33:38
skuall21@yahoo.com.mx
it's really cool, salutes from Mexico
JUDE
2004-12-04 07:57:48
jude_nilo@yahoo.co.in
http://www.vemix.com
I'm very proud to send a mesg to
my citizen(brother).all the best
for your great implementation process in animation concepts.

send a source code to animate
a figure
Evan Strom
2004-11-23 23:55:02
Spalvl_hunter@hotmail.com
Wow, what a waste of time to just create a 3d effect. Nice code though.
Jurgen
2004-11-20 07:40:16
jurgen_linder@yahoo.com
Wow. One of the best actionscripts I ever saw. I cannot believe how much you achieve within these few lines of code.
D.rajashekar
2004-10-18 12:07:31
it's amazing
one requaste

Plz can u write the script in simple way
jonathan
2004-10-14 06:31:30
boink_blunt55@yahoo.com
nice
Alexander
2004-06-18 17:17:49
shul54@yhoo.com
Awesome, formidable, beautiful, perfect, smart...etc.
NTD
2004-06-15 18:27:14
Hi,

Very nice tutorial! Your understanding of math and geometry is impressive. Nice work.

Regards
NTD
Add Your Remark:
Your Name*:
Email:
Hide Email    Subscribe to Site News
Web Site:
Message*:
Other tutorials:
JavaScript Tutorials