A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS3] Actionscript Help Please!

  1. #1
    Junior Member
    Join Date
    Feb 2008

    [CS3] Actionscript Help 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 trying to float an object called sight1. I want the sight1 object to independently move in any direction, and also its scale to change depending on how close it is to an object called sight. This would give the appearance of the object floating in a 3d space. Could anyone give me some sample code on how to do this. Thank you.

  2. #2
    Junior Member
    Join Date
    Feb 2008
    Forget about that previous problem, I got some help and did this to create that affect. How would I make it so that the further it sight1 is away from sight, it will scale smaller, rather than larger?

    //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

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