Question

How do I activate a movieclip on rollover and rewind it on rollout?

Asked by: LLC0706

I have a movieclip called offer_mc, which I would like to be user activated on rollover and then for it to rewind on rollout, at any point in the timeline.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-03-30 at 03:30:55ID24276761
Tags

Flash Actionscript

Topic

Adobe Flash

Participating Experts
1
Points
500
Comments
13

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. on rollover swap images or movieclip
    Hi, this is a simple code I guess that I need to excute. I'll like to swap images or movieclip when the users rollover something in a flash movie. thanks,
  2. how to play a movieclip on rollover
    Hello, I have a header that I made it as a movieclip and I have a menu at the botton. The movie clip (header)..it has a short animation where the header moves to the left. I'll like to make this movieclip (header) play when I make a rollover on the menu...I'll like to hav...
  3. MovieClip buttons
    I'm using FlashMx2004 I have a movieClip that contains a menu of buttons. When rolled on this movieClip slides into view. When rolled off it slides back out of view. My problem is that the menu buttons contained within the movieClip don't function because of the main rollO...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: john_hollingsPosted on 2009-03-30 at 04:21:05ID: 24017714

I would use labels to control the movie clip.  For example:  In you movie clip timeline I would have a layer called actions and a layer below called labels.  On frame one of your MC I would have the following ActionScript in a key frame on the actions layer:  
stop();

In the labels layer I would create a blank key frame and label this as start.

In frame two of the labels layer again have a blank key frame and label this over.

Now I'm not sure if you are using ActionScript 2 or 3 and how you have structured your Movie Clip.  However I will continue with the assumption of ActionScript 3.

Create another layer labeled button and create an invisible button.  

Just draw a rectangle with fill but no border.  Select it and press F8 to create a symbol.  Select button from the list and give it a name.  Now double click the symbol you just created and you will see four frames on the timeline.  To create an invisible button click and drag the keyframe to the hit frame.

Return to the timeline of your movie clip and make sure the invisible button is on the button layer extended through to the end of your movie clip timeline.

Give the button an instance name activate_btn for example.  Now move to your main root timeline and if you have an ActionScript layer using the following code to get the activation to work on rollover.

Hope this is of help.

//add an event listener to the activate button to listen out for when someone rolls over it, and action the function activate_btn_ROLLOVER
movieclip_mc.activate_btn.addEventListener(MouseEvent.ROLL_OVER, activate_btn_ROLLOVER);
 
//add an event listener to the activate button to listen out for when someone rolls out, and action the function activate_btn_ROLLOUT
movieclip_mc.activate_btn.addEventListener(MouseEvent.ROLL_OUT, activate_btn_ROLLOUT);
 
//function to action when rollover is detected
function activate_btn_ROLLOVER(e:MouseEvent):void
{
   movieclip.gotoAndPlay("over");
}
 
//function to action when rollout is detected
function activate_btn_ROLLOUT(e:MouseEvent):void
{
   movieclip.gotoAndPlay("start");
}
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:

Select allOpen in new window

 

by: LLC0706Posted on 2009-03-30 at 05:00:47ID: 24017940

Hi
I forgot to state that I'm using actionScript 2. I've also given my movieclip an instance name of offer_mc.

 

by: john_hollingsPosted on 2009-03-30 at 05:11:10ID: 24018000

Ok.  To change this to actionscript 2 you only need to amend the code for the main root timeline.  You don't need the event listeners only the onRollOver and onRollOut functions as shown in the code snippet below.

offer_mc.activate_btn.onRollOver = function()
{
    offer_mc.gotoAndPlay("over");
}
 
offer_mc.activate_btn.onRollOut = function()
{
    offer_mc.gotoAndPlay("start");
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

 

by: LLC0706Posted on 2009-03-30 at 13:51:55ID: 24023208

This solution works fine, however I would like the movieclip to rewind back through the previous frames on rollout rather than snapping straight back to the first frame as this solution does.

The movieclip is a single layer frame by frame animation, with no tweening. The movie is of a roller garage door, which goes up when the user rolls over it and goes back down again when the user rolls off it, so that if the user then rolls back over it again before it has reached the first frame it will go back up again.

Is this possible?

 

by: john_hollingsPosted on 2009-04-01 at 01:23:57ID: 24036897

I believe you could use tweener for this type of reserve playback you are after.

Watch this video if you haven't used Tweener before: http://www.gotoandlearn.com/player.php?id=45
It's AS3 but Tweener in AS2 is practically the same.

You will need to download tweener from here http://code.google.com/p/tweener/downloads/list - Make sure you get the AS2 version and not AS3.  Basically you are going to need the following code within your onRollOut function:

Watch the tutorial to understand tweener and how to use it.

Hope this helps.

offer_mc.activate_btn.onRollOut = function()
{
   Tweener.addTween(offer_mc,{_frame:15, time:1});
}

                                              
1:
2:
3:
4:

Select allOpen in new window

 

by: LLC0706Posted on 2009-04-04 at 03:49:11ID: 24066802

Sorry for the late reply.

I've been trying to get the Tweener to work, but I'm getting the following error message when I test the movie:
------------------------------------------------------------------------------------------------------------------------------
**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: There is no property with the name 'e'.

**Error** C:\Documents and Settings\LLC0706My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: Line 391: There is no property with the name 'e'.
handleError(_tweenList[i], e, "onOverwrite");

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: There is no property with the name 'e'.

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: Line 740: There is no property with the name 'e'.
handleError(tTweening, e, "onUpdate");

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: There is no property with the name 'e'.

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLDcaurina\transitions\Tweener.as: Line 770: There is no property with the name 'e'.
handleError(tTweening, e, "onStart");

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: There is no property with the name 'e'.

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: Line 832: There is no property with the name 'e'.
handleError(tTweening, e, "onUpdate");

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: There is no property with the name 'e'.

**Error** C:\Documents and Settings\LLC0706My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: Line 845: There is no property with the name 'e'.
handleError(tTweening, e, "onComplete");

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: There is no property with the name 'metaError'.

**Error** C:\Documents and Settings\LLC0706\My Documents\My Flash\projectLLD\caurina\transitions\Tweener.as: Line 1068: There is no property with the name 'metaError'.
printError(pTweening.scope.toString() + " raised an error while executing the 'onError' handler. Original error:\n " + pError +  "\nonError error: " + metaError);

Total ActionScript Errors: 12
Reported Errors: 12
-----------------------------------------------------------------------------------------------------------------------------
I'm using Flash MX2004 (not professional)
I've downloaded version: tweener_1_31_74_as_fl7.zip
I've installed the caurina folder locally to the project.
This is the current code:

import caurina.transitions.Tweener;

offer_mc.activate_btn.onRollOver = function()
{
    offer_mc.gotoAndPlay("over");
}
 
offer_mc.activate_btn.onRollOut = function()
{
    Tweener.addTween(offer_mc, {_frame:15, time:1});
}

This is the first time that I have used Tweener; any suggestions?

 

by: john_hollingsPosted on 2009-04-06 at 01:32:37ID: 24075243

Firstly, try removing the _ from _frame:

Tweeer.addTween(offer_mc, {frame:1, time:1});

If this does not solve the problem, can you provide your fla file?

 

by: LLC0706Posted on 2009-04-06 at 05:05:38ID: 24076390

Hi
I'm not able to provide the .fla file as Expert Exchange does not allow this file format as an attached file.
I've recreated the movie using Flash CS3 Professional, using actionScript 2.0, although it can now be coded using actionScript 3.0 if you prefer.

I've tried removing the_frame from _frame as you suggested; the movie plays but you get this error message:

## [Tweener] Error: The property 'frame' doesn't seem to be a normal object property of [object Object] or a registered special property.

You can view the movie at this address: http://freespace.virgin.net/linda.c

It's almost working correctly, however I would like the door to go down frame by frame on roll out, instead of on the second roll over as it currently does.

 

by: john_hollingsPosted on 2009-04-07 at 02:50:22ID: 24085430

EE does not allow fla's but if make a copy of your fla and then rename it with an extension of txt instead of .fla it will upload.  I have done some digging and _frame is the right syntax so without the fla I'm not too sure what to suggest.

 

by: LLC0706Posted on 2009-04-07 at 03:46:23ID: 24085747

Hi
I've attached the file for you.

 

by: john_hollingsPosted on 2009-04-08 at 02:58:07ID: 24095302

Hi,

I must admit I couldn't work out why those errors appear however I have provide an alternative solution which after some testing seems to be doing the task you asked for.  The downside is I have had to add quite a bit of code to the MC itself.  This code controls the state and direction of play, which is called by actions in the _root timeline.

Have a look and let me know what you think.

 

by: LLC0706Posted on 2009-04-08 at 03:26:19ID: 24095444

Brilliant! This is exactly how I wanted it to work. Thank you so much for persisting with this.

 

by: LLC0706Posted on 2009-04-08 at 03:30:25ID: 31564270

This is exactly how I wanted it to work. Thank you so much for persisting with this.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...