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);
}
A diary about programming problems - to help me more easily learn from (and Google) past mistakes.
Showing posts with label flash. Show all posts
Showing posts with label flash. Show all posts
Thursday, 8 October 2015
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);
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.
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.
Friday, 14 November 2014
How to Use Screen Shots in Flash
Sometimes, you want to take an exact picture of what is on your screen and put the image into Flash, but when you do, most of the image is transparent!
1) Press the PrtScn button on the keyboard to take a picture of the screen. Alternatively, to take a picture of a particular window, make sure the window is selected, hold down Alt, and then press PrtScn.
2) Open up a Word document, and press Ctrl+V (or just right-click and select Paste).
3) Select the resulting image, and copy it (right click, Copy, or Ctrl+C).
4) Now you can go back to your Flash document and paste the image, and it will look the way it should.
Have fun!
1) Press the PrtScn button on the keyboard to take a picture of the screen. Alternatively, to take a picture of a particular window, make sure the window is selected, hold down Alt, and then press PrtScn.
2) Open up a Word document, and press Ctrl+V (or just right-click and select Paste).
3) Select the resulting image, and copy it (right click, Copy, or Ctrl+C).
4) Now you can go back to your Flash document and paste the image, and it will look the way it should.
Have fun!
Friday, 4 July 2014
Flash: How to make the white transparent in a grey scale image
What if you want to get a picture and colour it in, but you don't want it to take forever, or lose any of the detail?
(Apologies if this can be done more easily in another program, but when it comes to pictures, I'm most comfortable with Flash.)
1) Find your image, the more contrast the better - ie, some really light areas and some really dark, the less grey the better.
2) Copy and paste it into flash.
3) Turn it into a movie clip, select it, and in the Properties box, select Adjust Colour, and increase the contrast. Try to choose an optimum value where you can see the details you need, but the grey areas have turned white.
4) Then choose the blending option Darken. The white areas should now be transparent.
5) Lock the layer of the photo, and create a new layer underneath. With this layer selected, draw lines to delineate the blocks of colour you want to show through the image. You can apply fills with gradients, or make areas of colour into movie clips and give them glows as ways of mixing colours etc.
6) If you want to make the lines darker, you can copy and paste the movie clip on top of itself (this way it will have the same contrast settings) and set the blending option of the one on top to Multiply.
Example:
I'm no artist, and I'm not claiming that mine is an improvement on the original, but I am claiming that this didn't take me very long at all.
(Apologies if this can be done more easily in another program, but when it comes to pictures, I'm most comfortable with Flash.)
1) Find your image, the more contrast the better - ie, some really light areas and some really dark, the less grey the better.
2) Copy and paste it into flash.
3) Turn it into a movie clip, select it, and in the Properties box, select Adjust Colour, and increase the contrast. Try to choose an optimum value where you can see the details you need, but the grey areas have turned white.
4) Then choose the blending option Darken. The white areas should now be transparent.
5) Lock the layer of the photo, and create a new layer underneath. With this layer selected, draw lines to delineate the blocks of colour you want to show through the image. You can apply fills with gradients, or make areas of colour into movie clips and give them glows as ways of mixing colours etc.
6) If you want to make the lines darker, you can copy and paste the movie clip on top of itself (this way it will have the same contrast settings) and set the blending option of the one on top to Multiply.
Example:
![]() |
| Before |
![]() |
| After |
Monday, 10 May 2010
Getting data from MySQL
Today, I have been mostly... not getting data from a MySQL database.
I thought I had this sorted already - I had a script that could send data to a php script, then receive a query string and format the data as a URL variable.
As usual, when you try to actually use it for something - it turns out to be more complicated.
First of all, using capital letters in the query string that PHP is outputting is apparently not a good idea! Can you imagine?!? It took me three hours just to pin the problem down to that!
So then I though I had the problem sorted, but no.
I think it might be something to do with the length of the query string...
More on this later?
I thought I had this sorted already - I had a script that could send data to a php script, then receive a query string and format the data as a URL variable.
As usual, when you try to actually use it for something - it turns out to be more complicated.
First of all, using capital letters in the query string that PHP is outputting is apparently not a good idea! Can you imagine?!? It took me three hours just to pin the problem down to that!
So then I though I had the problem sorted, but no.
I think it might be something to do with the length of the query string...
Subscribe to:
Posts (Atom)

