swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Re: [Swftools-common] Actionscript acting stupid...


From: John Sullivan
Subject: Fwd: Re: [Swftools-common] Actionscript acting stupid...
Date: Fri, 28 Jan 2011 09:49:11 +0000

[oops, rejected from list due to wrong From address, resending...]

On Thursday, January 27, 2011, 5:07:32 AM, Chris Pugh wrote:
>>John Sullivan <address@hidden> wrote:
>> [.put on an .swf creates a new movieclip]
>> .put on an image doesn't, which means the three cherries are
>> then not independently placeable.

> If that were strictly true, then surely something like this:
>[snip code]
> shouldn't work?  But it does.

But it doesn't ;-)

To clearly see why, you need to extend the code slightly:

image.png is a random 16x16 bitmap.

image.sc:

  .flash filename="image.swf" version=6 bbox=16x16 fps=24
  .png image "image.png"
  .put image x=0 y=0
  .end

example.sc:

  .flash filename="example.swf" bbox=300x200 version=8 fps=60 compress
  .png png "image.png"
  .swf swfpng "image.swf"
  .sprite sprpng
    .put png x=0 y=0
  .end

  .action:
    obs = new Array(png1, png2, swfpng1, swfpng2, sprpng1, sprpng2);
    i = 0;
    interval = setInterval(moveit, 250);
    function moveit() {
      xpoint = Math.random() * 100;
      obs[i%6]._x = xpoint;
      i++;
    }
  .end
  
  .put png1=png x=0 y=20 scale=15%
  .put png2=png x=0 y=40 scale=15%
  .put swfpng1=swfpng x=0 y=60 scale=15% 
  .put swfpng2=swfpng x=0 y=80 scale=15% 
  .put sprpng1=sprpng x=0 y=100 scale=15% 
  .put sprpng2=sprpng x=0 y=120 scale=15% 
  .end

What you see is that for the first two iterations the entire group of
six images move, then for the next four iterations the corresponding
image moves on its own. As we loop round, you notice that the first
two images are always moved somewhere between 0 and 100 pixels from
the left edge, and the last four images are always placed somewhere
between *that point* and 100 pixels to its right.

Some directives, such as .flash, .swf and .sprite, create their own
movieclip object - they cannot exist any other way. Some, such as the
image types and (as I recall) other primitive graphical elements do
not have a movieclip of their own and are placed within the closest
enclosing movieclip where they are invoked. They still create their
own name in the relevant namespace though - but that name refers not
to them but their parent movieclip.

So for the .swf and .sprite images, ._x refers to the x coordinate of
their own movieclip, which can be placed independently within *its*
parent container.

The parent container in this case being the movieclip created by the
.flash directive, also known as _root or this at global scope. This
movieclip itself lives within a parent container, the Stage object
representing the entire browser window. The root movieclip has
it's own _x property and can be moved around on the stage to move
the entire presentation. To make this visible, insert this line after
the obs= line: this.opaqueBackground = 0x7fffff;

When you reference png1 or png2, they are aliases to the _root
movieclip, so only a single _x property exists - this is what I mean
by not being able to move them independently. Not only that but moving
a movieclip has the effect of moving all child movieclips relative to
it, so all 6 objects move if you attempt to move the first 2, but the
last four can be freely moved without repositioning any of the others
(as long as they stay within the bounds of their parent, which has
already been moved by the attempt to move the .pngs).

John
-- 
Dead stars still burn




reply via email to

[Prev in Thread] Current Thread [Next in Thread]