A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS3] Actionscript help with scaling please

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    7

    [CS3] Actionscript help with scaling please

    Hello, I need help floating an object in flash. I am using actionscript 2.0 because some of the other coding stuff I'm doing will only work in that.
    I am scaling an object called sight 1, in relationship to it's distance from the sight object. With some help I got this code to work for what I am doing, but I can't figure out how to make it scale smaller the further away it is, rather than larger, like it is now. Some of the code is moving the sight1 object around randomly. Thank you.

    //Sight 1
    sight1.goalX = Math.random()*(650 -sight1._width)
    sight1.goalY = Math.random()*(515 -sight1._height)
    sight1.xSpeed = 20
    sight1.ySpeed = 20
    sight1.onEnterFrame=function() {
    this.xDifference = this.goalX - this._x
    this._x += this.xDifference/this.xSpeed
    this.yDifference = this.goalY - this._y
    this._y += this.yDifference/this.ySpeed
    this.xDelta = this._x - sight._x
    this.yDelta = this._y - sight._y
    this.myDistance = Math.sqrt(Math.pow(this.xDelta,2)-Math.pow(this.yDelta,2))
    this._xscale += (this.myDistance - this._xscale)/this.ySpeed
    this._yscale += (this.myDistance - this._yscale)/this.ySpeed
    if (Math.abs(this.xDifference)<10){
    this.goalX = Math.random()*(650 -sight1._width)
    this.xSpeed = 5+Math.random()*20

    }
    if (Math.abs(this.yDifference)<10){
    this.goalY = Math.random()*(515-sight1._height)
    this.ySpeed = 5+Math.random()*20
    }
    }

  2. #2
    Junior Member
    Join Date
    Feb 2008
    Posts
    7
    Does anyone know of a possible solution for this? 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