简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM