Search code examples
actionscript-3prezi

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.


Solution

  • 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.