background preloader

Actionscript code

Facebook Twitter

Actionscript Snippets. Rotating a Sprite around any point - Everyday 3D. Click once to activate, then click anywhere to move the registration point. Use SPACE to change the object or any other key to change the direction of the rotation. This time I want to share a simple solution to a relatively simple, but annoying problem. The problem: the Sprite.rotation property rotates the object always around the registration point of the Sprite. If you need to rotate it around some other point, it's not automatic. One way to achieve this is to move the content inside the Sprite in order to change its position in relation to the registration point. It works, but it's not elegant and not very handy if the Sprite has many children - you would need to move all of them. Another way is to wrap your Sprite into another Sprite and rotate the parent.

Solution: the Rotator class can be used as a replacement for the default Sprite.rotation property. Source. Example. Use it like this: Actionscript: Flashtica // Free Open Source Actionscript and Flash code files and resources directory. AnimatedBitmap - hexagon. Points around circumference. Explore. Preloader. The magic of creating a preloader in ActionScript 3 lies in the LoaderInfo class. Every instantiated DisplayObject instance (all objects that appear on the stage, plus the stage itself) have a loaderInfo property that returns a LoaderInfo instance that contains information about the loading progress of that particular display object.

Creating a preloader for the whole application is a matter of monitoring these LoaderInfo instances. Method 1: Monitor Stage LoaderInfo instance Under this method the loading progress is monitored via the LoaderInfo instance associated with the stage. Since all assets that will appear in the application need to be attached to the stage, the stage’s LoaderInfo instance will reflect the loading of all these assets. Graphics Save the file. Code Go to File → New… and select ActionScript File.Paste the following code and save the file as Preloader.as in the same directory as the .fla file saved earlier.

Method 2: Monitor content SWF LoaderInfo instance. Deep linking. Snippets.