ActionScript 3.0 :: Randomizing Symbol Movement Within Range
Apr 7, 2010
Basically, I've got a small space shooter game and the idea is to have the enemies start moving at the top of the screen and head towards the player, while growing in scale, and moving at an angle.(To give the sort of perspective/distance effect). Right now, I'm able to get the enemies to move at one angle only. How would I get them to move on X at a certain range?
This is the code affecting movement/Scale
for( i = 0; i < enemyShip.length; i++ ){
enemyShip[i].y += 10;
enemyShip[i].x += 5;
enemyShip[i].scaleX += 0.03;
enemyShip[i].scaleY += 0.03;
}
The pic above basically shows what I mean by the perspective look. I need to blocks to move towards the player at various X ranges within those lines, but I don't want them to zigzag while moving. I know it has to do with Math.Random.
View 2 Replies
Similar Posts:
Aug 18, 2004
I'm making a banner ad for work and have a part where I want to basically rain our logo for like 15 frames or so. I've started doing this manually but as you can imagine, it's a bit tedious and time consuming. I looked at Kirupa's tutorials on snow and continual motion but I'm wondering how I would go about scripting it so it does the following within mc_logorain (which is sitting on the root) on enter:
1. duplicates mc_logo many times, randomizing size.
2. Rains for a set amount of time or frames and unloads.
I think I understand the logic of what's supposed to happen, just not sure of the syntax. Would there be two loops? One for the duplicate/random size and one to say basically "while i < 100, keep duplicating and raining"?
View 9 Replies
Dec 30, 2010
I am learning AS3. How can I move a symbol? My Code
[Code]...
But when I press space the symbol is to fast. How can edit the speed of the point?
View 2 Replies
Oct 16, 2009
What I really want to know is how to rotate the symbol based on direction of mouse movement
View 1 Replies
Jul 9, 2010
I've been playing with carousel code, and was wondering how to change it from circular animation (carousel) to left/right linear (conveyer belt) style animation, how to change the mover code and 't.angle = i * ((Math.PI*2)/numOfItems);'
[Code]....
View 1 Replies
Dec 28, 2008
I have an xml flash slide show that works great but i would really like it to randomly select the images out of the xml so that every time it is seen it is showing a different cycle of images. I'm not by any means an ActionScript expert far from it actually, but i understand a bit of it (not enough to write my own code yet).here is the code im using:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
[code]....
Also I'm not using the text version of this were it gives a title of the image that is displayed but every time i think i have removed it correctly i screw the the whole thing up. right now i just have the title area in my xml blank which works but i guess its not the cleanest code right.
View 9 Replies
Jul 11, 2006
I used the tutorial for making a xml gallery and changed it up a bit to make a banner ad gallery from an xml file. This makes life easier for my non flash designers to just update the xml file when new ads come out. I would now like to make it randomly select the first image.The only idea I had was to change the p = 0; part to p = Math.floor(Math.random() * total); That didn't work.There is some additional code in there for a coldfusion click tracker and some to build the url string for the coldfusion page
// Load XML, define arrays, and initiate loading of first image
function loadXML(loaded) {
if (loaded) {
[code]....
View 5 Replies
May 1, 2009
I've got an xml slideshow playing on my home page and I need to have the pictures randomized. You can see the flash in action at [URL]. Here is the code that I am using now.
delay = 10000;
// function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
[Code] .....
View 8 Replies
Feb 16, 2005
Basically, it loads and parses an external XML file. I have it set to just step through the file but I'd like it to randomly display the images referenced by the XML. The script works like this, but I can't seem to figure out how to get the XMl into an array and then have the function read it correctly. It seems to me that the call:
picture.loadMovie(image[p], 1);
with p being changed somehow to a call to myArray should work, but it doesn't. What am I doing wrong?
this creates the load XML function and counts the children to an array
function loadXML(loaded) {
if (loaded) {[code]....
so the XML needs to loaded into the array somehow. Here's the array with a bunch of numbers instead of the XML info.
myArray=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
myArray.Shuffle();
View 2 Replies
Feb 12, 2003
I have a mc (fStrip) which looks like a piece of filmstrip with thumbnail images in it. I want this mc to move when the users mouse is positioned over it, but I only want it to move only along it's x-axis and in a direction opposite that of the mouse. And I want it to move or flow smoothly.
I've been trying to figure this out (see my lame attempt below) but without much luck.
onClipEvent (mouseMove) {
buffer=20 //movement buffer
mousePos=_root.fStrip._xmouse //store mouse position
if (mymouse!=_root.fStrip._xmouse){ //if the mouse has moved
[Code].....
View 3 Replies
Jun 22, 2004
I wish to get the effect of ants scuttering across the screen or up a tree, I have not decided which direction yet. I started with the tutorial code for the snow effect from kirupa, and changed it around to fit the little vector ant I created. The way I have it now looks pretty good, but the movement is a little too fluid. They obviously move in sinusoidal paths bc the code tells them to. I have about 20 copies of the main obj, and they're all a little different in size and specs (speed, transparency, etc) but what I was wondering was if there is any way I can change the code to make it a little more hectic, or erratic, not so fluid. If there is no way of doing so, it looks pretty good right now. If there is, however, I think it could look awesome. here's the code I'm using for the object.
onClipEvent (load) {
//stage
movieWidth = 850;
movieHeight = 50;
[code]....
View 5 Replies
Feb 19, 2009
I am trying to build a simple image scroller in a way that it creates 2 arrays from 2 xml attributes. I got that working, but what I want to do next is randomize the order of the images and while making sure it they retain their specific urls. Then I want the scroller to loop those images in that random order infintely.
So far here is ActionScript Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
// change the values to alter the spacing and scroll speed
scrollSpeed = 1;
picSpacing = 0;
picWidth = 116;
[Code] .....
View 7 Replies
Oct 18, 2010
I have a file with several movie clips and I want every time swf loads the different movie clips plays.
View 2 Replies
Mar 5, 2011
I'm trying to build an application that displays randomly thumbnails in a grid, but having problems with the random part. I'm displaying the thumbs in grid like this:
[Code]....
View 4 Replies
Mar 5, 2011
I'm trying to build an application that displays randomly thumbnails in a grid, but having problems with the random part.I'm displaying the thumbs in grid like this:Code: Select all//building a thumbnail container for each one of the projects from the library
var thumbContainerMisc_mc:ThumbContainer = new ThumbContainer();
thumbContainerMisc_mc.x = (200+1) * x_counterMisc; //setting the thumbnail x
thumbContainerMisc_mc.y = (200+1) * y_counterMisc; //setting the thumbnail y
[code]....
View 1 Replies
Oct 18, 2006
I wanted to randomise my quiz questions and to allow all questions to appear but no similar questions should appear twice. I tried to use arrays to do it but I kept having errors.
View 8 Replies
Feb 19, 2009
I am trying to build a simple image scroller in a way that it creates 2 arrays from 2 xml attributes. I got that working, but what I want to do next is randomize the order of the images and while making sure it they retain their specific urls. Then I want the scroller to loop those images in that random order infintely. So far here is my code:
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
// change the values to alter the spacing and scroll speed
[code].....
View 1 Replies
Mar 4, 2009
I have 7 movieclips that form a line down the stage like so:
Movieclip 1
Movieclip 2
Movieclip 3
I need it so that when a button is pressed is randomizes the order in which they are shown for example it could be:
Movieclip 2
Movieclip 3
Movieclip 1
View 4 Replies
Sep 20, 2004
So I figured that the last idea I had would not work, but I realized that if I attached each seperate background image from an array to a css element that, that would indeed work.
View 1 Replies
Nov 22, 2011
I have a project in Flash Professional CS5 and ActionScript 3.
I have a movieclip symbol (referred herein as "background" with scripts on various keyframes inside of that symbol. I need to hide or show another symbol (referred herein as "object") sharing a stage with "background".
To put it another way, I need "object" to be hidden when "background" reaches a certain internal keyframe. However, as "object" and "background" are both children of the same stage, how do I do this?
View 1 Replies
Dec 25, 2004
what i want to do is, when certain button is clicked, replace a certain symbol(button) by another symbol(movieclip) stored in the library. i try things like loadmovie("","") to replace the symbol from a external jpg, but some how it does not align even both images are exact dimension. can i replace an image straight from the library?
View 1 Replies
Aug 5, 2011
I animated eyes blinking inside of a movie clip symbol and placed the symbol on a face outside of the symbol.The eyes are stuck on the first frame. I am using CS5. What do I do?
View 5 Replies
Sep 3, 2010
How do i get the hitTest() function to test if a certain symbol is hitting another symbol, but, only if drawn parts of the symbol are touching, not thier outer bounds.
View 2 Replies
May 16, 2011
Basically there's an object in a movieclip. I want to find the location of that object in relation to the movieclip, not of the object's symbol. So when i look at the x and y of it, it wont show 0, it will show the x and y location in the movieclip it's in.
View 2 Replies
Aug 30, 2010
A slideshow containing advertisements, randomized in a way that each ad gets the same chance at being the first one to show when the page gets opened. Or rather, not randomizing, but alternating between about 25 different ads, perhaps even more
View 5 Replies
Jan 9, 2012
I'm having an issue using randomizing the appearance of movie clips using Math.random. I have a movie clip in the library, which is 85 frames long but it begins and ends with 15 blank key frames. In other words, it has 2 layers, one for action script and one for graphics which are movie clips too, the AS layer is 85 frames long while the art layer is shorter and begins on frame 16.
I began by putting the movie clip on the stage, without any code on the main timeline, with some code on the movie clip's timeline -
this.x = Math.random()*stage.stageWidth;
this.y = Math.random()*stage.stageHeight;
In this case, tested the movie, the swf played just what I wanted, the movie clip "appears" randomely on the stage, plays, disappears, and reappears, and so on and so forth.
I then gave the movie clip on the stage an instance name of b_mc, removed the code in its timeline, and put it on the main timeline, as such -
b_mc.x = Math.random()*stage.stageWidth;
b_mc.y = Math.random()*stage.stageHeight;
In this case, the movie clip does NOT appear randomly on the stage when the swf is tested, rather, it appears at the same position, appearing and disappearing over and over as planned, but in the same place - NOT as planned.
View 7 Replies
Sep 3, 2009
I'm working on a services module (slideshow for lack of a better term) for an accounting firms website - site is still under construction at On the home page, far right hand column a grey box with a service icon and user controls progresses thru the five services until the user advances the slide manually.I need to randomize the starting point of the slide show using one of the five services. To complicate the matter further I need to weight them so some services show up more often than others. But randomizing with equal weight would at least be a start.
View 1 Replies
Apr 25, 2010
I am currently making a quiz game and have an XML file which stores all the questions/answers.I then load the xml, and put all of the info into multiple arrays.
ActionScript Code:
var x = new XML();
x.ignoreWhite = true;
x.load ("Stating The Obvious 2.xml")
[code]....
So, how would I edit the code to make the questions appear in a random order? i.e. Make the currentQuestionNumber be random while not repeating itself.Also, is it possible to make the answers appear in a random order on the screen? For example, instead of the "answer1array" element always appearing at the top and the "answer4array" element appearing at the bottom, is there a way to mix things up a bit?
View 0 Replies
Feb 9, 2012
I'm developing an iOS flashcard app in Flash CS5 for a school project. I've got over 600 scenes, and my cards are structured in pairs so that one scene is the front of the card and the next is the backside with the answer. I've figured out how to get from scene to scene, but have had no luck trying to find how to randomize scenes while keeping them in pairs
View 0 Replies
Mar 12, 2012
know if it is possible to randomize data that is imported from a .CSV file so that it displays as dynamic text in Flash?Or if there might be a thread I could be pointed to? I'm creating a Flash program that can display "flash cards" with terms and their definitionsThe terms and definitions are in their own columns of the .CSV file.Currently, I can display in the dynamic text the data from each column (term and definition), however if I call them particularly. I was wondering if there was a way for me to do this randomly?
View 2 Replies