-
1. Re: How do I change a global variable from inside a function.
kglad Aug 21, 2013 1:48 PM (in response to SeanPercy42)you're making bookPosition local to slideServicesIn (and defining a 2nd variable named bookPosition) when you prefix it with var. use:
var bookPosition:String = "up";
var currentPage:String;
function slideServicesIn ():void{
if (bookPosition == "up"){
book.gotoAndStop('webDesignPage');
TweenLite.to(book, 3, { y:280 } );
bookPosition = "down";
currentPage = "book.servicesPage";
}
if (bookPosition == "down" && currentPage != "book.servicesPage"){
TweenLite.to(book.servicesPage, 1, { alpha:1, ease:Quad.easeIn, delay: .2 } );
}
}
-
2. Re: How do I change a global variable from inside a function.
SeanPercy42 Aug 21, 2013 2:42 PM (in response to kglad)Alright, that's what I originally had but it wasn't tweening my page in. I changed it back to the way you recommended but it's still not crossfading between pages. Any idea why not?
When the slideServicesIn function runs it set's the bookPosition variable to "down" and the currentPage variable to "book.servicesPage", so since it's already down I should be able to click on another button (slidePortfolioIn for example) and it should crossfade to the portfolio page since the book is down & the currentPage isn't "book.portfolioPage". The functions for each page are identical except for the names of the pages. You can look at the if statement in the slideServicesIn function and replace the book.servicesPage variables with book.portfolioPage to get an idea of what the code looks like for the other functions.
-
3. Re: How do I change a global variable from inside a function.
kglad Aug 21, 2013 7:46 PM (in response to SeanPercy42)that if-statement is only going to execute when your page loads, not after slideServicesIn() executes.
you probably want to put those tween statements in a function that gets called after assigning your strings variables.
-
4. Re: How do I change a global variable from inside a function.
SeanPercy42 Aug 21, 2013 10:02 PM (in response to kglad)Nevermind, I got it working well enough for right now and once I learn more about variables and TweenLite I'll come back in and tweak the code. Thanks for all your help anyway.


