A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Object Trail Problem

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    9

    Object Trail Problem

    Hello,

    I have a problem with a trail effect I have been working on.

    The effect works perfectly fine when I attach it to the _root._xmouse & _root._ymouse values.. but when I use the _x _ y of an object that is moving using actionscript i.e.

    onClipEvent(enterFrame){
    this._y += 2
    }

    the effect doesn't show up. But I want it to. T_T

    However, if I change this._y += 2 to use the mouse _y value i.e. this._y = _root._ymouse, it reappears!!


    The script for the trail used to be Actionscript 1, but I since got it to work using Actionscript 2... ish.
    It was working perfectly on the object in AS1, but in AS2 it doesn't show up and I have the occasional break in the line it creates.

    Any ideas would be great thanks!
    Last edited by idc2120; 07-08-2010 at 07:02 PM. Reason: Forgot info

  2. #2
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    can you post more of your code?
    Z¡µµ¥ D££

    Soup In A Box

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    9
    Lol I totally forgot about this post.

    I managed to solve my initial problem - it was because I was setting the scale of the trail to 0 when at least one axis remained constant - I.e. if the object was only moving down the trail wouldn't show up.

    However, I've stumbled across a new problem.

    Originally this script occured over 3 frames on the root timeline, but ideally I wanted it to be contained within one frame or in a class. When I came to do this however I've been getting a whole host of compiler errors - such as
    "Type Mismatch" and the infinite While Loop of doom.

    Here's is my class:

    class Trail extends MovieClip {
    var myOwner, n1, taillen, x0, y0, x1, y1, i, StepCounter, Target;
    function onLoad() {
    myOwner = _root.clipToRemove;
    n1 = 1;
    taillen = 15;

    }
    function onEnterFrame() {
    this._x = myOwner._x;
    this._y = myOwner._y;
    x0 = this._x;
    y0 = this._y;
    duplicateMovieClip("line","/line"+n1,n1);
    Target = _root["/line"+n1];
    Target._x = x1;
    Target._y = y1;
    Target._xscale = (x0-x1);
    if (Target._xscale == 0) {
    Target._xscale = 1;
    }
    Target._yscale = (y0-y1);
    if (Target._yscale == 0) {
    Target._yscale = 1;
    }
    x1 = x0;
    y1 = y0;
    n1 = n1+1;
    if (n1>taillen) {
    n1 = 1;
    }
    if (this.StepCounter) {
    this.StepCounter--;
    } else {
    // do updates
    i = 1;
    while (i<=taillen) {
    _root["line"+i]._x = _root["line"+i]._x+0;
    _root["line"+i]._y = _root["line"+i]._y-0;
    i = i+1;
    }
    this.StepCounter = 10;

    }
    }
    }

    It's currently gets a "Type Mismatch" error.

    If I mess around with the duplicateMovieClip() function... for instance replace it with something like _root.attachMovie() which I would normally use it manages to get to the While Loop and then causes a "Do you want to abort ...etc"

    Any ideas would be great, thanks!

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