Is There A More Efficient Way To Define A Variable Based On A Random Number?
When my flash document loads, I have a target_mc to which I attachMovie a movieClip called start_mc. The _action layer of start_mc in frame 1 looks like this:
var randomNumber:Number = random(3);
if (randomNumber == 0) {
var imageName:String = "acrylic"
trace(imageName);
}
if (randomNumber == 1) {
var imageName:String = "early"
trace(imageName);
}
if (randomNumber == 2) {
var imageName:String = "mixed"
trace(imageName);
}
if (randomNumber == 3) {
var imageName:String = "monotypes"
trace(imageName);
}
Also defined in frame one is a fade for a loadMovie(image.jpg) where the path to the image is defined by the value in the above variable imageName.
loadMovie("../images/" + imageName + ".jpg")
The end result? Of 4 image sub folders nested inside /images/, each represented by the type of artwork (acrylic, monotypes, mixed, early) I want the initial screen that is seen to attach a movie that loads random images from those folders, fades them in and out, and simply waits for user input on one of the menu selections on the left.
My current progress is located at http://www.laceyart.com.
FlashKit > Flash Help > Flash ActionScript
Posted on: 11-22-2006, 07:41 PM
View Complete Forum Thread with Replies
Sponsored Links:
Define Images To Load Into SWF Based On Variable
Put simply, I have some nav buttons, which when clicked load an external SWF into an empty movieclip instance called 'image_dummy'.
At the moment my external SWF consists of one frame showing an image.
However (this is where it gets tricky), I would like it to contain more than one frame, with an image on each frame and a 'more' button to move between the frames. But, I want it to be populated dynamically based on a variable(s?) passed to it when the button is clicked. For example, the first button when clicked may load my SWF file with 3 images and a more button to flick between them but, the second button when clicked may load my SWF file with 5 images and a more button to flick between them. I would also like the more button to not be there if there is only 1 image, but that is probably another question entirely. Phew!
Can anyone help? Any suggestions would be gratefully received.
View Replies !
View Related
Random Number Variable That's Different From Previous Number
I have this line of code in my game that works great. However it would work even better if when it the code was executed the next random number was not the same as the one before it. For example if "speech" is on frame 6 when the code is executed I would like the random number to be between 2 and 12 but not 6. (I don't want the same frame to come up as it confuses the kindergarteners and preschoolers using the program.) Here's the code that's working for me now.
ActionScript Code:
speech.gotoAndStop(Math.floor(Math.random()*11)+2);
View Replies !
View Related
Random Number Using A Variable
Hello Folks,
I'm trying to generate a random number. I want the limit of the random number generated to be defined by a variable. For some reason I just can't get this to work.
here's the code I've been using:
test = Math.floor(Math.random()*_root.number)+1
_root.number is the variable and movie recognises it everywhere except in this code. Any help would be greatly appreciated.
View Replies !
View Related
Define To Play Number Of Frames From The Specified Frame In A Movie
For Example,
I have play from frame Number 40 to Frame number 50. At the same time it has to jump & play from frame 70 to 100.
I may use label for the frame number 40 & 70.
Right now what i have tried is put a action as stop at 50th frame and also 100th frame
_root.gotoAndPlay(40);
_root.gotoAndPlay(70);
It works only once and it stops at 50th frame itself, because i have given stop action at 50th frame...
Hope you understand my question,
Thanks, Bala
View Replies !
View Related
Choosing A Random Number (that Isn't The Current Random Number).
I have a loader movie, that randomly chooses a clip to load from an xml list. Sometimes it 'randomly' chooses the same number which makes it look like the loaded clip is mistakenly looping (skipping). Here's the code:
Actionscript Code:
function randomImage() {
if (loaded == filesize) {
fadingPeople._alpha = 0;
numberSelected = random(total);
fadingPeople.loadMovie(image[numberSelected], 1);
}
}
The code runs, waits for x seconds and then fire again. What I'm wondering about is how would I go about telling the random function to choose a random number that's NEQ numberSelected.
Thanks for any help.
View Replies !
View Related
Random Number Then Delete Number Till Reset
Last edited by pixcels : 2006-10-18 at 22:41.
I am trying to create a type of quiz thing. It is a stand alone move and can not have anything loaded into it.
Problem:
I need a random item from an array, then after the item is displayed I need it to delete itself so that it will not show again. After the array is down to the last item it calls in the array again and starts all over.
Below is code that I have found but it does not delete the array item after it has been show from the array, or restart.
Code:
Array.prototype.shuffle = function() {
var shuffledArray = [];
var copyArray = this.slice(0);
for (var j = 0; j<this.length; j++) {
randomNo = Math.floor(Math.random()*copyArray.length);
shuffledArray[j] = copyArray[randomNo];
copyArray.splice(randomNo, 1);
}
return shuffledArray;
};
testArray = ["1", "2", "3", "4", "5", "6", "7"];
newArray = testArray.shuffle();
//Text area component
theText.text = "newArray = "+newArray
//Button component
theBtn.onRelease = function(){
newArray = testArray.shuffle();
var tempArray = Math.floor(Math.random()*testArray.length)
var totalArray = Math.floor(tempArray+=newArray[0])
var slicedArrary = tempArray.splice(0)
theText.text = "newArray = "+newArray[0]
}
View Replies !
View Related
How To Define A Global Variable?
How do I make a variable global? In the following code, the value of MyText is lost after the function:
Code:
var MyText;
TextLoad = new loadVars();
TextLoad.load('Text.txt');
TextLoad.onLoad = function (success)
{
if (success == true)
{
MyText = unescape(TextLoad);
}
}
trace(MyText);
View Replies !
View Related
Define Variable And Use It As A Target
With a button I define a variable, this variable will later be called as a target. I think I am doing it right, but apparently not. Otherwise I won't be here
so basically this is what I do:
ActionScript Code:
on (press){
_root.myVar = "B2";
}
// I have an MC on stage that is also called B2
// so i thought:
on (press){
_root[myVar].gotoAndPlay("something");
}
so is the syntax correct?
I tried a trace on (_root[myVar]) but that gives me a cool "undefined"
Anyways... hope you can help!
Cheeers
View Replies !
View Related
Define Variable, String Or Boolean
in reference to my previous post (Urgent, genuine question! multiple ifs)
if i defined the position of drag 2 and defined the hitest as a variable, string or boolean could i then just group it into:
if (drag2Pos && drag1Loc) {
setProperty(this, _x, 308.9);
setProperty(this, _y, 175.8);
setProperty("/textbox", _alpha, "0");
} else {
setProperty(this, _x, 663.9);
setProperty(this, _y, 325);
setProperty("/textbox", _alpha, "100");
}
would that be possible, and if so, which one?
View Replies !
View Related
Serious Call For HELP How To Define And Use Global Variable ?
I have problems using variables and my global variables dont seem to work.
Can anyone tell me how to define a global variable so that different movie clips can use it ? And, how to use global variables ?
I have read some other threads on the same problem but I still dont understand.
please explain it with the simplest way because i am a newbie at action script. Thanks!!
View Replies !
View Related
Help: Using URL Variable To Define Rollover State
Simple question:
I am trying to build a simple menu using Flash MX to be used in a normal HTML page using GoLive.
Click button on menu, and get taken to a new html page (that also uses same flash menu). I have this part working.
-------------------------
What I need help with is how to make the rollover for the button that was clicked (active page) stay in it's down state, which would indicate to the user what page he is on.
Scenario, you click on Button-1 (B1) to go to Page-1.html (P1).
Once on P1, I want B1 to be stuck in it's down state which would indicate to the user that they are on P1. On P2 I want B2 to be stuck in it's down state.....and so on.
-------------------------
Below is the code I used below to get the rollovers to link to pages.
----code begin----
on (release) {getURL('http://www.____.com/P1.html')
----code end----
How do I get the rollovers to remain 'down'?
B1 to remain down if user is on P1.html
B2 to remain down if user is on P2.html
B3 to remain down if user is on P3.html
Thanks for any help you can provide.
e3_e3
View Replies !
View Related
Use External PHP Or TXT To Define A Variable Used By LoadMovie
Can I define a variable using external file PHP or TXT and use the loadMovie ActionScript. I want to use an external file to tell my main movie which SWF file to load and play. I thought it would be pretty simple but of course I may be completely crazy to think it is simple. I hope someone can take a look at my code and let me know if I am almost there or if this is much more complex than I think. Thank you much in advance.
Here is my AS:
stop();
dataLoad = new LoadVars();
dataLoad.onLoad = function () {
moviename = this.video
};
dataLoad.load("links.txt");
this.mc_movie.loadMovie("moviename");
Here is my txt:
video=movie.swf
View Replies !
View Related
Using String Variable To Define Object
Hey guys,
im having trouble getting this code to work. I would really appreciate any help you can provide as its the only thing holding me back from finishing my project :-). what im doing is creating a map where when you click on a state, it brings up all the locations we have within that state. the locations for each state are within an xml file.
the file has the following structure. it is just a list of locations within different states. i used the each state's two letter code for the structure.
ActionScript Code:
<venuelist>
<mi>
<name></name>
<address></address>
<city></city>
</mi>
<mi>
<name></name>
<address></address>
<city></city>
</mi>
<ma>
<name></name>
<address></address>
<city></city>
</ma>
</venuelist>
here is the result handler. right now it is set so that it always grabs the locations from michigan
ActionScript Code:
public function resultHandler(event:ResultEvent):void {
var arrvar:Object = event.result.venuelist.mi;
arrcol = arrvar as ArrayCollection;
dg.dataProvider = arrcol;
}
in my flex, i have a http service calling the xml file and assigning the entire xml collection to a variable. and then having it assigned as the dataprovider for my datagrid. when you click on a state, it creates a pop up with the data grid. i also have an alert that shows the two letter state code you click on
ActionScript Code:
public function createPopUp(event:USAMapEvent):void {
var stateSelected:String = event.code;
Alert.show(stateSelected, 'Alert Box', mx.controls.Alert.OK);
PopUpManager.addPopUp(panel, this, true);
PopUpManager.centerPopUp(panel);
}
what i need to do is set the dataprovider for the datagrid to something like dg.dataProvider = arrcoll + stateSelected so that it will go to "
"venuelist.stateSelected". what is the proper way to do this. any help is appreciated!
View Replies !
View Related
Define Variable On Root From Child
I have a loader which loads external swfs. From the external swfs, I need to define the variable of the loader as "somemovie.swf" or whatever so it will load the appropriate movie.
Here is the loader on the root:
Code:
var loadMovie:Loader = new Loader();
function addALoader(someURL:String):void{
loadMovie = new Loader();
loadMovie.addEventListener(Event.COMPLETE, onLoadComplete);
loadMovie.load(new URLRequest(someURL));
}
function removeALoader():void{
loadMovie.removeEventListener(Event.COMPLETE, onLoadComplete);
container.removeChild(loadMovie);
}
function onLoadComplete(e:Event):void{
loadMovie.removeEventListener(Event.COMPLETE, onLoadComplete);
container.addChild(loadMovie);
}
How would you program 5 buttons on a child swf to use this same loader to load 5 different movies into the root?
(Thanks to MaskedMan for getting me this far!)
View Replies !
View Related
Using A Variable To Help Define A Target Path?
I have 5 movieclips which serve as 5 separate countdown timers. They are simply named "timer1", timer2", "timer3", etc. I also have an input device movieclip (looks like a calculator) which allows the user to set each timer depending upon which one is currently chosen at the time. The user sets the time on the calculator, presses a "submit" button, and the information is sent to the appropriate timer where the countdown is begun. To streamline the code I am wondering if it is possible to inject a variable into a target path in order to direct the time to the appropriate timer.
for example:
If timer1 is chosen, the variable "activeTimer=1". With timer2 chosen, "activeTimer=2", etc.
Is there a way to do something like this and make it work:
Code:
_root.timer["activeTimer"].gotoAndPlay("start");
This way I don't have to copy and paste the submit button's code 5 times using if statements.
Thank you for time,
Nate
View Replies !
View Related
Define Variable On Root From Child
I have a loader which loads external swfs. From the external swfs, I need to define the variable of the loader as "somemovie.swf" or whatever so it will load the appropriate movie.
Here is the loader on the root:
Code:
var loadMovie:Loader = new Loader();
function addALoader(someURL:String):void{
loadMovie = new Loader();
loadMovie.addEventListener(Event.COMPLETE, onLoadComplete);
loadMovie.load(new URLRequest(someURL));
}
function removeALoader():void{
loadMovie.removeEventListener(Event.COMPLETE, onLoadComplete);
container.removeChild(loadMovie);
}
function onLoadComplete(e:Event):void{
loadMovie.removeEventListener(Event.COMPLETE, onLoadComplete);
container.addChild(loadMovie);
}
How would you program 5 buttons on a child swf to use this same loader to load 5 different movies into the root?
View Replies !
View Related
Basic Define Variable Code Won't Work
hi.
this is very odd. i took a 3-day actionscript workshop. we used the same one-line method of declaring and assigning a String/Number/Boolean/etc instance many many times. now i am on my home computer and trying to review the basics. the basic code (STRAIGHT OUT OF THE BOOK) is not working! i have tried variations of the same type of declaration by grabbing code from the macromedia sample tutorials and same problem. both the computer that i was using at the workshop and my home computer have Flash 8. the only difference i can think of is the class had a PC, whereas i use a mac at home. i am totally baffled. if anyone has any insight, i'd be very appreciative.
my code...
var userName:String = "fred";
trace(userName);
returns undefined.
on the other hand, this 2-line method of declaring/assigning does work for me on my mac:
var userName:String;
userName = "fred";
trace(userName);
merry christmas btw :)
View Replies !
View Related
How I Can Define A Variable That Is Manipulated From The Clip Parameters Panel That I
here' the question...How i can define a variable that is manipulated from the Clip Parameters panel that is related to a Target Path? example: I have a movie clip that i replicated several times on the main timeline. I want each of the to trigger different events outside them [make other clips play, jump to keyframes, etc] only whenh specific keyframes of their timeline are read. I ve put an action _root.myclip1234.play(); on specific frames of the movie clip then transfromed it into a smart clip with a variable name as myclip1234 then drag onto the stage duplicated the smart clips, and changed the myclip1234 variable from the Clip Parameter panel for each of them with some different instance names that i ve put onto the stage [ie projects, contact, etc]..It does not work..Is not possible to replace a path part with a changable variable? [ myclip1234 in this case works as a variable]
thanks wasily
View Replies !
View Related
Load Variable From Text File To Define Location
I'm trying to set variables in my MC something like this:
// this is on frame2
var dirLocate = "emb/emb/";
var fileName = "1.jpg";
loadMovieNum(dirLocate+fileName, 1);
I want the dirLocate variables value to be "dirloc1=emb/emb/" loaded from an external text file. (the txt files detail will change depending on where the swf is loaded from)
// this is is the external file loaded on frame1)
loadVariablesNum("dirloc.txt", 0);
It is driving me mad, I cant seem to figure it out. I've created a dynamic text box and linked the dirloc1 VAR to it, the information shows ok in the text box, but I can't seem to be able to use that data as the value of the variable. What am I doing wrong??? Any ideas
Ragards
View Replies !
View Related
How To Define A Variable On The Root From Inside A Movie Clip
Hi
I want to define a variable on the root from inside a movie clip, so that when I save a value in it I can reach it from another movie clip, if this is not possible, what should I do to declare a public value that can be accessed by any movie clip on the stage but without using the main time line?
I hope if you have an answer, to write a definition code example with your answer.
thanks a lot.
View Replies !
View Related
How To Define A Variable On The Root From Inside A Movie Clip
Hi
I want to define a variable on the root from inside a movie clip, so that when I save a value in it I can reach it from another movie clip, if this is not possible, what should I do to declare a public value that can be accessed by any movie clip on the stage but without using the main timeline?
I hope if you have an answer, to write a deifinition code example with your answer.
thanks alot.
View Replies !
View Related
Number Based Tiles....help..
OK heres the problem,
i am trying to make a simple game where there are a selection of tiles which turn over to reveal part of a photo if the 2 numbers inside them add up to the same value...
for example, if the user click on the tile with "2+2" in it, that tile's outline becomes a different colour (to show it has been highlighted)- if the user then clicks on the a tile which has "3+1" in it, then both tiles flip over to reveal part of a photo..(because the insides of both tiles adds up to 4...)
WHAT WOULD BE THE BEST WAY FOR ME TO GO ABOUT THIS ?????
> Will I need to use buttons or Movieclips for the tiles???
> How will i get the tiles to randomly shuffle position so they are in a different position everytime the game is played????
YOUR FEEDBACK WILL BE APPRECIATED GREATLY.....
View Replies !
View Related
Loadmovie Based On Number Of Clicks
I think this should be fairly simple, but I can't crack it.
I want to load one of 3 movies based on whether this menu button is being clicked for the first, second or third time. I created a dynamic textfield to store the counter variable, but it increments fine until I add the if/thens.
on (release) {
countflag=countflag+1
if (countflag=1) {
loadMovie("page-flags1.swf", "mcinv");
} else if (countflag=2) {
loadMovie("page-flags2.swf", "mcinv");
} else if (countflag=3) {
loadMovie("page-flags3.swf", "mcinv");
countflag=0
}
}
Help?
PS: I'm a bit out of my depth here, so if in addition to the counter, there's a reason this won't work, please explain in small words with powerpoint and/or handpuppets.
View Replies !
View Related
Making A Moving Bar Based On Number?
Hi there,
I'm want to make a little bar, that when the movie clip is loaded, it will
"load" to a specific percentage......well, really "fill in width".
I'm trying my best to not confuse this with a loading/preloader bar, cause
it's not what i want - here's what im thinking:
I have an outline (rectangle) which has a black outline- i want to be able
to set a number in a variable some where in this small mc, which will fill
my outline with the bar based on a percentage.......im making this sound
alot more complicated than i think it is!
So, if i set the variable to 70% - i want my little bar, to fill with a
colour, over 1 second of time, 70% filled - make any sense?
Thanks for any help,
Neil
View Replies !
View Related
Declaring An Array Based On Number Of ChildNodes In XML
I want to change the static array:
var aFrameLabels:Array = new Array("Q1", "Q2", "Q3", "Q4", "Q5", "Q6");
..to one that would be dynamic, based on the number of childNodes present in the XML file. Can anyone tell me how to get the following variable OUTSIDE the function...i assume it would be using "return" but I cant figure out the syntax!
This is the line I have INSIDE my xml.onLoad function that gives me partly the data I am looking for...
var xmlTotalQuestions = xnRoot.childNodes.length;
View Replies !
View Related
Making A Number Based Lottery Generator
I'm trying to work out how i can do this with 3 different text boxes and number generator encoded boxes. I need some extra solution to this, as every time i do it, the same numbers are generated each time by all 3 boxes, which is what i don't want to happen.
Thanks
View Replies !
View Related
Define Variable With Variable
Working in Flash 5 - My main objective is to tell a clip the value of a variable, the following is how I am trying but I am open to suggestions on the proper way of doing this if there is one.
This works:
tellTarget ("_level0.instance1.instance2") {name1 = "MrKicks"}
This does not but it is what I am trying for:
Name = "MrKicks"
tellTarget ("_level0.instance1.instance2") {name1 = name}
The var name is declared early in the movie, I now need to get that to instance2.
Thanks,
MrKicks
View Replies !
View Related
Variable Number = Frame Number#$%@&*
I have a movie Clip called “percentage bar” and a variable text box called “percentage”.
Now I get a number from VB and this number is = to the value of ”percentage” (my variable txt box).
The Movie Clip has a 100 frames… here it comes I need to have whatever the variable number (“percentage”) is to determine which frame the movie clip (“percentage bar”) is standing on.
This has to be possible, don’t it?
View Replies !
View Related
Variable Number = Frame Number ?
Here's an easy one for anyone who knows actionscript...
I have a variable text box called "percentage" and a movieClip called "progressbar" (100 frames).
I want the number in my variable txt box "percentage" to tell "progressbar" to go to the corresponding frame number.
for instance if the number in the txt box is 15 the movieclip has to go to frame 15.
Thanks
- a Designer, forced to be a programmer.
View Replies !
View Related
Calculation Expiration Date Based On Number Of Months
Hi, in need of some help, I know how to get the current date, but I'm working on an app by which user accounts expire based on payment options, semiannualy, annually for example. How would I go about this. Like if a user registers and account on December 12, 2004, how can I accurately calculate the date 3,6,12,24 months from then. Thanks alot
View Replies !
View Related
Hide Forward/next Button Based On Number Of Pages
Hello,
I've built an e-commerce site that dynamically loads products on the page from a db using php and then I have a script to move the y of this loader by a certain number of pixels to display the next. (They show 6 on the screen at a time).
I know how to hide and show items on the screen and I'm wodering if there is a simple way after knowing the total numbe of products "num" to automatically call on a function to see if the back or forward button should dissapear.
I've got this going on right now
ActionScript Code:
if (page == "1") {
backtext._visible = false;
backarrow._visible = false;
backbttn._visible = false;
if (num < 7) {
ffrwrdtext._visible = false;
frwrdarrow._visible = false;
frwrdbttn._visible = false;
} else {
ffrwrdtext._visible = true;
frwrdarrow._visible = true;
frwrdbttn._visible = true;
}
}
I can keep doing this checking for each page however their is a page with over 120 products and this could get a little lengthy. On each button click I am adding 1 or subtracting 1 from the variable "page"
I know my way will work but I'm curios to find a simpler solution and expand my scripting.
Thanks in advance for any help.
View Replies !
View Related
Using A Button To Advance A Movieclip To An Expression Based Frame Number
Can anyone help, I'm working on a simple thumbnail viewer using flash, and images stored in a movieclip, called "thumbs" and placed on the stage with an instance name of "slideshow1" to make life easier than manually coding the seperate thumbnails as seperate symbols.
e.g.
Movie clip called "thumbs"
image1 on frame1
image2 on frame2
image3 on frame3
ad infinitum
This is then triggered by thumbnails which make the "image" go to the frame that you click on.
for 6 thumbnails - hence the *6 in the code below
on the first thumbnail I have the following actions
on (release) {
var currentthumbnail=int((thumbset-1)*6+1);
tellTarget ("slideshow1") {
gotoAndStop ("currentthumbnail");
var debug="tell target initiated";
}
}
on the second
on (release) {
var currentthumbnail=int((thumbset-1)*6+2);
tellTarget ("slideshow1") {
gotoAndStop ("currentthumbnail");
var debug="tell target initiated";
}
}
etc...
Nothing happens... but if I change the "GotoAndStop" from an expression into a "frame number" such as (1) or (2) it works, but obviously the variable functionality works, and the last thing I want to do is manually set different flash scenes or frames showing diffenet pages of thumbnails, the idea is to use buttons to show sets of thumbnails at a time.
View Replies !
View Related
Dispaly Clickable Buttons Based On Number Of Similar Nodes In An XML File?
I have a flash gallery (that works ok as it is) however I'd like to upgrade it a bit and I'm stumped.
Right now there is a single image for each portfolio item pulled from an XML file. Some portfolio items however have more than 1 image. Some have 2 and a few have up to 4 or 5.
How can flash automatically see how many similar nodes there are within a set and then display a clickable "1, 2, 3, etc" button below the image to view each photo or if there is only 1 photo, no numbers will appear at all?
Thanks!
Neil
They will use a format similar as shown below. Notice how the first one only has 1 image and the second has 3 image nodes.
Code:
<images>
<pic>
<image>images/web/dictaphone.jpg</image>
<description>Description: Working with the Dictaphone marketing department worked on a complete overhaul of the entire Dictaphone website.</description>
<thumbnail>images/web/dictaphone_s.jpg</thumbnail>
<sectitle>Web</sectitle>
<client>Client: Dictaphone Corporation</client>
<project>Project: Company Website</project>
</pic>
<pic>
<image>images/web/upstart1.jpg</image>
<image>images/web/upstart2.jpg</image>
<image>images/web/upstart3.jpg</image>
<description>Description: Creation of the new Upstart Training website and formulation of entirely new corporate branding.</description>
<thumbnail>images/web/upstart_s.jpg</thumbnail>
<sectitle>Web</sectitle>
<client>Client: Upstart Training</client>
<project>Project: Website</project>
</pic>
</images>
View Replies !
View Related
Random Mc Based On Array?
I'm trying to create a basic app where you shoot MCs moving at random. That part works but I'm not sure how I can call an Array at random instead of keeping to the basic shape I'm using now, would be fun with a bit of difference..
Any idea how I could achieve that usig the below code?
Code:
var i;
// get sound
var gunfire = new Sound();
gunfire.attachSound("gunfire");
_root.hit1.onPress = function() {
gunfire.start();
i++;
_root.bull.duplicateMovieClip("bulletNew", i);
if (i == 10) {
i = 0;
}
// hit test on target
if (_root.target_mc.hitTest(_root._xmouse, _root._ymouse, false)) {
_root.gun.gotoAndPlay(2);
_root.target_mc._x = 0;
_root.target_mc._y = random(300);
_root["bulletNew"+x].removeMovieClip();
}
};
// initialise stuff
_root.onLoad = function() {
// hide the mouse
Mouse.hide();
};
//loop
_root.onEnterFrame = function() {
//put cross hairs to mouse coords
_root.gun._x = _root._xmouse;
_root.gun._y = _root._ymouse;
// target move
_root.target_mc._x += 10;
if (_root.target_mc._x<0 || _root.target_mc._x>Stage.width) {
_root.target_mc._x = 0;
_root.target_mc._y = random(300);
}
};
Appreciate any kind suggestions!!!
Yossi
View Replies !
View Related
Help: Looking For XML-Based Quiz (Random)
I'm looking for advice for direction. I need to put together a Flash quiz for a course. The questions need to be randomly selected from an XML file. As of right now, I only need multiple choice and true/false. And obviously, I need score tracking.
Can anyone make a recommendation on how to move forward? Anything already existing out there? Thank you for your advice!
View Replies !
View Related
Random Number
Hi,
I am new to actionscript and am just hoping tbat one of you more experienced user could help me out on this one.
I am trying to get a random number betweeb 1 & 9, does anyone know how to do that?
I know the random() function has been dropped in Flash 5, is there a replacement to that?
Thanks
View Replies !
View Related
Random Number
People please help me.
I have this code:
var back = background.getBounds(_root);
minx = back.xmin;
miny = back.ymin;
maxy = back.ymax;
maxx = back.xmax;
function getUniqueRandom (number) {
var numberlist = new array();
for (count=1; count<=number; count++) {
numberlist[count] = count;
this.randomlist = new array();
for (count=numberlist.length-1; count>0; count--) {
picked = math.floor(math.Random()*count)+1;
if (picked<=maxx & picked<=maxy & picked>=miny & picked>=minx) {
this.randomlist[count-1] = numberlist[picked];
numberlist[picked] = numberlist[count];
} else {
//here i want to reset what i did above and get another numbercount+1;
}
}
}
return randomlist;
}
x = new getUniqueRandom(36);
stop ();
What i try to do is it genrates a unique number that is not duplicated. Ok this works fine, my problem is , I have 4 conditions that this random number must meet, if it doesn't meet it, it must choose another one, something is not right wiht my if statement....
Please help... Thanx in advance..
View Replies !
View Related
Random Number
Ok this shoulndt be that hard but i cant find anything to tell me how to create random numbers. I want a random number to apper then if n==1 goto lable 'One'. So how do i do random numbers?
Twister
View Replies !
View Related
|