all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

"Bring to front" in actionscript


Re: "Bring to front" in actionscript Bruce McMurry
2/3/2006 2:23:30 PM
flash actionscript: build each tab as a separate clip then use swapDepths...

[quoted text, click to view]
Re: "Bring to front" in actionscript David Stiller
2/3/2006 4:28:57 PM
[quoted text, click to view]

This is on the right track, but accurately speaking, swapDepths() isn't
a function. It is a method of the MovieClip class, which is fortunate in
that it's easy to spot in the "MovieClip class" entry of the ActionScript
Language Reference.

Everything in ActionScript is an object, and objects are defined by
their namesake classes. Everything about movie clips -- their methods (the
things they can do), properties (characteristics they have), and events
(things they can react to) -- are conveniently organized under the MovieClip
class. Same goes for button symbols (the Button class), text fields (the
TextField class), and so on.

No more guessing, hunting, or pecking!


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

"Bring to front" in actionscript BeniRose
2/3/2006 7:59:14 PM
I'm trying to build my own tab menu as sublinks for my navigation, but I'm
having problems finding the action script to bring a button to the front of a
movie clip (basically I need to know the code to do exactly what Modify >>
Arrange >> Bring to Front does). I tried finding this tab_menu template
everyone seemed to be talking about but I had no luck, so any help is
appreciated. Thanks!
Re: "Bring to front" in actionscript Hudey
2/3/2006 8:41:04 PM
look into the SwapDepths function... that's what you use to arrange movie clip orders on the fly within actionscript.

HTH

Re: "Bring to front" in actionscript BeniRose
2/4/2006 12:00:00 AM
Well the swapDepths thing worked great, but i wish there were a StackDepths or
something so instead of swapping, it pushed all the levels below it back a
level. Oh well, it works well enough, but now I can't get the brightness change
to work. I did a bunch of search, cause apparently Macromedia scored another
big hit and decided to completely leave brightness out of actionscripting (I'm
hoping they fixed this in flash 8?). So after all my searching, i'm still
confussed as hell. I understand you have to use a color object and use setRGB
and fiddle with this stuff to change the "brightness". I tried this, but all I
got was a nearly black movie clip, and the entire movie clip turned the colour
whereas changing brightness in the properties panel leaves my multicoloured
movieclips in tact. In one post I read this:

"That's correct there is no direct access property. Instead you have to build
a transformation matrix. The idea is to proportionately lock the rgb values in
series so as to appear to gain or loose brightness without changing hue or
saturation."

Seeing as I have no idea how the heck to build a "transformation matrix" or
what it even is for that matter I need some help. Could someone please just
explain in plain english, assuming I know nothing about the correlation between
a hex number and it's corresponding colour (because i don't!) how I can change
the brightness of my movie clip as if I was changing it in the properties panel.
Re: "Bring to front" in actionscript David Stiller
2/6/2006 8:52:02 AM
BeniRose,

[quoted text, click to view]

You realize you don't have to actually swap two movie clips, right? You
can simply specify a new depth for the desired movie clip by providing a
number.

[quoted text, click to view]

I'd say Flash is a kick-@$$ hit!

[quoted text, click to view]

A) Brightness isn't "left out" of ActionScript. This is a bit like
saying physics and gravity simulation were "left out" of ActionScript. You
have to know the concepts involved, then apply the necessary math. B) How
do you "fix" something that isn't broken? You can add support for
something, sure.

[quoted text, click to view]

That's putting it vaguely, but yes. Fiddling with it can get you a
brightness change. ;)

[quoted text, click to view]

Let's see your code.

[quoted text, click to view]

When I was dealing with color transformations -- may have been a year
ago, or more -- I ran up against some of the same frustrations you're
seeing. When I didn't know something, I posted about it (which you're
doing, I know) and I also researched it. Anything worth having is worth
working for, even if that means months of research. I know what a
transformation matrix, but I don't think it applies here, to be honest.
Maybe that's a misunderstanding on my part, but here's the best tutorial
I've seen on matrixes. Granted, this article is for Flash 8 and it involves
resizing, skewing, and the like, rather than color, but it may at least give
you an idea what a matrix is.

http://www.senocular.com/flash/tutorials/transformmatrix/

Again, a matrix need not necessarily refer to size, skew, and position.
That said, I don't see, frankly, how to apply the notion of a transformation
matrix to the Color class in ActionScript. (Just because someone posted it
here, doesn't make it true. Caveat emptor.)

[quoted text, click to view]

Now we're talking! Grouching and complaining doesn't really do much,
but straightforward question-and-answer gets us somewhere. Let me explain
how a hex number corresponds to the more familiar sense of color.

The RGB colorspace is a way of describing a particular color in terms of
its three component parts: red, green, and blue. Pure red is the full
presence of the Red component and the absence of the others (255, 0, 0);
pure green follows suit (0, 255, 0); and so does blue (0, 0, 255). Pure
yellow is a mixture of pure green and pure blue (0, 255, 255), while
orange -- one particular orange -- is a particular mix of all three (255,
137, 50). So far, so good, I presume. We're all familiar with the color
picker in Photoshop, or the like, and this should make sense because it
roughly corresponds to the way me mixed paints in grade school.

So what about so-called hex? Well, "hex" is short for hexadecimal,
which is just another way of saying "base 16". Our everyday counting is
decimal, which means it is based on powers of ten. We have a tens column, a
hundreds column, a thousands column, and so on. For reasons beyond the
scope of this reply, computer calculation is often recorded not in decimal,
and in hexa (six) decimal (ten), which means it is based on powers of 16.

There is no tens column in hexadecimal. The tens column appears in
"normal" decimal notation when the 9 becomes a 10. Suddenly the ones column
starts over again at zero and the tens column advances to 1. That 1 and 0
together ... 10 ... make ten. If you want to describe the number fifteen,
that's a 1 in the tens column and a 5 in the ones column. Twenty is
described by a 2 in the tens column and 0 in the ones column.

You're still with me, right?

In hexadecimal, we have a ones column, a sixteens column, a two hundred
fifty-sixes column, and so on. To describe the number five, you simply put
a 5 in the ones column. To describe a ten ... well, you can't put a 1 in
the tens column, because there is no tens column: it's a sixteens column,
remember. Ten isn't high enough to go to the sixteens column yet, so it
still belongs in the ones column. And yet -- ten is a two-digit number!
What do we do? Well, the concept of ten isn't necessarily two-digit. It's
only two-digit in the decimal world. In hexadecimal, ten is a one-digit
number. By convention, we start with the letter A after the number 9 in the
hexadecimal ones column. So ten is simply A. Eleven is B, Twelve is C, and
so on. By sixteen, we finally roll around to the sixteens column, which
goes up by 1 while the ones column starts again at 0. Therefore, in
hexadecimal notation, the number sixteen looks like 10. Seventeen looks
like 11.

Remember, think of it in terms of columns. 11 is simply 1 in the
sixteens column and 1 in the ones column, which in decimal language is like
saying 16 + 1.

That said, the hex values you see in HTML and other places are simply
RGB triplets expressed in hexadecimal notation. r:0, g:0, b:0 is expressed
as 00, 00, 00. r:255, g:17, b:5 is expressed as FF, 11, 05. Get it? After
a while, you can actually start "reading" hex values by sight. Just break
up a given color, FF8932, into its three components, r:FF, g:89, b:32, and
you get ... hey, that's our orange from earlier.

Now, how to change brightness? Well, there are several common
colorspaces. Colorspaces are just a way to describe color. RGB should be
very familiar, but there's another, HSV (Hue, Saturation, Value [aka
brightness]) that describes color in a different manner.

Forget about transformation matrixes. What you need to do is convert
your RGB color into ts HSV equivalent first. Once accomplished, you can
adjust the V component (brightness), then convert back to RGB.

How is this done?

Wikipedia shows how, but it looks like pretty scary math.
http://en.wikipedia.org/wiki/HSV_color_space Your best bet is to fire up
Google -- now that you have some good new search terms -- and look up "hsv
Re: "Bring to front" in actionscript David Stiller
2/6/2006 9:14:43 AM
[quoted text, click to view]

In fact, the search "ActionScript HSV to RGB" quickly brought me this:

http://flashexperiments.insh-allah.com/AS-downloads.html


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

AddThis Social Bookmark Button