First time here? First time here? Newsletter Signup Newsletter
651326 Members and growing! | Flash Jobs
Search tutorials
Author: Joachim Schnier | Website: http://www.flashscript.biz

Creating the Fading Events

All our functions are static. The following error message is given if by mistake we call a function static:

Error! Instance variables cannot be accessed in static functions.

What we have done wrong in such case is we have referred to an instance variable outside of the function, for example a variable we have defined right at the beginning of the class and which we now refer to. If we have to do that then our function is not static any more. In actionscript the Math functions are for example static. Static functions form a unit for themselves. Anyways, coming back to the script in our first function we create a movieclip and position it using x and y coordinates. If we load a swf instead of jpg we want to make sure that the root of the swf is its own root and not the parents' root. So we add _lockroot here, which is a very handy property introduced with Flash 7.

The second function is the fading function with mainPic as argument, which will be the path to our picture or movie to be loaded. Now here comes the point why we have created two movieclips. We created those, whereby the second one resides within the first one. The reason for this is that now we can have two independent events associated with each of the movieclips, which we can manipulate separately. If we had only one movieclip and we create the same event in the two onEnterFrame functions we could not continue after deleting the function once. The rest of the fader function are just typical alpha tweens and I do not go into further details. One more explanation is, however, necessary. We have to create a variable fade, to lead the compiler into one direction not to repeat the same events over and over again, which is done by changing the value of fade once a task is completed. Now go to the next page for more.

» Level Intermediate

Added: 2004-09-21
Rating: 7 Votes: 6
(10 being the highest)
» Author
The author is a cancer researcher and Flash developer.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: doc_chin7
» Description:

The flash's horizontal road drive was done in CS4 and was upgraded to CS6. The car responds to right/ left key and flash will auto-generate the movement of roads from left-right or right-left based on random number. Have fun driving in this virtual environment and avoid other cars... :) If you are creative, a road driving game can be created from it.

Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.