resizing and loading in a new window actionscript help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tom1201
    New Member
    • Sep 2007
    • 1

    resizing and loading in a new window actionscript help!

    Hey, I'm fairly new to action scripting...and require a little bit of help to get going!

    I'm creating a website and have found two cool features that i would like to use.

    Firstly i would love to know how to create a pop-up window so the website can fill the whole screen....

    and secondly how to change the size of a simple box when a button is pressed with easing...obviou sly in action script!

    to illustrate what i'm talking about the site www.temperleylo ndon.com does exactly these two things!!

    I would so appriciate any tips hints or help!!

    Thanks Tom
  • xNephilimx
    Recognized Expert New Member
    • Jun 2007
    • 213

    #2
    Hi, tom1201! Welcome to TSDN!
    The first question is a javascript question. I can answer taht, but it would be proper to post that question on the JavaScript forum.

    Anyway if you know a little of javascript, it's really simple, you need to use the window.open method.
    You can get the maximum width and height of the screen from screen.availWid th and screen.availHei ght. Each will return the width and height respectively of the users' screen.

    The second one it's really easy too.
    The first thing you need to understand is the math operation behind an eased animation. That is:

    let's say you have an object A, and two points in the space, points B and C, you need to move A from B to C. So the position B will be initially the initial position of the object A, let's say its the current _x and _y properties of A. the the point C is the final x and y position.
    so, you need to calclulate the distance between the two points.
    Then multiply that distance by a low number, less that one, an ideal number is 0.2. I got that number from experimentation , depends also in the frame rate of your movie, I use almost always 0.2 or 0.3 easing value in a 30fps movie.
    Because the point B will always be the current A position, that will cause the distance multimplied by the easing to throw a smaller number each time, and that will cause the visual effect of easing.
    Now that the math logic is explained let's pass this to a more tangible situation. Let's make a reusable function that will return the eased distance.
    The function will recieve to parameters, the initial value, and the final value.
    Why did I call it value and not position? Because you are not limited to only ease the position of an object, you can easedly animate any object's properties, like transparency (alpha), rotation, color, anything you can come up with.

    [CODE=actionscri pt]
    function easeMe(initVal, endVal):Number {
    var easing:Number = 0.2;
    return (endVal - initVal) / easing;
    }
    [/CODE]

    As you can see the function is pretty easy, first gets the distance between two unidimensional values, and then divides it by the easing value, returning the next objects property value.

    If you want to use it so resize an object you can do it like this:

    [CODE=actionscri pt]
    someButton.onRe lease = function() {
    resizeThis(theM ovieClip,300,40 0);
    //I'm changing the movieclip's width and height to 300 and 400 respectively
    }
    function resizeThis(objT oResize,targetW idth,targetHeig ht):Void {
    objToResize.onE nterFrame = function() {
    this._width += easeMe(this._wi dth, targetWidth);
    this._height += easeMe(this._he ight , targetHeight);
    }
    }
    [/CODE]

    You see, is really easy to do the easing XD
    Now you can adapt this new knowdlege to anything you need to do.

    Best regards,
    The_Nephilim

    Originally posted by tom1201
    Hey, I'm fairly new to action scripting...and require a little bit of help to get going!

    I'm creating a website and have found two cool features that i would like to use.

    Firstly i would love to know how to create a pop-up window so the website can fill the whole screen....

    and secondly how to change the size of a simple box when a button is pressed with easing...obviou sly in action script!

    to illustrate what i'm talking about the site www.temperleylo ndon.com does exactly these two things!!

    I would so appriciate any tips hints or help!!

    Thanks Tom

    Comment

    Working...