Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is this 3d menu original or has it been done? 1

Status
Not open for further replies.
I have seen 3D a square like that before but not with menu items attached to the corners Regards
David Byng
spider.gif

davidbyng@hotmail.com
 
I haven't seen it anywhere else ...but i have to say that is very cool!!! i really like it...do you want to share it or just ask for oppinions? Regards,
Dragos.


 
Here you go:

Code:
// [onClipEvent of sprite 1 in frame 1]
onClipEvent (load) {
    message = "Click, Drag, and Go";
}

// [onClipEvent of sprite 2 in frame 1]
onClipEvent (load) {
    leader = 0;
    halfwidth = _parent.menuwidth[leader] / 2 + _parent.buffer;
}

onClipEvent (mouseMove) {
    current_leader = _parent.get_leader();
    if (current_leader != leader) {
        if (covered) {
            name = eval("_parent.menu" + leader);
            colorful = new Color(name);
            colorful.setRGB(_parent.regular_colour);
            covered = false;
        }
        leader = current_leader;
        sized = false;
        halfwidth = _parent.menuwidth[leader] / 2 + _parent.buffer;
        trace(_parent.menuwidth[leader]);
    }
    else if (covered) {
        _parent.cursor._x = _parent.point[leader][3];
        _parent.cursor._y = _parent.point[leader][4];
    }
}

onClipEvent (enterFrame) {
    if (sized) {
        _parent.change_width(leader, halfwidth);
    }
    if (covered) {
        _parent.ease_position(leader);
        _parent.check_close(leader);
    }
}

// [onClipEvent of sprite 2 in frame 1]
onClipEvent (load) {
    scale = 0.010000;
}

onClipEvent (mouseMove) {
    if (dragging) {
        xpower = _parent._xmouse - xlast;
        ypower = _parent._ymouse - ylast;
        xlast = _parent._xmouse;
        ylast = _parent._ymouse;
        xpower = xpower * scale;
        ypower = ypower * scale;
        _parent.rotate(ypower, xpower, 0);
        _parent.rotate_shadow();
        _parent.plot_label();
        _parent.draw_menu_shadow();
        updateAfterEvent();
    }
}

// [Action in Frame 1]
number_of_points = 8;
number_of_lines = 12;

function rotate(xrotate, yrotate) {
    xrotate_cosine = Math.cos(xrotate);
    xrotate_sine = Math.sin(xrotate);
    yrotate_cosine = Math.cos(yrotate);
    yrotate_sine = Math.sin(yrotate);
    for (i = 0; i < number_of_points; i++) {
        rotate_xaxis(i, xrotate_cosine, xrotate_sine);
        rotate_yaxis(i, yrotate_cosine, yrotate_sine);
        get_perspective_ratio(i);
        get_xreal(i);
        get_yreal(i);
    }
    plot();
}
function rotate_xaxis(what, cosine, sine) {
    ytemp = point[what][1];
    ztemp = point[what][2];
    point[what][1] = ytemp * cosine - ztemp * sine;
    point[what][2] = ztemp * cosine + ytemp * sine;
}
function rotate_yaxis(what, cosine, sine) {
    xtemp = point[what][0];
    ztemp = point[what][2];
    point[what][0] = xtemp * cosine - ztemp * sine;
    point[what][2] = ztemp * cosine + xtemp * sine;
}
function rotate_zaxis(what, cosine, sine) {
    xtemp = point[what][0];
    ytemp = point[what][1];
    point[what][0] = xtemp * cosine - ytemp;
    point[what][1] = ytemp * cosine + xtemp;
}
function get_perspective_ratio(what) {
    point[what][5] = d / (zcenter + point[what][2] + d);
}
function get_xreal(what) {
    point[what][3] = point[what][0] * point[what][5];
}
function get_yreal(what) {
    point[what][4] = point[what][1] * point[what][5];
}
function plot() {
    draw_line(0, 1, 0);
    draw_line(1, 2, 1);
    draw_line(2, 3, 2);
    draw_line(3, 0, 3);
    draw_line(0, 4, 4);
    draw_line(1, 5, 5);
    draw_line(2, 6, 6);
    draw_line(3, 7, 7);
    draw_line(4, 5, 8);
    draw_line(5, 6, 9);
    draw_line(6, 7, 10);
    draw_line(7, 4, 11);
}
function draw_line(pt1, pt2, line) {
    name = eval(&quot;line&quot; + line);
    x1 = point[pt1][3];
    y1 = point[pt1][4];
    x2 = point[pt2][3];
    y2 = point[pt2][4];
    name._x = x1;
    name._y = y1;
    name._xscale = x2 - x1;
    name._yscale = y2 - y1;
}
d = 1000;
side = 200;
halfside = side / 2;
zcenter = 1000;
point0 = [-halfside, -halfside, -halfside];
point1 = [halfside, -halfside, -halfside];
point2 = [halfside, -halfside, halfside];
point3 = [-halfside, -halfside, halfside];
point4 = [-halfside, halfside, -halfside];
point5 = [halfside, halfside, -halfside];
point6 = [halfside, halfside, halfside];
point7 = [-halfside, halfside, halfside];
for (i = 0; i < number_of_points; i++) {
    name = eval(&quot;point&quot; + i);
    name.push(0);
    name.push(0);
    name.push(0);
}
point = new Array();
for (i = 0; i < number_of_points; i++) {
    name = eval(&quot;point&quot; + i);
    point.push(name);
    ratio = get_perspective_ratio(i);
    get_xreal(i, ratio);
    get_yreal(i, ratio);
}
for (i = 1; i < number_of_lines; i++) {
    duplicateMovieClip(line0, &quot;line&quot; + i, 16384 + -i);
}
rotate(0, 0);

function plot_label() {
    get_property();
    i = 0;
    if (i < number_of_points) {
        name = eval(&quot;menu&quot; + i);
        name._x = point[i][3];
        name._y = point[i][4];
        name._xscale = menu_point[i][0];
        name._yscale = menu_point[i][1];
        name._alpha = menu_point[i][2];
        i++;
    }
}
function get_property() {
    i = 0;
    if (i < number_of_points) {
        menu_point[i][0] = point[i][5] * 200;
        menu_point[i][1] = point[i][5] * 200;
        menu_point[i][2] = (-point[i][2] + halfrange) / range * rangefade + minfade;
        i++;
    }
}
halfrange = Math.sqrt(Math.pow(halfside, 2) * 3);
range = 2 * halfrange;
maxfade = 100;
minfade = 5;
rangefade = maxfade - minfade;
menuwidth = new Array();
for (i = 0; i < number_of_points; i++) {
    name = eval(&quot;menu&quot; + i);
    menuwidth.push(name._width);
}
menu_point = new Array();
for (i = 0; i < number_of_points; i++) {
    name = eval(&quot;menu_point&quot; + i);
    name = new Array();
    name.push(0);
    name.push(0);
    name.push(0);
    menu_point.push(name);
}
plot_label();

function rotate_shadow() {
    for (i = 0; i < number_of_points; i++) {
        ratio = get_shadow_ratio(i);
        get_shadow_xreal(i, ratio);
        get_shadow_yreal(i, ratio);
    }
    plot_shadow();
}
function get_shadow_ratio(what) {
    perp_ratio = d / (zcenter + point[what][2] + d);
    return(perp_ratio);
}
function get_shadow_xreal(what, perp_ratio) {
    shadowpoint[what][0] = point[what][0] * perp_ratio;
}
function get_shadow_yreal(what, perp_ratio) {
    shadowpoint[what][1] = bottom * perp_ratio;
}
function plot_shadow() {
    draw_shadowline(0, 1, 0);
    draw_shadowline(1, 2, 1);
    draw_shadowline(2, 3, 2);
    draw_shadowline(3, 0, 3);
    draw_shadowline(0, 4, 4);
    draw_shadowline(1, 5, 5);
    draw_shadowline(2, 6, 6);
    draw_shadowline(3, 7, 7);
    draw_shadowline(4, 5, 8);
    draw_shadowline(5, 6, 9);
    draw_shadowline(6, 7, 10);
    draw_shadowline(7, 4, 11);
}
function draw_shadowline(pt1, pt2, line) {
    name = eval(&quot;shadow&quot; + line);
    x1 = shadowpoint[pt1][0];
    y1 = shadowpoint[pt1][1];
    x2 = shadowpoint[pt2][0];
    y2 = shadowpoint[pt2][1];
    name._x = x1;
    name._y = y1;
    name._xscale = x2 - x1;
    name._yscale = y2 - y1;
}
function draw_menu_shadow() {
    i = 0;
    if (i < number_of_points) {
        name = eval(&quot;menu_shadow&quot; + i);
        name._width = menu_point[i][1];
        name._alpha = menu_point[i][2];
        name._x = shadowpoint[i][0];
        name._y = shadowpoint[i][1];
        i++;
    }
}
bottom = 250;
for (i = 1; i < number_of_points; i++) {
    duplicateMovieClip(menu_shadow0, &quot;menu_shadow&quot; + i, 16384 + (-i - number_of_points - 3));
}
for (i = 1; i < number_of_lines; i++) {
    duplicateMovieClip(shadow0, &quot;shadow&quot; + i, 16384 + (-i - (number_of_points + 3) * 2));
}
shadow1.swapDepths(-number_of_lines);
shadowpoint = new Array();
for (i = 0; i < number_of_points; i++) {
    name = eval(&quot;shadowpoint&quot; + i);
    name = new Array();
    name.push(0);
    name.push(0);
    shadowpoint.push(name);
}
rotate_shadow();
draw_menu_shadow();

function get_leader() {
    closest = 0;
    for (i = 1; i < number_of_points; i++) {
        if (point[i][2] < point[closest][2]) {
            closest = i;
        }
    }
    return(closest);
}
function ease_position(leader) {
    cursor._x = cursor._x + (point[leader][3] - cursor._x) / ease_distance;
    cursor._y = cursor._y + (point[leader][4] - cursor._y) / ease_distance;
}
function check_close(leader) {
    xtopow2 = point[leader][3] - cursor._x;
    xtopow2 = xtopow2 * xtopow2;
    ytopow2 = point[leader][4] - cursor._y;
    ytopow2 = ytopow2 * ytopow2;
    distance = Math.sqrt(xtopow2 + ytopow2);
    if (distance < snapto) {
        name = eval(&quot;menu&quot; + leader);
        colorful = new Color(name);
        colorful.setRGB(highlight_colour);
        name.swapDepths(number_of_points);
        cursor_controller.covered = true;
        cursor._x = point[leader][3];
        cursor._y = point[leader][4];
    }
}
function change_width(leader, halfwidth) {
    cursor.left._x = cursor.left._x + -(halfwidth + cursor.left._x) / ease_width;
    cursor.right._x = cursor.right._x + (halfwidth - cursor.right._x) / ease_width;
    distance = Math.abs(cursor.left._x - halfwidth);
    if (distance < snapto) {
        cursor_controller.sized = true;
        cursor.left._x = -halfwidth;
        cursor.right._x = halfwidth;
    }
}
ease_distance = 1.750000;
ease_width = 4;
snapto = 3;
buffer = 6;
regular_colour = 16763904;
highlight_colour = 13056;
for (i = 0; i < number_of_points; i++) {
    name = eval(&quot;menu&quot; + i);
    colorful = new Color(name);
    colorful.setRGB(regular_colour);
}
Regards
David Byng
spider.gif

davidbyng@hotmail.com
 
well i was asking for opinions, plus i wanted to know was it an original idea or was i copying unawared
 
plus i am really surprised that you were able to extract my code, there's a lot of lines, sorry for the mess of jumbled up code
 
I have never such a big thread since i am on this forum :)
Think that i love a copy of the .fla DAVID.
Can you send it to my e-mail?
Thanks a lot! Regards,
Dragos.


 
Spiritdaway: you have made this one or you take it from somewhere?
Regards,
Dragos.


 
oh, i made it, but i got the idea of the box, cuz i saw swift3d and tried to intergrate the idea of interactive boxes in flash
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top