A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Why would this work in F6, AS1 but not F7, AS2?

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    54

    Why would this work in F6, AS1 but not F7, AS2?

    I have the following code which "scoots" a MC to a location with elasticity:
    Code:
    slideY = function(mc, dest) {
    	mc.onEnterFrame = function() {
    		this._Y = slideMc(this, "_Y", dest, .4, .6);
    		if (Math.round(this._Y) == [dest]) {
    			trace("slideY done");
    			this.onEnterFrame = undefined;
    		}
    	};
    }
    slideMc = function(mc, property, destination, inertia, friction) {
    	yspeed = ((puppy._y-destination)*inertia)+(yspeed*friction);
    	mc[property] -= yspeed;
    	return (mc[property]);
    }
    However this will work fine if I export the swf as Flash 6, ActionScript 1.0, but it will not work as Flash 7, ActionScript 2.0.

    Why is this?

  2. #2
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    This line :
    Code:
    yspeed = ((puppy._y-destination)*inertia)+(yspeed*friction);
    yspeed traced NAN

    You init the variable yspeed there but also use it instantly, that messes it up i guess.

  3. #3
    Member
    Join Date
    Jan 2001
    Posts
    54
    You're exactly right. Initializing the yspeed vairaible beforehand solves the problem in v7, AS2.

    Thanks so much.

  4. #4
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    no problem

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