XML Image Gallery with World Style
| Category | : Flash | Views | : 39716 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : xml-image-gallery-with-world-style.zip | ||
| Result | : See the result | ||||
var bmd:BitmapData = new BitmapData(500,375);
In this line we create a Bitmap to store the loaded image; I used the size "500x375" because that's how I draw my MC if you used a different size don't forget to change these values.
var xscale = 500/target._width
var yscale = 375/target._height
The image we are loading is probably bigger than the size we want so we need to scale it, but we need to know the scale value.We just divide the width and height we want by the width and height of the target (the image). The result will be used in the Matrix object so that 1 equals 100%, 0.5 equals 50%, etc.
var MT = new Matrix();
Create a new Matrix object, which we will use to scale the image to the size that we want.
MT.scale(xscale, yscale)
Set the matrix to scale the image by the values we got a few lines above.
bmd.draw(target, MT);
Draw the image that was loaded into target to the bitmap using the matrix object to scale it.
for(i = 0; i < 5; i++)
{
duplicateMovieClip(frame, "frame" + _root.frames, _root.getNextHighestDepth())
mc = _root["frame" + _root.frames]
Dupliacate the MC that is on the stage and set the variable "mc" as a reference to it so we can just write "mc" o call it.
mc.createEmptyMovieClip("pic", 10);
mc.pic._x = -250
mc.pic._y = -187.5
Create a new MC inside the "frame" and set its position. This is where the image is attached so its also where the image starts and depends on how you draw your MC.
mc.pic.attachBitmap(bmd, 1);
Attach the bitmao with the image to the "pic" MC we just created.
mc._xscale = mc._yscale = Math.random() * 5 + 2
Get a random scale between 2% and 7%.
mc._rotation = Math.random() * 360;
mc._alpha = mc._xscale * 20
Get a random rotation from 0º to 360º and an alpha value that is proportional with the scale.
mc._x = Math.random() * Stage.width;
mc._y = Math.random() * Stage.height;
Set the position of the MC to anywhere on the screen.
mc.onEnterFrame = function()
{
This is the code for every MC that is created.
difX = _xmouse - Stage.width/2
difY = _ymouse - Stage.height/2
Get the difference between the current position of the mouse and the center of the stage so that we can know to where we should move the MCs.
![]() |
![]() |
![]() |
![]() |
![]() |







