0

I've successfully converted a Flash file to HTML using CreateJS but I am having no joy making a symbol a link.

The buttons work perfectly in the flash movie but when converted to JS/HTML5 it seems to fail. Does anyone have a solution?

Robert Owen
  • 930
  • 7
  • 12

3 Answers3

2

This is working:

// The "instance" is an instance on the stage in Flash
this.instance.addEventListener("click", function(event) {
    window.location = "http://google.com";
})    

I tested it on a Flash Canvas with just one frame and one button

Carloyn
  • 21
  • 2
  • Yes, the `onClick` methods have been deprecated and removed for some time now. I added an addendum to my answer. Cheers. – Lanny Oct 14 '15 at 22:53
1

Toolkit for CreateJS does not convert ActionScript- you will have to either add a frame script

/* JS
this.onClick = function() {
    window.location = "http://google.com";
}
*/

Or find the symbol in your JavaScript and add the listener there.

// The "symbolName" is an instance on the stage in Flash.
exportRoot.symbolName.onClick = function() {
    window.location = "http://google.com";
}

You can also create library items yourself and add the listener.

var symbol = new lib.MySybmol();
stage.addChild(symbol);
symbol.onClick = function() {
    // etc.
}

Hope that helps.

UPDATE: The examples in this answer are out of date. The onClick handlers have been deprecated for some time, and need to be replaced with the EventDispatcher addEventListener(), or the shortcut on() methods:

symbol.on("click", function() {
    // etc.
});
Lanny
  • 11,244
  • 1
  • 22
  • 30
0

i added your code just before the script ending . And my image has default bitmap instance for one image . but it does not redirect to google

exportRoot.instance.onClick = function() {
    window.location = "http://google.com";

here is the link : http://canvas.byethost11.com/check/check.html

Tanvir Ahmed
  • 25
  • 2
  • 6