PDA

View Full Version : Something complex.... translating AS 2 to AS 3.... PLEASE HELP!!


merapper
05-22-2008, 09:01 PM
Ok all this is is a satelite (in an external swf that 3D rotates and has stop on each frame)... All I want to do is make the satelite rotate on where the mouse cursor is on the stage... I have the code in AS 2... but I need to make it AS 3 so I can work with it coz it's made by a friend and he only knows as2, and i know only 3....


PLEASE HELP ME DO THIS... I know it's complex... and help me set the external swf too pls.... (i have the source of it too)...


this.onEnterFrame = function() {
//moving satelite
j += 5;
if (j>=100) {
j = 100;
}
satelit._xscale=j*75/100;
satelit._yscale=j*75/100;
satelit._alpha = j;


i += 0.1;
satelit._rotation = Math.sin(i)*2-30;
satelit._y = 200+Math.sin(i)*20;


if (pas == 0) {
bg._alpha += speed;
if (bg._alpha>=100) {
pas = 1;
}
}
if (pas == 1) {
menu._alpha += speed*3;
if (menu._alpha>=100) {
pas = 2;
pass = 0;
}
}
if (pas == 2) {
if (pass == 0) {
home._alpha += speed*2;
home._x -= speed*1.5;
if (home._alpha>=100) {
pass = 1;
}
}
if (pass == 1) {
aboutus._alpha += speed*2;
aboutus._x -= speed*1.5;
if (aboutus._alpha>=100) {
pass = 2;
}
}
if (pass == 2) {
services._alpha += speed*2;
services._x -= speed*1.5;
if (services._alpha>=100) {
pass = 3;
}
}
if (pass == 3) {
gallery._alpha += speed*2;
gallery._x -= speed*1.5;
if (gallery._alpha>=100) {
pass = 4;
}
}
if (pass == 4) {
contact._alpha += speed*2;
contact._x -= speed*1.5;
if (contact._alpha>=100) {
pass = 5;
pas = 3;
xpoz = contact._x;
}
}
}
if (pas == 3) {
sus._alpha += speed*3;
jos._alpha += speed*3;
sus.play();
jos.play();
if (sus._alpha>=100) {
pas = 4;
}
}
};

amarghosh
05-23-2008, 04:06 AM
its not much complex:
this.addEventListener(Event.ENTER_FRAME, onEnter);
function onEnter(e:Event):void
{
//copy and paste the contents of the method here.
//get rid of all underscores (_) in the code: _alpha is just alpha in AS3 and so on
//(rotation, x, y, alpha etc);
//_xscale and _yscale are now scaleX and scaleY
}

merapper
05-24-2008, 06:54 PM
and how do i make the video to be controlled by mouse possition?

amarghosh
05-26-2008, 04:11 AM
one more thing -- alpha is now 0 to 1 instead of 0 to 100; u might wanna make corresponding changes too. [change _alpha += speed * 2 to alpha += speed * 2 / 100;]
and how do i make the video to be controlled by mouse possition?

is it related to the first post or a new question?

anyway, simple answer is u will need event handlers for that;