-
Flying birds / on mouse over
I am working in flash, and I would like to have birds, which are sitting on buildings, but when you move your mouse over them, they fly away off the screen. All the animation kind of stuff, I can do fine, I don't know how to do the actionscript for this though. Could someone me out?
-
K, I'm still new in flash but I think I have the answer for this one.
First you have to create a mc for your birds.
mc actions script:
frame 1:
this will stop the mc from playing, in frame 1 you should have your birds in scene and standing on the building.
now work with that mc and make the birds go away. Remember the frame where they (birds) start flying away.
make a key frame inside the mc where you don't see the birds anymore and write another stop(); in there.
On main timeline you should have this script:
Code:
your_mc_instance_name.addEventListener(MouseEvent.MOUSE_OVER, functionName);
function functionName(evnt:MouseEvent):void
{
your_mc_instance_name.gotoAndPlay(frame number where your birds start flying away);
}
hope this works for you
PS: Since I am new and I don't know much on AS, there might be a easier way to do this :P.
Gent
-
Well first I would suggest using actionscipt 2.0, since it is much simpler.
The greatest pleasure in life is doing what people say you cannot do.
- Walter Bagehot
The height of cleverness is to be able to conceal it.
- Francois de La Rochefoucauld
-
Originally Posted by 691175002
Well first I would suggest using actionscipt 2.0, since it is much simpler.
I can do that, how would I do it in AS2?
-
Originally Posted by Gent
K, I'm still new in flash but I think I have the answer for this one.
First you have to create a mc for your birds.
mc actions script:
frame 1:
this will stop the mc from playing, in frame 1 you should have your birds in scene and standing on the building.
now work with that mc and make the birds go away. Remember the frame where they (birds) start flying away.
make a key frame inside the mc where you don't see the birds anymore and write another stop(); in there.
On main timeline you should have this script:
Code:
your_mc_instance_name.addEventListener(MouseEvent.MOUSE_OVER, functionName);
function functionName(evnt:MouseEvent):void
{
your_mc_instance_name.gotoAndPlay(frame number where your birds start flying away);
}
hope this works for you
PS: Since I am new and I don't know much on AS, there might be a easier way to do this :P.
Gent
I have this on the main timeline, on the layer and keyframe which contains my bird1 movie clip.
bird1.addEventListener(MouseEvent.MOUSE_OVER, flybird1);
function flybird1(event:MouseEvent):void
{
bird1.gotoAndPlay(1);
}
I am getting the following errors when I run it.
**Error** Scene 1, Layer 'birds', Frame 1, Line 5: 1120: Access of undefined property bird1.
bird1.gotoAndPlay(1);
**Error** Scene 1, Layer 'birds', Frame 1, Line 1: 1120: Access of undefined property bird1.
bird1.addEventListener(MouseEvent.MOUSE_OVER, flybird1);
Total ActionScript Errors: 2, Reported Errors: 2
-
I think you forgot to add the instance name to your movieclip.
Ckicl on your MC
Check the properties pannel
Click in the field, and type "bird1"
One more thing I forgot to mention
If you want to change your Mouse cursor to hand (like when you move your mouse over a button) you have to add this too:
bird1.buttonMode = true;
Gent
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|