Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   Свободно плавающий мувик (http://www.flasher.ru/forum/showthread.php?t=106245)

grun 07.01.2008 12:05

Свободно плавающий мувик
 
Я не очень то шарю в action script'е, поэтому люди добрые помогите!

Задача такова - есть мувик(логотип), он должен произвольно ездить по странице стукаясь о края, при этом издавать звук, при наведении на него он должен останавливаться и увеличиваться.

Вообщем аналогично http://wacom.com/index.html

Очень нужно ребят! Выручайте!

MrPoma 07.01.2008 12:14

Код:

var w:Number =Stage.width;
var h:Number = Stage.height;

var dx:Number = 5;
var dy:Number = 5;

mc.onRollOver = function(){
      delete this.onEnterFrame;
      _xscale = _yscale = 110;
}

mc.onRollOut = function(){
      _xscale = _yscale = 100;
      move();
}

function move():Void{
    mc.onEnterFrame = function(){
          if(_x>(w-_width/2) || _x<_width/2){
              dx *= -1;
              //проиграть звук
          }

          if(_y>(h-_height/2) || _y<_height/2){
              dy *= -1;
              //проиграть звук
          }
          _x += dx;
          _y += dy;
    }
}

move();


screamge 07.01.2008 12:38

grun, не нужно множить темы в разных разделах, достаточно в одном один раз написать.

grun 07.01.2008 13:28

MrPoma, спасибо большое за ответ, но не мог бы ты более полно скрипт написать, ато вроде опробовал а мувик тупо дергается на месте вверх вниз. я в АС почти нуль. Заранее большое спасибо!

MrPoma 07.01.2008 13:35

дык проверьте. вытаскиваете логотип на сцену, обзываете его mc и вставляете код в кадр.

зы. возможно он не работает. не проверял

grun 07.01.2008 13:38

Проверил, дергается на месте

MrPoma 07.01.2008 13:59

что у вас стоит в настройках публикации?

grun 07.01.2008 14:17

MrPoma, AS2 - если про это, флеш cs3
ВОт это нашел в исходниках здесь(bukvaM - трехмерная буква вращается), мб отсюда можно как то выдернуть что мне нужно
Код:

gCorners = new Array();
gCorners[0] = [-50, -50, -20];
gCorners[1] = [-16, -50, -20];
gCorners[2] = [0.5, 16, -20];
gCorners[3] = [16, -50, -20];
gCorners[4] = [50, -50, -20];
gCorners[5] = [50, 50, -20];
gCorners[6] = [27, 50, -20];
gCorners[7] = [27, -27, -20];
gCorners[8] = [9, 50, -20];
gCorners[9] = [-9, 50, -20];
gCorners[10] = [-27, -27, -20];
gCorners[11] = [-27, 50, -20];
gCorners[12] = [-50, 50, -20];
//
for (i=13; i<26; i++) {
        gCorners[i] = [gCorners[i-13][0], gCorners[i-13][1], 20];
}
gCorners[26] = [0.1, 0.1, 20];
gCorners[27] = [0.1, -20, 0.1];
gCorners[28] = [20, 0.1, 0.1];
gCorners[29] = [Math.cos(13.5*Math.PI/180)*20, -Math.sin(13.5*Math.PI/180)*20, 0.1];
gCorners[30] = [Math.cos(13.5*Math.PI/180)*20, Math.sin(13.5*Math.PI/180)*20, 0.1];
//
gRectList = new Array();
gRectList[0] = [0, 1, 14, 13, 1];
gRectList[1] = [1, 2, 15, 14, 3];
gRectList[2] = [2, 3, 16, 15, 4];
gRectList[3] = [3, 4, 17, 16, 1];
gRectList[4] = [4, 5, 18, 17, 2];
gRectList[5] = [5, 6, 19, 18, 1];
gRectList[6] = [6, 7, 20, 19, 2];
gRectList[7] = [7, 8, 21, 20, 4];
gRectList[8] = [8, 9, 22, 21, 1];
gRectList[9] = [9, 10, 23, 22, 3];
gRectList[10] = [10, 11, 24, 23, 2];
gRectList[11] = [11, 12, 25, 24, 1];
gRectList[12] = [12, 0, 13, 25, 2];
//
orden = new Array();
orden[0] = [4, 6, 3, 2, 1, 9, 0, 12];
orden[1] = [12, 10, 0, 1, 2, 7, 3, 4];
orden[2] = [5, 6, 7, 2, 8, 9, 11, 12];
orden[3] = [11, 10, 9, 1, 8, 7, 5, 4];
incremento1 = 2;
incremento2 = 2;
//
rojo = 255;
verde = 255;
azul = 0;
gCenter1 = 220;
gCenter2 = 180;
//
function plotPoint(objectInfo) {
        x = objectInfo[0];
        y = objectInfo[1];
        z = objectInfo[2];
        radius1 = Math.sqrt(x*x+y*y);
        if (x == 0.0) {
                angle = Math.atan(2000000);
        } else {
                angle = Math.atan(y/x);
        }
        if (x<0) {
                angle = Math.PI+angle;
        }
        angle = angle+gRotate;
        realX = radius1*Math.cos(angle);
        realY = radius1*Math.sin(angle);
        radius2 = Math.sqrt(realX*realX+z*z);
        if (realX == 0) {
                angle2 = Math.atan(2000000);
        } else {
                angle2 = (Math.atan(z/realX));
        }
        if (realX<0) {
                angle2 = Math.PI+angle2;
        }
        angle2 = angle2-gPlane;
        screenX = radius2*Math.cos(angle2);
        screenY = realY;
        screenZ = radius2*Math.sin(angle2);
        puntox = screenX+gCenter1;
        if (puntox<=0) {
                incremento1 = Math.abs(incremento1);
        }
        if (puntox>=400) {
                incremento1 = -Math.abs(incremento1);
        }
        puntoy = screenY+gCenter2;
        if (puntoy<=0) {
                incremento2 = Math.abs(incremento2);
        }
        if (puntoy>=400) {
                incremento2 = -Math.abs(incremento2);
        }
        puntoz = screenZ;
        point = [puntox, puntoy, puntoz];
        return (point);
}
function frameScript() {
        gRotate = gRotate-((_root._xmouse-gCenter1)/60)*Math.PI/180;
        gPlane = gPlane-((_root._ymouse-gCenter2)/30)*Math.PI/180;
        gCenter1 += incremento1;
        gCenter2 += incremento2;
        puntos = new Array();
        for (i=0; i<gCorners.length; i++) {
                temp = plotPoint(gCorners[i]);
                puntos[i] = temp;
        }
        if (puntos[0][2]>puntos[4][2]) {
                if (puntos[0][2]>puntos[12][2]) {
                        clave = 0;
                } else {
                        clave = 2;
                }
        } else {
                if (puntos[0][2]>puntos[12][2]) {
                        clave = 1;
                } else {
                        clave = 3;
                }
        }
        if (puntos[0][2]<puntos[13][2]) {
                pos = 13;
        } else {
                pos = 0;
        }
        rojo = Math.abs(puntos[26][2])*10+50;
        verde = Math.abs(puntos[26][2])*5+50;
        rojo1 = Math.abs(puntos[27][2])*10+50;
        verde1 = Math.abs(puntos[27][2])*5+50;
        rojo2 = Math.abs(puntos[28][2])*10+50;
        verde2 = Math.abs(puntos[28][2])*5+50;
        rojo3 = Math.abs(puntos[29][2])*10+50;
        verde3 = Math.abs(puntos[29][2])*5+50;
        rojo4 = Math.abs(puntos[30][2])*10+50;
        verde4 = Math.abs(puntos[30][2])*5+50;
        _root.createEmptyMovieClip("eme", 10);
        with (_root.eme) {
                beginFill((rojo << 16 | verde << 8 | azul), 100);
                moveTo(puntos[0+pos][0], puntos[0+pos][1]);
                for (i=1; i<13; i++) {
                        lineTo(puntos[i+pos][0], puntos[i+pos][1]);
                }
                endFill();
        }
        for (i=0; i<orden[clave].length; i++) {
                thisRect = gRectList[orden[clave][i]];
                q = [puntos[thisRect[0]], puntos[thisRect[1]], puntos[thisRect[2]], puntos[thisRect[3]]];
                _root.createEmptyMovieClip("cuadrado"+i, i+1);
                with (_root["cuadrado"+i]) {
                        beginFill((_root["rojo"+gRectList[orden[clave][i]][4]] << 16 | _root["verde"+gRectList[orden[clave][i]][4]] << 8 | azul), 100);
                        moveTo(q[0][0], q[0][1]);
                        lineTo(q[1][0], q[1][1]);
                        lineTo(q[2][0], q[2][1]);
                        lineTo(q[3][0], q[3][1]);
                        endFill();
                }
        }
}
stop();


MrPoma 07.01.2008 14:22

у-у-у.. даже разбираться неохото. попробуйте разобраться с кодом (пост №2). там ничего сложного. используйте trace()

grun 08.01.2008 13:26

MrPoma, никак не работает!!! =( Помогите пожалуйста!


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

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