Flash :: Adding Parts Of A Snake On Through Timer Events?
Mar 30, 2011having problems adding parts of a snake on through timer events
package {
import flash.display.Sprite;
import flash.events.KeyboardEvent;[code]....
having problems adding parts of a snake on through timer events
package {
import flash.display.Sprite;
import flash.events.KeyboardEvent;[code]....
I'm making a puzzle game in Flash cs5/as3 which can have custom puzzle shapes. Basically, the user can draw basic protrusions of a puzzle. Then I create a black and white puzzle piece with a custom function like this var piece:PuzzlePiece= new PuzzlePiece(true,true,false,false); PuzzlePiece is a class that extends Sprite. The four arguments correspond to the four sides of a puzzle piece (up, down, left, right). If the argument is true, it means that protrusion should stick out of that side of puzzle piece. If it's false, it should have a hole on that side, so it fits the protrusion. I first attach the protrusions that stick out, then i flip the protrusions that stick in, attach them to a new sprite (in_part) and invert them with the following function:
[Code]...
I am trying to use a timer in differents parts of a movie, but I want each part to play a different amount of millisecounds, but even though I change the var millis, it still times for the same amount as the timer on the first timeline. DO I need to make a new timer, and how would I do it. Some else gave me the script for the timer I am using.
[Code]...
This is what I am using for the other frames because if Flash wont allow me to use the same script more than once. I use this for the second scene, but when I try to change it, there is no change it still follows the parameters f the timer in the first scene.
I have a bunch of movieclips called firstNameBtn_mc, lastNameBtn_mc and many others. I also have a bunch of movieclips whose names start with the same but instead of "Btn" they have "Arrow", like firstNameArrow_mc, lastNameArrow_mc etc.
What I want is when I click on firstNameBtn_mc it does somthing to firstNameArrow_mc, but there are so many buttons I would like to do it in the following way.
1. get the movie clip's name...something with e.currentTarget.name for example
2. remove the Btn_mc part
3. add the Arrow_mc part
4. do something to the movieclip of that name
Does anyone know if there is a way to determine when all the parts of a SkinnableComponent object have been added? The context of this problem is the following:I have a custom skinnable component class which needs to update some of its parts (e.g. change some labels) once it has been created, meaning once all the skin parts have been instantiated and added.
View 1 RepliesI've looked all over the web and everyone can teach you how to make a timer for your game or a countdown, but I can't seem to find out how to add time to an already counting timer. So here is my counter class:
package {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.text.TextField;
import flash.events.Event;
import flash.utils.Timer;
[Code] .....
That works without any issues or problems and just keeps counting upwards at a speed of 100ms, what I want to know is how to add say 30 seconds if something happens in my game, say you kill an enemy for example.
've created a simple flash game for moving a car round the flame to collect fuel cans and avoid traffic cones. The game has a 10sec timer running but i want to make it that if u hit a fuel can it adds 5secs to the timer and if u hit a cone it removes 2secs.This is my code so far
var fuelpoints = 0;
var conepoints = 0;
startButton.visible = true;
[code]....
I downloaded the trial of flash cs4 and have created a simnple flash.I am creating a simple slideshow, each of the slides should be clickable and redirect the browser.I created images then imported them and they were automatically converted to symbols.I combined the symbols using some motion tweens.I then created an actions layer and created clasic tween wher I want the user to be able to click.My problem is I cant get it working. I think I am not referencing the right objects.[code]I have tried setting the object reference to the motion tween instance name, the classic tween name on the actions layer and the symbol name none seem to work
View 1 RepliesI got a small problem in timer,i am using timer code in my game,when i reached the 0 timer i need to start the timer again with out using any events how can i do this .please help me in this.I am using following timer code in my game:
var aa:Number;
var timer:Timer = new Timer(1000,120);
timer.addEventListener(TimerEvent.TIMER, countdown);[code].....
Can we use 2 timer events in a single application. I'm trying to use 2 timer events in a single application but the 2nd timer event is not working.... any one have an idea??? how to use 2 timer events in a single application.
View 1 RepliesI am using the Timer class to time events. Although, I am not sure I have it set up correctly as after a few seconds the events start to get synchronized. first two, then three, etc. Here is an example of the code:
[Code]...
Does anyone know what could be possibly interfering with the Timer for this to happen? It mainly starts happening after you click on an mc and it is removed from the stage (this is for a game).
I have been working on something along the lines of a computer controlled version of snake.. and i have gotten most of it done, but i am having so many issues getting the artificial intelligence to work right. so far, i have it set up so that the head of the snake constantly moves toward the dots it is trying to pick up.
And i also have it set up so that every frame it checks to see if there is another block in its path. the problem is, once it knows there is something in the way, it cant seem to figure out how to get around it. in other words, i dont know what to tell it to do once it notices it is about to die.
I'm working on writing a class that kind of creates a ribbon/snake effect. The class itself just needs to draw a box when initiated. I'm having trouble with some of the math though. I'm going to be passing in information into the initialized class, angle, speed, width, etc. When the instance is greated, the first two points are going to be the last two points of the box. Then I need to place a line at the angle passed in, and draw two more lines to that.
View 1 RepliesI was wondering if it was possible to move a MClip from a defined "point A" to a defined "point B" (precisely), but this with a "snake or bubble" movement (or something like that).
View 8 RepliesI would like to add a timer that keeps track of total time and also current time that runs next to my seek bar component for my flash movie. How can I do this? For example: 1:11 | 2:04 ... the 1:11 displays the current time of the movie and the 2:04 would represent the total time of the video.
View 20 RepliesI am creating a flash game with a timer and as you answer questions I would like the time to increase or decrease but I can't seem to figure out how to do so.
View 1 RepliesI've been trying to make my own flash game based on the kirupa tutorial: url...My scripting is very similar to the scripting in the tutorial, but I obviously adapted it to my own design. Now Iïż½m trying to add a time limit, which when the time reaches 0 it jumps to the time up screen. I have spent two whole days searching on google, trying loads of suggestions, trying to figure this out myself.[code]This scripting works on a test page (i.e. away from the actual game) but when I try to add it to my game it deletes the main movieclip (in this case a tank) which is used to play the game.
View 3 RepliesI finally added a timer into my XML AS3 gallery, but when the timer starts the images dislocate..
What is the problem here? I manually set the width and height in the XML with difficulty... (Because I couldn't find a way to automatically set the image to the horizontal and vertical center..)
But why does the position changes when the timer starts to play (every 10 secs)?
This is wat it looks like when the timer hasn't started yet (or when I browse through the images with the arrow buttons):
[Code]...
I made an app (Towers of Hanoi) and i added a "demo" button that solves the problem based on a recursive function. The button is supposed to make a move one step at the time, i mean one step at every few seconds so you can actually see how the algorithm works. The problem is i haven't really used the timer event before and i have no idea how to implement it in this particular scenario.
Code:
function hanoiPlay(n:int,a:Stack,c:Stack,b:Stack):void
{
[code]......
I am creating a game and want to reward the player at the end of a level by playing an animation. I have created a timer to add the animation to the stage but cannot figure out how to remove the animation once the timer has completed counting. I am sure you wise scripters out there know the secrete to this mystery.
[Code]....
I'm making a game and it has a 20sec timer in it and I want to make a button/powerup thing that adds 5 seconds to the timer when you press it.I'm currently using: -
Code:
timerBTN.onPress = function(){
_root.countdown += 5;
[code].....
The game contains a timer which displays on screen and counts up displaying hours, minutes and seconds.
When the hint button is pressed the game adds 1 to the penalty counter.
Code:
penalty++;
What I want to happen is for 20 seconds to be added the time shown at the end of the game for every time the hint button is pressed.
Below is the timer code:
Code:
function TimerHandler(e:TimerEvent):void{
var Seconds:String = String(uint(MyTimer.currentCount%60));
var Minutes:String = String(uint((MyTimer.currentCount/60)%60))
var Hours:String = String(uint((MyTimer.currentCount/60)/60));
[Code]....
This is TJenner2's code I got from this thread:
ActionScript Code:
var myBtnArray:Array = ["Apple", "Orange", "Blue", "Lion"];
var myFrameArray:Array = [2,3,4,5]
[code].......
I am working on a game and want to reward the player with an animation at the end of a level. I have created a time and added the animation to the stage but I cannot figure out how to remove the animation once the timer has completed.
Code: Select all/* Simple Timer
Displays a countdown timer in the Output panel until 30 seconds elapse. This code is a good place to start for creating timers for your own purposes.
Instructions:
1. To change the number of seconds in the timer, change the value 30 in the first line below to the number of seconds you want.
var celebration:Celebration;
var fl_TimerInstance:Timer = new Timer(1000,30);
fl_TimerInstance.addEventListener(TimerEvent.TIMER, fl_TimerHandler);
fl_TimerInstance.removeEventListener(TimerEvent.TIMER, removeTimer);
fl_TimerInstance.start();
[Code] .....
I set up a loop where a movie clip moves in a triangle over and over. It works, but I want it to pause for 5 seconds at each location, so I added a Timer (my first attempt). Now, it will go through the triangle once, pausing correctly, but then the main movie clip (target_mc) stops in the original position and never moves again.
Code:
import fl.transitions.*;
import fl.transitions.easing.*;
var xMove0:Tween;
var yMove0:Tween;
var xMove1:Tween;
[Code] .....
[Code]...
how to add addevents to the menus in the popupButton.
I have a news rotator that is populated from an RSS feed. The rotator has a timer that cycles through the news items, displaying a link and image and title for each item. I have the put in three buttons for the user to control the item that is displaying. A pause, forward and backward button.
My issue is that I'm not sure how to implement the button without messing up my timer that is already running. I was able to do the Pause button, which was simply to stop the timer. The forward and backward buttons are a bit more tricky. This is what I have so far. Note that I have much of the code duplicated because I needed to initialize the objects for the first timer index. After the first item, the code runs from the timerHandler() function.
PHP Code:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
[Code] .....
I want to make a movieclip invisible initially but i dont want to set it manually within the properties in flash because i cant then see it on the scene.i could add some code like so:
MC Frame one.
this.onClipEvent(load)
{
this._alpha = 0;
}
but I cannot. How can i set the MC _alpha to 0 for all instances without adding it manually to each instance or setting it in the properties?
edit: or creating a class for it just to set the alpha.
I am loading an external SWF using the Loader class, and adding it to the stage with addChild.When trying to add a mouse click event listener to the MovieClip, using addEventListener, nothing happens, the event never fires.Is there a specific way to add listeners to externally loaded movie clips?My code looks somewhat like this:
var target:MovieClip = assets["screensaver"] as MovieClip;
target.root.addEventListener(MouseEvent.CLICK, onClickScreenSaver, true);
addChild(target);
The target shows up on the display, but the CLICK event is completely ignored.
I am working on a very simple game in Flash. I want to make all the animations framerate agnostic, so that I can change the framerate without affecting the flow and speed of the game.I read somewhere that if you want to do that, you simply create a Timer object and attach an event listener to this timer.
What if I have many objects that have to listen to the same timer? See the code to understand what I am trying to do. At this stage nothing breaks, but the event does not fire.Here is the Main class, the one that runs on swf execution:
public class Main extends MovieClip {
private static var _stage:Stage;
private static var _timer:Timer;
[code]....