Skip to content

Instantly share code, notes, and snippets.

@jhiswin
Last active January 3, 2019 07:11
Show Gist options
  • Save jhiswin/22c62ea2f3428f3f0236 to your computer and use it in GitHub Desktop.
Save jhiswin/22c62ea2f3428f3f0236 to your computer and use it in GitHub Desktop.
utilities for swiffy runtime, so it's easier to manipulate
// TODO make this not an ugly hack, assumes a lot of things
// TODO add a LoadMovie to load movie in-place, need to retrieve bgcolor and frameSize and set them
// for swiffy v7.4
// loadMovie only works if ends in lowercase .swf, looks for .swf.json
function lcase_swf(path) {
var path = path[path.length - 4] === '.' ? path.slice(0, -4) : path;
return path + '.swf';
}
swiffy.Stage.prototype.getContainer = function () {
return this['Td'];
};
swiffy.Stage.prototype.getRoot = function () {
return this['Ga']['O']['s'];
};
swiffy.Stage.prototype.GoToFrame = function (n) {
this.getRoot().stop();
this.getRoot().gotoAndStop(n + 1);
};
swiffy.Stage.prototype.Rewind = function () {
this.getRoot().stop();
this.getRoot().gotoAndStop(1);
};
swiffy.Stage.prototype.GetMovie = function () {
this.__url__;
};
swiffy.Stage.prototype.SetMovie = function (url) {
url = lcase_swf(url);
if (this.__url__ === url) return url;
this.__url__ = url;
this.setSwfUrl(url);
this.getRoot().loadMovie(url);
return url;
};
swiffy.Stage.prototype.PlayMovie = function () {
this.start();
this.getRoot().stop();
this.getRoot().play();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment