Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   Перевод AS2 в AS3, дайте совет (http://www.flasher.ru/forum/showthread.php?t=144869)

nic233 23.09.2010 08:54

Перевод AS2 в AS3, дайте совет
 
Вложений: 1
Здравствуйте! У меня есть небольшая задача. Нужно перевести несколько строк кода из ActionScript 2 в ActionScipt 3. Я совсем плохо-плохо знаю AS3, только приступил к его изучению, но мне надо перевести программу. Я не знаю к кому обратиться потому решил написать в этот форум. Может кто ни будь, чем ни будь, поможет, или даст совет? Заранее благодарен!!!

zuxul 23.09.2010 09:51

http://www.flasher.ru/forum/showthread.php?t=85645

TWETTI 23.09.2010 10:12

Можешь скинуть сюда код, который надо перевести на AS3?

nic233 23.09.2010 10:36

Первый фрейм
Код AS1/AS2:

mas = new Array();
for(f=0;f<1000;f++){
        mas[f]=0
}
radius1 = 50;
radius2 = 60;
angle = 0;
MouseAngle = 0;
alfa = 0;
alfa2 = 0;
us = 0;
us2 = 0;
vx1 = -100;
vx2 = 900;
vy1 = -100;
vy2 = 900;
povorot = 0;
radius = 0;
timer = 0;
timer2 = 0;
radius2 = 0;
nxt = 0;
testtop = false;
mas[0] = "";
mas[1] = "";
mas[2] = "";


Второй фрейм
Код AS1/AS2:

onEnterFrame = function () {
        ax = _xmouse;
        ay = _ymouse;
        axx = ax-ax1;
        ayy = ay-ay1;
        ax1 = ax;
        ay1 = ay;
        if ((axx>0 and ay<240) or (axx<0 and ay>240)) {
                us2 = us2+1;
        }
        if ((axx<0 and ay<240) or (axx>0 and ay>240)) {
                us2 = us2-1;
        }
        if ((ayy>0 and ax<320) or (ayy<0 and ax>320)) {
                us = us+1;
        }
        if ((ayy<0 and ax<320) or (ayy>0 and ax>320)) {
                us = us-1;
        }
        x = Math.cos(angle*Math.PI/180)*us2*2.5;
        y = Math.sin(angle*Math.PI/180)*us*2.5;
        if (us<0) {
                angle = angle-10;
        }
        if (us>0) {
                angle = angle+10;
        }
        if (angle>359) {
                angle = 0;
        }
        if (angle<0) {
                angle = 350;
        }
        ap._x = 320+x;
        ap._y = 240+y;
        newRadius = Math.sqrt(x*x+y*y);
        x = Math.cos((angle)*Math.PI/180)*newRadius;
        y = Math.sin((angle)*Math.PI/180)*newRadius;
        function direction(x1, y1, x2, y2) {
                return Math.atan2(y2-y1, x2-x1)/Math.PI*180;
        }
        if (us2>0) {
                us2 = us2-0.3;
        }
        if (us2<0) {
                us2 = us2+0.3;
        }
        if (us>0) {
                us = us-0.3;
        }
        if (us<0) {
                us = us+0.3;
        }
        if (us2>59) {
                us2 = 59;
        }
        if (us2<-59) {
                us2 = -59;
        }
        if (us>59) {
                us = 59;
        }
        if (us<-59) {
                us = -59;
        }
        if (alfa>360) {
                alfa = 0;
        }
        mbx = 320-ap._x;
        mby = 240-ap._y;
        radius = int(Math.sqrt((mbx*mbx)+(mby*mby)));
        if (timer>0 and timer2 == 1) {
                timer++;
                if (radius>radius2 and testtop == false) {
                        mas[nxt*3] = timer;
                        if (angle>=0) {
                                mas[(nxt*3)+1] = angle;
                        }
                        if (angle<0) {
                                mas[(nxt*3)+1] = angle*-1;
                        }
                        testtop = true;
                }
                if (testtop == true and radius<radius2) {
                        testtop = false;
                        pp = mas[(nxt*3)];
                        if (pp != 0) {
                                if (angle>=0) {
                                        mas[(nxt*3)+2] = angle;
                                }
                                if (angle<0) {
                                        mas[(nxt*3)+2] = angle*-1;
                                }
                                a1 = mas[nxt*3];
                                a2 = mas[(nxt*3)+1];
                                a3 = mas[(nxt*3)+2];
                                nxt++;
                                for (f=0; f<1000; f++) {
                                        s1 = mas[(f*3)];
                                        s2 = mas[(f*3)+1];
                                        s3 = mas[(f*3)+2];
                                        if (s1 == 0 and s2 == 0 and s3 == 0) {
                                                break;
                                        }
                                        trace(s1+"  "+s2+"  "+s3);
                                }
                        }
                }
        }
};
_root.onMouseDown = function() {
        if (timer>0 and timer2 == 1) {
                timer = 0;
                timer2 = 0;
                testtop = false;
        }
        if (timer == 0 and timer2 == 0) {
                timer = 1;
                timer2 = 1;
                radius2 = radius;
        }
};
stop();

Добавлено через 5 часов 14 минут
Тема не актуальна. Исходник переделал.


Часовой пояс GMT +4, время: 14:51.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.