A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: All Twisted

  1. #1
    Member
    Join Date
    Oct 2000
    Posts
    41

    All Twisted

    Hi,


    I have a piece of code
    It's a twisted rope like thing rotating.
    When i publish(F8 actionscript2).
    I've tried publishing with 4 and up, same problem
    I get this
    Any ideas?


    **Error** Scene=Scene 1, layer=Action Layer, frame=1:Line 34: Identifier expected
    var num = x[x] = {y: y, vx: 0, vy: 0, next: num + 1 == seg ? (0) : (num + 1), prev: num - 1 == -1 ? (seg - 1) : (num - 1), next2: num + 2 == seg ? (0) : (num + 2), 1: "prev2", num - 2 == -2 ? (seg - 2) : (num - 2): seg - 1};

    Total ActionScript Errors: 1 Reported Errors: 1



    AND HERE'S THE CODE(line 34 in red)

    Bubble = function (mc, col, seg, size)
    {
    this.mc = mc;
    this.col = col;
    this.seg = seg;
    this.radius = size / 2;
    this.setUp();
    };
    Bubble.prototype.setUp = function ()
    {
    var mc = this.mc;
    var seg = this.seg;
    var as = 6.283185 / seg;
    var r = this.radius;
    var nodes = this.nodes = [];
    var a = 0;
    while (a < 6.283185)
    {
    var x = Math.cos(a) * r;
    var y = Math.sin(a) * r;
    var num = nodes.length;
    if (num + 2 <= seg)
    {
    }
    else
    {
    } // end if
    if (num - 2 != -1)
    {
    }
    else
    {
    } // end if
    var num = x[x] = {y: y, vx: 0, vy: 0, next: num + 1 == seg ? (0) : (num + 1), prev: num - 1 == -1 ? (seg - 1) : (num - 1), next2: num + 2 == seg ? (0) : (num + 2), 1: "prev2", num - 2 == -2 ? (seg - 2) : (num - 2): seg - 1};
    a = a + as;
    } // end while
    var dx = nodes[1].x - nodes[0].x;
    var dy = nodes[1].y - nodes[0].y;
    this.dd = Math.sqrt(dx * dx + dy * dy);
    var dx = nodes[2].x - nodes[0].x;
    var dy = nodes[2].y - nodes[0].y;
    this.dd2 = Math.sqrt(dx * dx + dy * dy);
    };
    Bubble.prototype.render = function ()
    {
    var ten = -0.010000;
    var rel = 0.990000;
    var dd = this.dd;
    var dd2 = this.dd2;
    var r = this.radius;
    var nodes = this.nodes;
    for (var n in nodes)
    {
    var cn = nodes[n];
    var nn = nodes[cn.next];
    var pn = nodes[cn.prev];
    var nn2 = nodes[cn.next2];
    var pn2 = nodes[cn.prev2];
    var cnx = cn.x;
    var cny = cn.y;
    var nnx = nn.x;
    var nny = nn.y;
    var pnx = pn.x;
    var pny = pn.y;
    var nn2x = nn2.x;
    var nn2y = nn2.y;
    var pn2x = pn2.x;
    var pn2y = pn2.y;
    var cnvx = cn.vx;
    var cnvy = cn.vy;
    var dx = nnx - cnx;
    var dy = nny - cny;
    var d = Math.sqrt(dx * dx + dy * dy);
    var mx = dx / dd * d;
    var my = dy / dd * d;
    cnvx = cnvx + (dx - mx) * ten;
    cnvy = cnvy + (dy - my) * ten;
    var dx = pnx - cnx;
    var dy = pny - cny;
    var d = Math.sqrt(dx * dx + dy * dy);
    var mx = dx / dd * d;
    var my = dy / dd * d;
    cnvx = cnvx + (dx - mx) * ten;
    cnvy = cnvy + (dy - my) * ten;
    var dx = nn2x - cnx;
    var dy = nn2y - cny;
    var d = Math.sqrt(dx * dx + dy * dy);
    var mx = dx / dd2 * d;
    var my = dy / dd2 * d;
    cnvx = cnvx + (dx - mx) * ten;
    cnvy = cnvy + (dy - my) * ten;
    var dx = pn2x - cnx;
    var dy = pn2y - cny;
    var d = Math.sqrt(dx * dx + dy * dy);
    var mx = dx / dd2 * d;
    var my = dy / dd2 * d;
    cnvx = cnvx + (dx - mx) * ten;
    cnvy = cnvy + (dy - my) * ten;
    var amp = 1.500000;
    cnvx = cnvx + (Math.random() * amp - 0.500000 * amp);
    cnvy = cnvy + (Math.random() * amp - 0.500000 * amp);
    cnvx = cnvx - cnx / 222;
    cnvy = cnvy - cny / 222;
    (cn.vx = cnvx, cn.vy = cnvy);
    } // end of for...in
    var mc = this.mc;
    mc.clear();
    mc.lineStyle(1, 16763904, 100);
    for (var n in nodes)
    {
    var node = nodes[n];
    node.x = node.x + node.vx;
    node.y = node.y + node.vy;
    node.vx = node.vx * rel;
    node.vy = node.vy * rel;
    node.mc._x = node.x;
    node.mc._y = node.y;
    var n = Number(n);
    var node = nodes[n];
    var node_ = nodes[n - 1];
    var nx = node.x;
    var ny = node.y;
    var px = node_.x;
    var py = node_.y;
    if (n == nodes.length - 1)
    {
    var n0 = nodes[0];
    var n0_x = n0.x;
    var n0_y = n0.y;
    var sx = (nx + n0_x) / 2;
    var sy = (ny + n0_y) / 2;
    var ex = (nx + px) / 2;
    var ey = (ny + py) / 2;
    mc.moveTo(sx, sy);
    mc.curveTo(nx, ny, ex, ey);
    }
    else if (n > 0)
    {
    var tx = (nx + px) / 2;
    var ty = (ny + py) / 2;
    mc.curveTo(nx, ny, tx, ty);
    ex = (nx + px) / 2;
    ey = (ny + py) / 2;
    }
    else
    {
    mc.curveTo(n0_x, n0_y, sx, sy);
    } // end if
    } // end of for...in
    };
    XJ = new Bubble(scene, 16763904, 16, 300);
    onEnterFrame = function ()
    {
    XJ.render();
    };
    var i = 0;
    while (i < 20)
    {
    XJ.render();
    i++;
    } // end while

    Thanks again

    Trinitee

  2. #2
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    explain what you want the red line to do in english.

    Like, what do you want the variable next to be?

    explain all the variables where you use == and what you want them to be.

  3. #3
    Member
    Join Date
    Oct 2000
    Posts
    41

    Here it is in english

    Hi DrDoom,

    Thanks for your reply.

    Listen, i've attached the swf and fla in a zip(5k)
    It would be great if you could take a look at it.
    I didn't write the code and it was origanally published in flash6 ac1.
    The swf now works fine but it won't re-publish.
    What i would like it to do is exactly what it's doing now.I would to integrate it into an experiment publishing it in flash8 ac2.
    Publishing it now just comes up with code errors that i don't know how to fix.(in any publishing from 4 to 8 ac1 or2)

    Cheers
    Attached Files Attached Files

  4. #4
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    The code is just generally messed up, and its too complicated for me to sift through and work out whats wrong. It would take too much time. The error you're getting is because the (extremely confusing) syntax used in that red line is incorrect - in other words the properties of the object aren't being set correctly. Since I don't know how they should be set, I don't know how to fix this easily.

    I would suggest getting a better copy of the source code, if you remember where you found it.
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

  5. #5
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    dMonkey is right. Sorry, but there's really nothing we can do. I gave it a shot but theres a lot wrong with that line and there is just no way of telling what it was intended to do.

    Whoever wrote this code has evidently tried to make it as concise as possible. This line could have been made very simple by being turned into like 10 lines and using a couple of if statements instead of using the ? operator, which makes it extremely difficult to understand. Even then though, we still wouldn't be able to fix it. Having not written the code i have absoloutely no idea how it works.
    -luke.slashmedia.co.uk(my site)
    (^.^)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center