Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / September 2006



Tip: Looking for answers? Try searching our database.

Run SWF on mouseover

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
skateblade - 28 Sep 2006 15:49 GMT
Hi,
I?m very new at this, but I have created a flash file and added it to a web
page and would like it to start running when someone mouses over the image. Can
anybody explain if or how I can do it in very easy terms?
Thanks for any help anybody can provide.
Sbisa - 28 Sep 2006 16:46 GMT
I am no expert, myself. But, one way to do this would be to:
1. keep your main timeline clean. In other words, don't make your main movie
in the main timeline. Instead, make your movie a movieclip that you would then
place in frame 1 of the main timeline; give it an instance name. Be sure to put
a stop(); action in the first frame of your movieclip, so it doesn't take off
on its own.
2. create an invisible button object. Place the invisButton object on top of
that [instanceName] movie clip (on its own layer) that you have placed on the
stage.
3. select the invisible button, and open your actions panel. Place the
following code in the invis button's action panel (I've used a_mc as my
instance name of the movieclip)

on (rollOver) {
    this.a_mc.gotoAndPlay(2);
}
on (rollOut) {
    this.a_mc.gotoAndStop(1);
}

Now, when you publish your movie, the swf will play only when mouse is over
it.

Notice that I put actionscript in the last frame of the movieclip, directing
it to gotoAndPlay(2). This keeps the movie playing as long as the mouse is
over.

http://www.oemlive.com/sample.zip
ChrisFlynn - 28 Sep 2006 16:50 GMT
Create a new scene that will come before you're current movie.

Create 2 layers, one called 'actions', the other 'btn'. In the actions layer,
add a stop();

If you don't already have a label where you movie starts, I'd add a layer with
just a label on it, call it "Start".

Create a transparent button, by creating a new button, and putting only a
25x25 box in the hit area, the rest of the keyframes should remain blank.

Drag that button from your library to your btn layer in your new scene. The
button will have a blueish tint to it. Make that button the size of your Flash
movie.  

Add this actonscript to your button

on(rollOver){
gotoAndPlay("Start");  //<-- Or whatever the label is at the start of your
movie
}

Hope that helps.

Chris
skateblade - 28 Sep 2006 17:38 GMT
Thank's for the response
I'll try and do it see if I can do and get it to work.
skateblade - 29 Sep 2006 19:45 GMT
Thanks for the help yesterday
I tried adding the button as described and I get this error:  

**Error** Scene=Scene 1, layer=btn, frame=1:Line 1: Mouse events are permitted
only for button instances
     on(rollOver){

I added this code to the first layer: stop();

I added this code to the second layer, btn layer:

on(rollOver){
gotoAndPlay("Start");
}

Have any ideas what I?m doing wrong?
Nickels55 - 29 Sep 2006 20:58 GMT
on(rollOver){
gotoAndPlay("Start");
}

add that code by clicking on the button and making it active, not on the layer

on the layer it looks like this:
*buttonInstanceName*.onRollover = function() {
gotoAndPlay("Start");
}
skateblade - 29 Sep 2006 21:19 GMT
Sounds great thanks, But how do I make the button active.

I am a newbie and have down loaded the trial version and I'm using the Flash
pro.
This is a lot harder that I thought it was going to be.
Thanks for help you can provide
Nickels55 - 29 Sep 2006 22:04 GMT
I mean actually select the button before you add the actionscript. This
attaches the script directly to the button as opposed to just having it on the
layer. If you click on the layer and add action script then it is not really
attached to anything. If you click on the button then add the code then the
code is directly attached to the button.

Hope that makes sense.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.