all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

ActionScript Help


ActionScript Help DIgitalDisasta
4/23/2005 9:31:38 PM
flash actionscript:
Ok, I am currently working on my personal website and I am runing into a
problem. Let me explain. I have a movie clip on the main scene, in the movie
clip I have 6 more movie clips (these are the buttons for my interface). The
reason for this is because I have an object the moves across the X axsis and
moves over the button when the mouse is over it. I also have the buttons
(movieclips) change color when the mouse is over it. My problem is, im trying
to play a sound when the mouse rolls over the movieclip. I have tried a few
different codes but yet nothing works. This is the code I am using right now
(it is in the first frame of the movieclip):

[quote]

news.onRollOver = function() {
colornews_button = new Color(news)
colornews_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
playSound("beep");
}
};
news.onRollOut = function() {
colornews_button = new Color (news)
colornews_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
arrow._x -= (arrow._x-_stop);
};
};
news.onPress = function() {
getURL ("http://")
}

bio.onRollOver = function() {
colorbio_button = new Color (bio)
colorbio_button.setRGB ( 0x990000)
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
bio.onRollOut = function() {
colorbio_button = new Color (bio)
colorbio_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
bio.onPress = function() {
getURL ("http://")
}

music.onRollOver = function() {
colormusic_button = new Color (music)
colormusic_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
music.onRollOut = function() {
colormusic_button = new Color (music)
colormusic_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
music.onPress = function() {
getURL ("http://")
}

events.onRollOver = function() {
colorevents_button = new Color (events)
colorevents_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
events.onRollOut = function() {
colorevents_button = new Color (events)
colorevents_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
events.onPress = function() {
getURL ("http://")
}

links.onRollOver = function() {
colorlinks_button = new Color (links)
colorlinks_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
links.onRollOut = function() {
colorlinks_button = new Color (links)
colorlinks_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
links.onPress = function() {
getURL ("http://")
}

contact.onRollOver = function() {
colorcontact_button = new Color (contact)
colorcontact_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
contact.onRollOut = function() {
colorcontact_button = new Color (contact)
colorcontact_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
contact.onPress = function() {
getURL ("http://")
}

[/quote]

I have an other code for the sound in the first frame of the movie (I read
somewhere that this was the way to do it, but it doesnt work). This code is as
follows:

[quote]

_global.playSound = function(beep){
var newSound = new Sound();
newSound.attachSound(beep);
newSound.play();
}

[/quote]

my question is how do i get the sound to play when the mouse rolls over the
movieclip. I can't figure it out. Can someone help??

news.onRollOver = function() {
colornews_button = new Color(news)
colornews_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
playSound("beep");
}
};
news.onRollOut = function() {
colornews_button = new Color (news)
colornews_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
arrow._x -= (arrow._x-_stop);
};
};
news.onPress = function() {
getURL ("http://")
}

bio.onRollOver = function() {
colorbio_button = new Color (bio)
colorbio_button.setRGB ( 0x990000)
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
bio.onRollOut = function() {
colorbio_button = new Color (bio)
colorbio_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
bio.onPress = function() {
getURL ("http://")
}

music.onRollOver = function() {
colormusic_button = new Color (music)
colormusic_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
music.onRollOut = function() {
colormusic_button = new Color (music)
colormusic_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
music.onPress = function() {
getURL ("http://")
}

events.onRollOver = function() {
colorevents_button = new Color (events)
colorevents_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
events.onRollOut = function() {
colorevents_button = new Color (events)
colorevents_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
events.onPress = function() {
getURL ("http://")
}

links.onRollOver = function() {
colorlinks_button = new Color (links)
colorlinks_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
links.onRollOut = function() {
colorlinks_button = new Color (links)
colorlinks_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
links.onPress = function() {
getURL ("http://")
}

contact.onRollOver = function() {
colorcontact_button = new Color (contact)
colorcontact_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};
contact.onRollOut = function() {
colorcontact_button = new Color (contact)
colorcontact_button.setRGB( 0x999999 )
this.onEnterFrame = function() {
};
};
contact.onPress = function() {
getURL ("http://")
}
Re: ActionScript Help kglad
4/23/2005 10:04:40 PM
you may have more errors, but the 2 i see immediately are enough to cause your
problems. first, you don't want to repeatedly call playSound(). and second,
you don't start playing a sound object by using play():

news.onRollOver = function() {
playSound("beep");
colornews_button = new Color(news)
colornews_button.setRGB( 0x990000 )
this.onEnterFrame = function () {
arrow._x -= (arrow._x-_xmouse)/3;
}
};

_global.playSound = function(beep){
var newSound = new Sound();
newSound.attachSound(beep);
newSound.start();
}
Re: ActionScript Help DIgitalDisasta
4/23/2005 10:28:29 PM
Re: ActionScript Help kglad
4/23/2005 10:55:29 PM
AddThis Social Bookmark Button