Skip to main content
agnestheo
Participant
March 16, 2017
Answered

Load movie through a button in Animate CC?

  • March 16, 2017
  • 2 replies
  • 1185 views

Let's say I have this button that when I click it, it loads an SWF file I targeted.

I know there is some ways to do this (by linking the button to a scene where it has the loadMovie script there using Go to Scene And Play), but is there another way to do it with just putting a loadMovie script in the button itself?

I tried using the ones from the code snippets and put it in the button, but it didn't work at all. It seems like you need a different codes for that.

I hope you can help me. Thank you!

OS: Windows 10

Program: Adobe Animate CC 2017

This topic has been closed for replies.
Correct answer kglad

you can't attach code to buttons.  you can attach code to a timeline that references that button.

var loader:Loader=new Loader();

var urlR:URLRequest=new URLRequest('path/filename.swf');

yourbutton.addEventListener(MouseEvent.CLICK,loadF);

function loadF(e:MouseEvent):void{

loader.load(urlR);

addChild(loader);

}

2 replies

agnestheo
agnestheoAuthor
Participant
March 16, 2017

It works! Thank you very much!

kglad
Community Expert
Community Expert
March 16, 2017

you're welcome.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 16, 2017

you can't attach code to buttons.  you can attach code to a timeline that references that button.

var loader:Loader=new Loader();

var urlR:URLRequest=new URLRequest('path/filename.swf');

yourbutton.addEventListener(MouseEvent.CLICK,loadF);

function loadF(e:MouseEvent):void{

loader.load(urlR);

addChild(loader);

}