A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Can't change _alpha

  1. #1
    Always needs help marinebro0306's Avatar
    Join Date
    Jul 2005
    Location
    Philadelphia
    Posts
    166

    Can't change _alpha

    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...
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    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;

  3. #3
    Always needs help marinebro0306's Avatar
    Join Date
    Jul 2005
    Location
    Philadelphia
    Posts
    166
    Quote Originally Posted by w.brants
    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?

  4. #4
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    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.

  5. #5
    Always needs help marinebro0306's Avatar
    Join Date
    Jul 2005
    Location
    Philadelphia
    Posts
    166
    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?

  6. #6
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Quote Originally Posted by marinebro0306
    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.

  7. #7
    Always needs help marinebro0306's Avatar
    Join Date
    Jul 2005
    Location
    Philadelphia
    Posts
    166
    I know it isnt a MC, but I changed that after i read Bob's and it still didnt work.

  8. #8
    Always needs help marinebro0306's Avatar
    Join Date
    Jul 2005
    Location
    Philadelphia
    Posts
    166
    still doesnt work (check the updated file)
    Attached Files Attached Files

  9. #9
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    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;

  10. #10
    Senior Member pherbrick's Avatar
    Join Date
    Jul 2004
    Location
    Los Angeles
    Posts
    291
    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.
    Attached Files Attached Files

  11. #11
    Senior Member pherbrick's Avatar
    Join Date
    Jul 2004
    Location
    Los Angeles
    Posts
    291
    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 .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center