Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to get a movie inside a button to trigger on rollover so it doesn't stop when mouse moves off the button?

New Here ,
Feb 05, 2015 Feb 05, 2015

Hey all,

How can I get a movie inside a button to trigger on rollover so it doesn't stop when mouse moves off the button? The final output will be a touchscreen so it should function when tapped once. I will have several buttons existing at the same time so I can't use the timeline to solve it. I'm using action script 3.0. Any help welcome please. I am a designer not a coder so scripting knowledge is limited,

Thanks,

Sarah

TOPICS
ActionScript
380
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2015 Feb 05, 2015

it will actually be easier to use a movieclip instead of a button and control your off,over and down frame display using actionscript.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 05, 2015 Feb 05, 2015

Sounds good in theory. Any chance of a sample? One graphic for example is an ambulance. On rollover the ambulance drives off, siren flashing and sound blaring. I've figured it out in action script 2.0 but 3.0 is a no go.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2015 Feb 05, 2015

Try something like this:

ball.addEventListener(MouseEvent.CLICK, triggerMC);

function triggerMC(e:MouseEvent):void {

  ball.play();

}

Assuming "ball" is your MovieClip instance.

Here's an FLA => https://dl.dropboxusercontent.com/u/78088/shares/mc_click.fla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2015 Feb 06, 2015
LATEST

Hi Joseph,

I'm using Flash CS5 so couldn't open your CC file. Vould you save it down to cs5 for me please?

Thanks,

Sarah

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2015 Feb 05, 2015

check jl's answer but i think this might be more what you're looking for:

button_mc.addEventListener(MouseEvent.MouseOver,overF);

button_mc.addEventListener(MouseEvent.MouseOut,outF);

// button_mc should have a stop() in its first frame, an 'over' frame with your movieclip (eg, over_mc)

function overF(e:MouseEvent):void{

button_mc.gotoAndStop("over");

button_mc.over_mc.play(); 

}

function outF(e:MouseEvent):void{

if(button_mc.over_mc.currentFrame!=1){

button_mc.addEventListener(Event.ENTER_FRAME,enterframeF);

}

}

function enterframeF(e:Event):void{

if(button_mc.over_mc.currentFrame==button_mc.over_mc.totalFrames){

button_mc.removeEventListener(Event.ENTER_FRAME,enterframeF);

button_mc.over_mc.gotoAndStop(1);

button_mc.gotoAndStop(1);

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 05, 2015 Feb 05, 2015

‌thanks Joseph and kglad. I'll get time tomorrow to try these options.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines