Search This Blog

Thursday 29 March 2012

MX.TRANSISTIONS

Today we experimented with a hidden libary MX.TRANSISTIONS
http://www.swfcabin.com/open/1333011928

We made the box resize depending on the screensize aswell as the nav bar sticking to the side of the box no matter what size it is.


here is the code that was used. blue highlights the instance names if you want to try it out yourself. Code highlighted in yellow are variables. Code Highlight in red is the for the nav. bar (combined buttons into a movie clip) make sure you use nav. if you want to target that movie clip other wise it wont target all the buttons at the same time.

Blue = Instance names

Yellow = Variables

Red = navigation bar code (remember to group the buttons on your nav bar into a movie clip.)


import mx.transitions.Tween;  // IMPORTANT
import mx.transitions.easing.*; // IMPORTANT
var oldh = 0;
var newh = 300;
var oldw = 0;
var neww = 300;
//-------------------------------Fullscreen website code- ---------------//
Stage.align = "TL";
Stage.scaleMode = "noScale"
sizeListener = new Object();
sizeListener.onResize = function() {
 fullsize();


};
Stage.addListener(sizeListener);
_global.fullsize = function(){


 box._x = Stage.width/2;
 box._y = Stage.height/2;
};
fullsize();
onEnterFrame = function (){


 nav._x = Stage.width/2 - box._width/2 - nav._width
 nav._y = Stage.height/2 - box._height/2


}


new Tween(box, "_height", Elastic.easeOut, oldh, newh, 2, true);
new Tween(box, "_width", Elastic.easeOut, oldw, neww, 2, true);
nav.btn1.onPress = function (){
 oldh=newh
 newh=100
 oldw=neww
 neww=100


 new Tween(box, "_height", Elastic.easeOut, oldh, newh, 2, true);
new Tween(box, "_width", Elastic.easeOut, oldw, neww, 2, true);
};
nav.btn2.onPress = function (){
 oldh=newh
 newh=300
 oldw=neww
 neww=300
 new Tween(box, "_height", Elastic.easeOut, oldh, newh, 2, true);
new Tween(box, "_width", Elastic.easeOut, oldw, neww, 2, true);




};


nav.btn3.onPress = function (){
 oldh=newh
 newh=500
 oldw=neww
 neww=500
 new Tween(box, "_height", Elastic.easeOut, oldh, newh, 2, true);
new Tween(box, "_width", Elastic.easeOut, oldw, neww, 2, true);
};

No comments:

Post a Comment