be well
be well

Reputation: 335

Set min and max width of Rectangle

How can I set a range in AS3 for value of (for example) width of my screen? What I mean is I have this piece of code:

var myBounds:Rectangle=this.getBounds(stage);
if ((myBounds.width>650)&&(visibleArea.intersects(myBounds)))
{

  if(this.currentFrame==1)
     this.play();
}
else
{
    this.gotoAndStop(1);
}
return;

and my movie starts only if it's width more than 650 px. What I don't know is how to set a range of values, something like this: 250<.width<650, so my movie will start only if it's width between this numbers.

Upvotes: 1

Views: 287

Answers (1)

Atriace
Atriace

Reputation: 2558

if (stage.loaderInfo.width < 650 && stage.loaderInfo.width > 250) {
    play();
} else {
    gotoAndStop(1);
}

You'll have to call the function at some sort of interval, either by event or by enterframe.

Upvotes: 1

Related Questions