Because of the constant attack by the wiki spam bots, accounts that are created and not used will be deleted. If you are a legitimate user, and your IP was blocked, please contact any active administrator - look at Special:RecentChanges and see who is busy fighting spam.

LoadMovie

From SWFTools
Jump to: navigation, search

loadMovie is the function that loads a movie. A movie may be anything, like a movie itself or an image.

To see how it works, let's take the example in the SWFC Manual that takes a fixed image, an then does a lot of crazy things with it: resize, change colors, move, and so on.

The original example is this:

	

.flash filename="cxform.swf" version=5 fps=25
    
    .jpeg s1 "photo.jpeg" quality=80%

    .put s1 x=50 y=50 scalex=110 scaley=110
    .frame 50
    .change s1 x=0 y=0 scalex=210 scaley=210 red=-1+255 green=-1+255 blue=-1+255 #invert
    .frame 100
    .change s1 x=100 y=50 scalex=110 scaley=110 red=0 green=+0 blue=+0 #remove red
    .frame 150
    .change s1 x=0 y=0 scalex=210 scaley=210 red=+0 green=2 blue=-1+255 #amplify green, invert blue
    .frame 200
    .change s1 x=50 y=100 scalex=110 scaley=110 red=2-128 green=-2+255 blue=+0.7+40 #alien glow
    .frame 250
    .change s1 x=0 y=0 scalex=210 scaley=210 red=8-1024 green=8-1024 blue=8-1024 #palette reduce
    .frame 300
    .change s1 x=0 y=0 scalex=210 scaley=210 red=+0 green=+0 blue=+0 #back to normal
    .frame 350
    .change s1 x=105 y=105 scalex=0 scaley=0 luminance=0 #fadeout
.end

Now, let's change it a little bit. Instead of using a fixed image, let's dynamically load a user-given image:

.flash bbox=600x600 version=5 fps=25

    .sprite s1
    .end
    
.action:
  _root.createEmptyMovieClip("s1", 2);
  _root.s1.loadMovie(filename);
.end

    .put s1 x=50 y=50 scalex=110 scaley=110
    .frame 50
    .move s1 x=0 y=0
    .change s1 scalex=210 scaley=210 red=-1+255 green=-1+255 blue=-1+255 #invert
    .frame 100
    .move s1 x=100 y=50
    .change s1 scalex=110 scaley=110 red=0 green=+0 blue=+0 #remove red
    .frame 150
    .move s1 x=0 y=0
    .change s1 scalex=210 scaley=210 red=+0 green=2 blue=-1+255 #amplify green, invert blue
    .frame 200
    .move s1 x=50 y=100
    .change s1 scalex=110 scaley=110 red=2-128 green=-2+255 blue=+0.7+40 #alien glow
    .frame 250
    .move s1 x=0 y=0
    .change s1 scalex=210 scaley=210 red=8-1024 green=8-1024 blue=8-1024 #palette reduce
    .frame 300
    .move s1 x=0 y=0
    .change s1 scalex=210 scaley=210 red=+0 green=+0 blue=+0 #back to normal
    .frame 350
    .move s1 x=105 y=105
    .change s1 scalex=0 scaley=0 luminance=0 #fadeout
.end

What does this code do?

First, it declares s1 as a sprite, but the sprite is empty.

Then, with _root.createEmptyMovieClip("s1", 2), we create the sprite, but it's still empty.

Finally, with _root.s1.loadImage(filename), we load filename to the sprite s1.

Now, an interesting question is, where is filename defined?

The answer is that it's not, so it must be defined by the invocation of the script.

If the .swf is called by gnash, this is done with:

gnash -P "FlashVars=filename=file:://home/cthulhu/images/evil_overlord.jpg" myflash.swf

There are other ways to pass parameters, to see two applications using mediawiki, consult the examples in the portuguese language humor wikis:

The only bug is that the image is not resized.