Thursday, 8 October 2015

Flash CC Pro/CreateJS: nextFrame

This function doesn't exist in Flash's HTML5 canvas, but the below will work instead.

this.forw.addEventListener("click", goNext.bind(this));
function goNext() {
this.gotoAndStop(this.currentFrame + 1);
}

Wednesday, 7 October 2015

Flash CC Pro/CreateJS

Another strange thing when working with Flash's HTML5 Canvas is that variables cease to exist when you move to the next frame.

I am used to having a root timeline that I can store info on that all other movieclips might need, but this won't work if they disappear between one frame and the next.

My current adjustment is to move everything down by one timeline. So I have a single frame on the uppermost timeline, and the movie clip sitting on that contains several frames, as I would normally lay things out. If something needs to be stored while moving to the next frame, then I just store it on the parent timeline.

for this function that I wanted all movie clips to be able to access:

this.giveDimensions = function (mc) {
mc.height = mc.nominalBounds.height * mc.scaleY;
mc.width = mc.nominalBounds.width * mc.scaleX;
}

In the timeline of the movieclip:

this.parent.giveDimensions(this.work_btn);

Flash CC Pro/CreateJS: Width and height of movieclips

I am currently trying out Flash CC Pro and the HTML5 Canvas publishing option.

One odd thing is not being able to access the height and width of the movie clips.

With the help of a stackoverflow post (http://stackoverflow.com/questions/29768424/how-to-get-width-height-of-a-movie-clip-in-createjs), I came across 'nominal bounds'. Couldn't find it in any of the documentation, it doesn't appear as one of the coding hints in the flash program either. Oh well.

I found that movieClip.nominalBounds gave me back an object that contained the original x, y, width and height of the unaltered movie clip. But on the stage, mine was a bit stretch and squashed, so I used

movieClip.nominalBounds.height * movieClip.scaleY

and this gave me the actual height. Ditto for the width.

Apparently the various bounds properties and functions vary depending on the exact type of object, but this worked for my movie clip.