ActionScript 3/Flash CC - Loop background - actionscript-3

I just started learning AS3, I've been using Adobe Flash for a while.
I'm making a simple "Avoiding Game", but the problem is that I want the background with stars (white dots) to move, but eventually it will run in to it's end (white space).
I made a temporary solution by copy/paste:ing the bg over and over again, but it only lasts a few minutes.
Is there a way to loop the background?
or even better:
Is there a way to random generate moving stars?
I guess it's quite simple, but I'm a newbie.

I made a temporary solution by copy/paste:ing the bg over and over again
If you are familiar with the Timeline, I will give you simple solution.
Yes, you need to copy/past your background, but only once.
Stack original and copied background, so copied version begins at the end of original background. Create animation by offsetting original background on it's width, so copy version of the background will be in the same place - at start.
Now you will have infinite loop for the background, because first and last frames are equal ;)

Related

Is There a Way to Make a Repeated GIF Background That Randomly Changes GIF After Each Loop in HTML?

I'm really new to HTML and I'm trying to make a small website for my art.
I was wondering if it's possible to have my background choose randomly from a set of GIFs for each tile and after one loop to randomly select another GIF. I'm specifically trying to have a unique GIF for each tile and wasn't sure how to even go about doing this since I only know how to make one GIF repeat across the entire background.
In case what I'm asking doesn't make sense, I'm attempting to have the background of my website look like the floor of an arcade. I didn't want to be the same few squiggles and shapes in a repeated pattern and thought it would be cool if instead each one changed into a separate squiggle/shape after a few seconds.
Thank you if you can help and sorry if this sounds at all silly or anything.
I tried looking into this elsewhere and just couldn't find anything I understood, so I thought to ask here.

How to make do 'pixie-based' free drawing in fabricjs

I am trying to make an 'Eraser' for my fabricjs-based 0.5 Opacity free drawing app(with non-trivial background image), i. e. everything drawing is half-transparent and we still can see the background through the free drawing.
However I understand by default all free drawing are 'path-based' i. e. everything we draw (between mouse-down mouse up) is captured as an individual path in the canvas, so it is not possible to erase arbitrary part of the path. So I am thinking maybe we can capture the mouse-down/up event manually and draw an image pixie by pixie and place it on the canvas with opacity=0.5? so that we can use white to overwrite all those 'old' drawing?
Is this a workable/efficient enough solution?
However I am not sure how this can be implemented in fabricjs? could you please give me some advise on the steps or some pseudocode? thanks
I didn't complete my attempt when i had a similar problem , but the basic concept was simple 'Read the pixel under the cursor(and under the canvas, where another canvas with a background image was) and paint the path with the same color' , creating an eraser effect. The starting stone was this jsfiddle.net/DV9Bw/1/ maybe it can help you out, i didn't try it to its completion since the idea was quickly abandoned

Remove Child? AS3

So I'm incredibly new to AS3, and barely know my way around.
I built a simple colouring book game, essentially changing some of the graphics of a tutorial, and replacing numbers and sizes to fit what I wanted to achieve. I then built a menu screen in a seperate scene and linked the two with code snippets and buttons to go back and forth.
The colour pickers are generated when the game is ran, however an issue I seem to be facing is that when I go back to my main menu, they are still there.
Can someone point me in the right direction as to how I can fix this? I'm sure it's a rather simple fix. I can provide the code from the tutorial if needed
I think you're right you need removechild this color to remove one color from stage... Maybe you need removechildren to remove all color, whin are on stage... Try this two way

AS3 Fisheye Effect

I'm having trouble understand how DisplacementMapFilter works. Basically, I'm trying to create a revolving planet through a combination of fisheye/masking.
Also, how do I go about doing this via timeline? I'm not too familiar with coding within it, but this is more of an animation project than anything else, so classes are out of the question. Sorry for the lack of code -- I'm simply stuck.
As noted in the comments above, this probably only answers half the problem;
Generating a displacement map image isn't too difficult with the right tools. I'll assume you're using Photoshop, GIMP, Fireworks, or similar.
It's probably best to work on a 128x128 image or smaller with this method. Some editors have more specialised tools which let you work on pretty much any size of image, but this is a generic process that needs no special tools. You can always enlarge the end result, but the quality will begin to go down.
Start with a gradient fill. It should go from pure black on the left to dark red on the right (specifically 128,0,0). Add a vertical fill from black at the top to dark green at the bottom (specifically 0,128,0), and combine them with a LIGHTEN or ADD filter. You should now have an image which has black, red, green and yellow corners. Flatten it.
Copy this image to another layer / whatever the term-of-choice is for your editor. Apply whatever displacement filter you want to it (maybe a fish eye, maybe a manual smudge, maybe a perspective transform, anything)
Add a third layer between the two. Flood-fill it with dark yellow (128,128,0) and set it to ADD / ADDITION blend mode. Set the top layer to SUBTRACT / SUBTRACTION blend mode.
That's it. You should get a mostly yellow image which will function as a displacement map.
Update:
To use this in the example program (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/DisplacementMapFilter.html#includeExamplesSummary), replace the createBitmapData function with this:
private function createBitmapData():BitmapData {
return myBitmapObject.bitmapData;
}
where myBitmapObject is the instance name (I think) of your displacement Bitmap. There are tidier ways of setting that up, but this is the easiest.

'Runner' Game, loop sliding background, remove children when outside

I've just started using actionscript 3 and I am currently trying to make a scrolling runner game in Flash CS5, similar to the Flood Runner games from Tremor games. The difference is, however, that my game is not an endless runner game and the character has a destination that she must reach before time runs out. Alot of the tutorials I've read on the subject use the player character's x and y positions to scroll, but in my game the background scrolls independent of the character. The tutorials I've read about this do not address my problems specifically.
TL;DR: I do not want to loop my background but have a series of multiple background images.
I am trying to figure out the best way to patch together multiple background images seamlessly. Currently, I have one background movie clip object at the maximum pixel width. The background object scrolls to the left independently of the position of the player character, who can only jump.
What I am thinking about doing is this:
Every time a point at the far right edge of one background image reaches the far right stage boundary, I have my actionscript call an addChild command for the next background object and instantiate it at the far right stage boundary. It will scroll at the same speed as the preceding background object.
I also need to figure out how to remove the background objects once they have completely exited the stage for memory purposes.
So, what would be the best way to tackle this?
Your basic concept will work, and to remove you just need to evaluate when the background image is off the screen :
if (backgroundImage.x < -backgroundImage.width)
{
// image is no longer on the screen.
removeChild(backgroundImage);
}