First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Corky§urprise | Website:
' Copy and paste the following.

// This script is just for an idea, it isnt perfect and I'm aware of that! // Script "poorly" made by Corky§urprise - // // tree made by ChrisF // Shadow Concept by OSteel onClipEvent (load) { // When the tree movieclip loads onto the screen... (executed once) _root.attachMovie("shadow", "shadow", 5); // Attach the shadow movie clip, with a new name of shadow, and a depth of 5 (not really important) _root.shadow.swapDepths(this); // swaps the 'depth' of the shadow with this, sending the shadow behind the tree } onClipEvent (enterFrame) { // When the tree movieclip has loaded the screen... //(executed constantly, for example a frame rate of 12 would be executed 12 times a second) deltaX = _x-_parent.sun._x; // finds angle1 deltaY = _y-_parent.sun._y; // finds angle2 angleR = -Math.atan2(deltaX, deltaY); // Tricky math thing, converts the 2 angles into radians (angleR<<<) angle = Math.round(angleR*180/Math.PI); // Converts our radians into degrees. _root.shadow._x = _x; // places the shadow where this tree is on the x axis _root.shadow._y = _y; // places the shadow where this tree is on the y axis _root.shadow._rotation = angle+170; // Rotates the tree accordingly (Dont ask why it is 170, its a guess) if (_parent.sun._y>_y) { // if the sun is Under the tree _root.shadow._visible = false; // hide the shadow // In real life, if you managed to get on top of // the sun, you wouldnt see a shadow, right? } else { // If the sun ISNT under the tree... _root.shadow._visible = true; // Show the shadow! } }

The code is explained well enough, so i'll leave it as that. Test the movie (control + enter) and you should (hopefully) see a shadow around your character. It isnt perfect, but it's a start. That is basically it, in my next tutorial I will show you how to make something useful. Yes, something actually useful. Send all hate mail / questions / comments to corkysurprise (at)
» Level Basic

Added: 2006-03-01
Rating: 6 Votes: 6
(10 being the highest)
» Author
Yeah..umm..i'll get back to you on that...
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • 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: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
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: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.