Action Script Fading in Flash MX

  • rich9a9
  • Born
  • Born
  • No Avatar
  • Joined: Mar 30, 2005
  • Posts: 3
  • Status: Offline

Post March 30th, 2005, 12:43 pm

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
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 30th, 2005, 12:43 pm

  • Tchuki
  • Mastermind
  • Mastermind
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post March 30th, 2005, 1:10 pm

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
  • Joined: Sep 17, 2004
  • Posts: 260
  • Loc: Miami Beach, FL, USA
  • Status: Offline

Post March 30th, 2005, 1:13 pm

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. };
Cordially,
Abel K - Miami Beach, FL, USA
http://www.worldkit.com
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Joined: Sep 17, 2004
  • Posts: 260
  • Loc: Miami Beach, FL, USA
  • Status: Offline

Post March 30th, 2005, 1:19 pm

Here is the sample file (fla file included):

http://www.worldkit.com/wknforum/forums/thread-view.asp?tid=573
Cordially,
Abel K - Miami Beach, FL, USA
http://www.worldkit.com
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post March 30th, 2005, 3:48 pm

Strong with this one, the sudo is.
  • rich9a9
  • Born
  • Born
  • No Avatar
  • Joined: Mar 30, 2005
  • Posts: 3
  • Status: Offline

Post March 31st, 2005, 1:36 am

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
  • No Avatar
  • Joined: Sep 30, 2004
  • Posts: 1774
  • Loc: Edinburgh
  • Status: Offline

Post March 31st, 2005, 3:51 am

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

Post March 31st, 2005, 10:16 am

Sure...

But I hardly ever use buttons anymore, since the advent of AS2 and MX 2004...
Cordially,
Abel K - Miami Beach, FL, USA
http://www.worldkit.com

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 53 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
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.