;

PDA

Click to See Complete Forum and Search --> : Can't change _alpha


marinebro0306
08-23-2005, 12:34 AM
There's probably some stupid mistake I'm doing here, but I cant get this to work.
I have a circle thingy called "shape". I also have a button that says "More Transparent," which is supposed to make the circle's transparency to 30%. The button's script is:
on(release) {
setProperty("shape", _alpha, "30");
}

But, it does nothing when clicked...

w.brants
08-23-2005, 01:22 AM
setProperty will be correctly implemented in the KM 5.0.2 release but you can directly assign a property instead.

setProperty("shape", _alpha, "30");

becomes

shape._alpha = 30;

marinebro0306
08-23-2005, 01:34 AM
setProperty will be correctly implemented in the KM 5.0.2 release but you can directly assign a property instead.

setProperty("shape", _alpha, "30");

becomes

shape._alpha = 30;

i tried that, and still nothing happens.

PS when is 5.0.2 coming out?

Bob Hartzell
08-23-2005, 07:34 AM
Is shape a movie clip? It needs to be a movie clip.

5.0.2 will be released today and tomorrow if all goes well.

marinebro0306
08-23-2005, 11:49 AM
both the circle and box you click are movie clips. does the code need to be put in the button MC, or the button'a actual actions?

w.brants
08-23-2005, 11:55 AM
both the circle and box you click are movie clips

I checked the attachment from your first post in this thread but the circle you call shape definitely isn't a movieclip. If you convert it to a movieclip and use the direct assignment I posted before it works fine.

marinebro0306
08-23-2005, 12:09 PM
I know it isnt a MC, but I changed that after i read Bob's and it still didnt work.

marinebro0306
08-23-2005, 01:21 PM
still doesnt work (check the updated file)

w.brants
08-23-2005, 01:39 PM
This time you not only converted the shape to a movieclip but also the button.
The button is embedded inside mc1 and therefore takes that as its scope not able to directly see the shape movieclip anymore. When you embed the button like this inside mc1, you have to use

_root.shape._alpha = 30;

pherbrick
08-23-2005, 02:02 PM
Hi Jeff,

Starting from your original file:

1) In the button code, change the object to be made transparent to mc1, as in: mc1._alpha = 30;

2) On the Stage, you need to embed the red circle Shape in movieclip mc1. To do this,

2) A) Select Shape, either on the stage with the Toolbox select tool or in the Shapes list,

2) B) Next you need to place Shape in movieclip mc1. In the Toolbox (usually located to the left) select and click on the Convert Selected Shape(s) to Movieclip tool, or in the Shapes menu click on Convert to Movie Clip. The conversion tool in the Toolbox is initially hidden, you will need to press on the triangle by the Create Movieclip tool or click and hold on the Create Movieclip tool to open the tool drawer containing the conversion tool.

When a tool is used to create a visual element, KoolMoves gives them sequential titles. For example, movieclips are mc1, mc2, etc. Textfields are txt1, txt2, etc. Shapes are S1, S2, etc. Above sequence assumes there are no other movieclips on the stage created by the visual element tools.

You've now created a movieclip (mc1) and moved your red circle (Shape) into it. Shapes created at authortime can not be manipulated w/ ActionScript - you need to embed them in movieclips. I've attached my fix if you have any questions.

Re putting a button in a movieclip, as Wilbert has pointed out, you need to keep track of absolute or relative locations ("paths") once you start embedding / nesting elements. Paths are not tricky, but they are not intuitive either - find a tutorial / exercise that addresses paths before you start nesting elements. In my solution mc1 is on the _root level so a path is not necessary.

pherbrick
08-23-2005, 02:52 PM
Oops, don't want to confuse you. _root is not a level. I should have said "mc1 is on the _root timeline..."

Levels contain movies. _level0 contains the main movie. If a movie was loaded into _level1, that movie would display over the content of _level0, but the movie in _level0 has overall control.

_root is a timeline - the main timeline in a movie for a given level. Movieclips are also timelines, located either on _root or nested within "parent" movieclips. "_parent" is the next level up for a nested element, while the meaning of "this" can vary; it usually points to the current timeline / containing movieclip. For how it works w/ Event handlers, Event listeners, and buttons I recommend you check out the MX 2004 online language reference.

Wilbert has already given an example of accessing a "child" in an absolute path.

Each timeline has a content stack. The content stack contains visual elements within the timeline. Each element within a content stack has an assigned depth. An element's depth correlates with how the element is displayed on the stage; elements with higher depths are displayed over elements with lower depths. Depth positions range from -16384 to 1048575. Depths from 0 to 1048575 are reserved for dynamically generated content; depths from -16383 to -1 are reserved for author-time contents; -16384 is reserved for a runtime background.

I have not covered how an object's depth is changed dynamically, or a lot of other things. All the above (and most of the other things I haven't addressed) have been covered in other posts, and now you have the vocabulary to find them either on Flashkit or in the online language reference. I hope this saves you a lot of frustration :).