Fading an object in as3 - actionscript-3

I'm relatively new to as3 and am rewriting a game I have previously written in another language in it. In the intro animation, that leads up to the menu, there is lots of images fading in and out. I know how to make an object transparent using the .alpha, but seem to be struggling to get it to fade back in. I have the image starting off faded out, then I want it to fade in gradually over the course of about .1 of a second, stay there for 4 seconds then fade out.... Thanks.

Related

8-direction Figure Animation with Arrow Keys

I've been charged with designing a demo for an isometric video game in ActionScript 3. I have the bitmap spritesheets that show the avatar I'm using standing and walking in each direction. The walking animation is made up of three frames.
My problem, though, is that I need to figure out how to make use of them. I'm not familiar with animation in Flash, and I need input on how to gotoAndPlay() the walking frames for the right direction. I don't think isolating the necessary DIRECTION is going to be a challenge, so much as starting it and keeping it going while the arrow keys are down.
My current code is basically comprised of keyboard handlers for KEY_UP and KEY_DOWN, each containing a switch-case statement that changes the Avatar.currentDirection property. The handler continues to fire while the keys are down, but I need to add animation to the game.
I've seen some examples where they simply embed the animations into an SWF, propagate an array of the various walking stages, and alternate between them using an EnterFrame event handler, but this seems really clunky. I guess in the end I'm trying to make use of Adobe Animate, but I don't know how you're supposed to do that.
Ops, fortunately i'm working with sprites (atlas animations) right now!.
if i'm right, you just needs to use them for playing some animation with functionality.
if you have a well sized sprite which is tiled with isometric slots like it:
(9 frames sized 64x128)
your work is very easy, only create new movieclip from library, inside it, create a borderless rectangle (which is our mask) in a layer (named mask) then import image to the project, and its better to disabling smooth ability from image properties,
now, inside your movieclip, you have to create new layer (under the mask layer) and add your sprite image for each frame, and change its position:
at last, enable masking for mask layer, then its time of coding,
name your animation queries (like image 3) and for loopable animations, insert gotoAndPlay('anim_name') inside last frame. i hope you are familiar with controling movieclip animations which is basic consept of any flash project.
now to extend it for 8 directions support, you just need to play and switch between dirctions according single and multi keypreses,

AS3 Wheel of Fortune spinning

I'm working on wheel of fortune project but i'm currently struggling with the code.
I have attached the design of the wheel. I'm not a coder, i'm a designer and I need to do all the animation and the effects but I want to do it professional and that part is very important.
What I want to do is when you click on the spin button the wheel to rotate for 4-5 seconds with ease in/out effect and to stop each time on different random sector. Ill do different animations for each sector in separate movie clip and when it stops on a sector I want the movie clip related with that sector to start playing.
My idea is to make the wheel as a movie clip and each sector animation movie clips to be nested in it so when it stops that specific movie clip starts. Maybe I need to make each position of the wheel on key frame and to place the animations on these frames, but not sure if that is the right way.
One of the thing is that these movie clips with the effects should be easy for re position. I need to move them on the stage if needed and that's why i don't want them to be triggered with code.
If you can guide me step by step how to do that part I will appreciate your help. wheel design
Ok guys. There is a thread already for that and its something what I'm looking for. I like the example of the last answer in that thread, but I think that the first code will be more useful for my needs after that.
Can someone help me to make the code working, because I couldn't. All I need at the moment is to make the wheel spinning for 4-5 seconds on button pressed with ease in/out and it stops on random sector. Here is the link of the thread.
Spinning Wheel in flash AS3
I suggest you not to use keyframes at all. Use only one single frame, and in code, using a main class, instantiate all elements you need. To spin the wheel, you can consider using Greensock TweenMax or embedded tweening classes from Adobe. Also, spinning the entire wheel with all movieclips with nested animations inside, in spite animations are not running, forces to render all nested movieclips at each frame with a very heavy calculation load. I would suggest to either use 2 different clips, and add the animated one only when you need it, or at least to cache tentire wheel as a bitmap, and then uncache it when some animation is running inside.

Box2D Lights Wall Shadowing

Alright, so I've been pondering over this for quite awhile now; looking through documentation, examples, previously made games, ect...
Basically (for those familiar with Box2d Lights), I'm trying to create bodies on top of my walls (so there's shadow casting, and so the light will stop instead of going through the wall). I have no problem creating, positioning, and updating the bodies, but the only real problem which I can't figure out is a way to make the filled body to be invisible or transparent so it shows my tileset (or wall) while still giving a shadow effect if light was casted onto it.
Perhaps I'm thinking or going about this the wrong way. Feel free to correct me.
Here's an image to display an example of a body I created on top of my wall. The shadows are handled properly, but I cannot see my wall.
Any help is greatly appreciated. Thanks.
You have two options here:
Set the shadow-dropping bodies behind the wall and use only transparent bodies for collision detection using BitMasks
Or render your wall sprites on top of box2dLights

ActionScript 3/Flash CC - Loop background

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 ;)

'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);
}