Action Script Fading in Flash MX

  • rich9a9
  • Born
  • Born
  • rich9a9
  • Posts: 3

Post 3+ Months Ago

I want the following functionality from a simple on screen button in flash mx:

upon clicking a button on screen i want it to make an object fade in.
i need it done using action scripting.

any help would be great thanks
rich9a9
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

Reference the button to your movie that you wish to fade in.

Create you button [ I assume you know how to do this ] and place the following code in the actions panel for it :

Code: [ Select ]
on(release) {
_root.myClip.gotAndPlay("in"); // We will get to this line later
}
  1. on(release) {
  2. _root.myClip.gotAndPlay("in"); // We will get to this line later
  3. }


Now, create yourself a simple shape [ just to practise with ] and convert it to a mc [ MovieClip ], give it the instance name myClip.

Double click the movie and in the timeline on frame 2 insert a new keyFrame, name this frame in. In the properties panel set the opacity of the clip to 0%. Create another keyFrame at about frame 31 and set the clips opacity to 100%. Right click between the keyFrames and select Create Motion Tween.

Go back to the main timeline and test your movie.

Thats a very simple version using tween, the same effect can be acheived using AS which is also more time effective [ less loading time ] and therefore puts less load on the viewers CPU.
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Here:

Code: [ Select ]
_root.myButton_btn.onRelease = function() {
    _root.myMovie_mc.onEnterFrame = function() {
        if (_root.myMovie_mc._alpha < 100) {
            _root.myMovie_mc._alpha++;
        } else {
            trace("done");
            delete _root.myMovie_mc.onEnterFrame;
        }
    };
};
  1. _root.myButton_btn.onRelease = function() {
  2.     _root.myMovie_mc.onEnterFrame = function() {
  3.         if (_root.myMovie_mc._alpha < 100) {
  4.             _root.myMovie_mc._alpha++;
  5.         } else {
  6.             trace("done");
  7.             delete _root.myMovie_mc.onEnterFrame;
  8.         }
  9.     };
  10. };
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Here is the sample file (fla file included):

http://www.worldkit.com/wknforum/forums/thread-view.asp?tid=573
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida
  • rich9a9
  • Born
  • Born
  • rich9a9
  • Posts: 3

Post 3+ Months Ago

is it possible to do exactly the same but instead of having a movie clip faded in but have a button fade in?
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

You can have your MC act like a button using the hitTest method and on(MouseAction) events.
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Sure...

But I hardly ever use buttons anymore, since the advent of AS2 and MX 2004...

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.