How To Select A Random Object In A For Function?
Hi. I have this for function:
for (i=1; i<=10; i++){ attachedObj = theScene.attachMovie("star"+String(i), "star"+String(i), theScene.depth + String(i)); attachedObj.x = 450 - Math.random()*500; attachedObj.y = 0; attachedObj.z = i*500;
attachedObj.onPress = selectStar; attachedObj.display = displayStar;
objectsInScene.push(attachedObj, attachedObjText); }
and some movement function that relates to it:
selectStar = function(){ cameraView.target.x = this.x; cameraView.target.y = this.y; cameraView.target.z = this.z; }
How do I make this work without having to use onPress? It should randomly select one of the objects in the for function and move it to the new location. Please give me a hand on this one.
Thanks.
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 12-19-2006, 09:37 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Select Each Random Value Only Once
Hi,
I have used a script that randomly shows names from a text file. How do I make it so that each name only shows once, until all have shown (then start again), but still keeping them in a random order?
The code is as follows:
Code:
/****************************************
**Random Quotes Script*******************
****************************************/
ranQuote = new LoadVars();
ranQuote.onLoad = function(success) {
if (success) {
RanNum = Math.ceil(Math.random()*406);
ran = this["quote"+RanNum];
quote_txt.text = ran;
}
else {
quote_txt.text = "Error Loading Data";
}
}
ranQuote.load("Names_File.txt");
Thanks
Select Only One Object MC
hi,
how can i make it so that the viewer can only click on one object MC and not multiple ones. When the click the MC, i have a function that happens, but i only want one MC able to be selected at once, not all of them.
so, if one is clicked, then another is clicked.. it needs to reset the first one etc.
hopefully this explains clear enough the concept.
any help is appreciated, im fairly new to actionscripting and programming in general.
thanks
z
Select Random Music
I have a music bar with 8 diiferent tracks. When it loads i want it to play a random track from 1-8. take a lookhttp://www.gionex.co.uk.
All i want is it to start of when it loads. No complex changing track, only a piece of action script in the frist frame to select a random track! Thanks!
Select Random Array.
Ok so I'm working on a portfolio for my personal site. I'm going to have it run off of a php backend so I can update it from my control panel I made. Well anyways. I have a rough draft going and it's working ok so far. When it loads in the text file it displays the buttons like it is supposed to ok. But what I'd like to do is have it so once all the buttons are loaded in it automatically selects one randomly from the list and displays the content. Rather than keep it blank til someone clicks a button. Catch what I'm saying?
Thanks a ton and I hope someone can help/direct me in the right direction.
Evan
Select And Show Mc At Random
Im trying to have one of two MCs show at random.
Anyone see whats wrong with my script?
The instance names are face_1 and face_2
Code:
face_1._alpha=0;
face_2._alpha=0;
stop();
/* select a random face pic from the ones available */
rand=Math.random();
trace(rand);
if (rand<=0.5){
shw=2;
}
else {
shw=1;
};
unhide=['face_'+shw];
trace(unhide);
unhide._alpha=100;
thanks
<added> FLASH MX</added>
Random Select On Refresh
I have a flash movie that I will be placing in a web site. The movie will contain interesting factoids. I want the movie to select a different fact everytime the web page is refreshed. Any tuts or examples on how this can be done?
FMX - Random Keyframe Select
Hello all, i think i may have a challenge for you. I would like to have a flash movie load to a random keyframe in a timeline when the page loads.
Basically, i'd like to set up a timeline with say 10 movies. When the page loads, i'd like the flash to randomly select from some predetermined keyframes (obviously where each movie starts) and when that movie ends, jump to another section of the timeline. This way, the loading of the movies is somewhat seamless and it looks like i've made 10 different flash movies.
Even if it's not possible to all load from the same timeline, i'd like to have it play the first movie, then when it reaches an ending frame, it loads another random movie from a directory on the server, and then keeps going and going until it can't stand it anymore.
Any suggestions?
FMX - Random Keyframe Select
Hello all, i think i may have a challenge for you. I would like to have a flash movie load to a random keyframe in a timeline when the page loads.
Basically, i'd like to set up a timeline with say 10 movies. When the page loads, i'd like the flash to randomly select from some predetermined keyframes (obviously where each movie starts) and when that movie ends, jump to another section of the timeline. This way, the loading of the movies is somewhat seamless and it looks like i've made 10 different flash movies.
Even if it's not possible to all load from the same timeline, i'd like to have it play the first movie, then when it reaches an ending frame, it loads another random movie from a directory on the server, and then keeps going and going until it can't stand it anymore.
Any suggestions?
Using Draw To Select An Object
Is it possible to use the actionscript draw function to then be able to circle round something with the mouse to select it.
So there would be a few options and then the user draws a circle around the object they want to use.
Im thinking that it may be possible to use the ontarget feature of drag and drop so that the new movie clip created gets filled with a transparent fill and the movie clip below detects that the new movie is on top.
Any ideas or suggestions?
Thanks
ds
Select Object, Not Container
I load a non-square image with transparency in a Bitmap->BitmapData and then add this in a MovieClip to allow the use of drag/drop.
But the MOUSE_DOWN select the "square" that contain the image.
I want that the drag starts when with the mouse you click on the image, not on the square that wrap the image.
Select Random From Load Movie ?
hi all i have a small banar in my site and i have also 30 swf file for my products
how can i write an action to select randomly from 30 swf file with loadmovei function
the files name are : p1.swf - to - p30.swf
thx alot
Select An Image At Random And Ask A Question - Please Help
Hi people,
My first time here and i was wondering if you could help me.
I am trying to build a simple flash game and was wondering if you flash guru's could help me.
I would like to be able to pick 1 of 8 images in the library at random and display it on the canvas. Once the image has been displayed i would like 3 symbols to be displayed underneath. 1 is correct and 2 are in-correct.
Get the symbol right first time and it's worth 3 points get it right second time 2 points and 3rd time 1 point. So the less accurate you are with your answer the less points you get.
Once the right symbol has been chosen it adds the points to a score total sheet and then selects another random image out of the remaining 7 images.
Once all the images have been used up it gives your final score!
Of course i appreciate that you people arnt going to give me a finished game but i would appreciate some pointers to help me build it myself.
I'm stuck on the random images selection from library expecially and also that need to take away answered questions from the images list. Any help on this would be fantastic.
Thank you in advance
How To Do This Effect> Random Text Select ?
Hello ,
Sorry for a asking question again but i love want to learn flash , so here is >>
how to do randmon outputs of words till rights words matches the name , like this site >>
http://www.flipmo.co.uk/v2.html << Click on Contact , then you'll know what i am asking << this site is really to cool
Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Force Select Of Input Object...
Hey everyone! First post on the forums here. I guess you could say I'm a "long time listener first time caller", but that's just in the radio sence. This seems like a great place and I hope to learn a lot from everyone here.
For my first question: Let's say you have a contact form with some button outside it. Is there a way where if they hit the button, it selects the input text field? Sort of a way to force the user to select the feild? And if so, is there a way to make it select it at the end of the strand that's already in the field, if there is any?
Thanks a lot,
Jake
Select Random Container Mc And Attach Mc From Library
Hi
Can anyone tell me why this doesn't want to work... the attachMovie bit...i can't seem to attach the movie to the empty clip which is determined randomly...
emptyArray = new Array ();
emptyArray[0] = "empty1";
emptyArray[1] = "empty2";
emptyArray[2] = "empty3";
emptyArray[3] = "empty4";
emptyArray[4] = "empty5";
emptyArray[5] = "empty6";
function randomDotAttach(){
mc = Math.floor(Math.random() * 6);
emptyArray[mc].attachMovie("circle", "circlenew", i);
}
Thanks very much.
setInterval(randomDotAttach, 30);
On Load Random Scene Select .flash MX.
Hi all,
need a script to randomly select a scene within in a flash file:
Got a 3 scene animation that loops, i would like to make a script that randomly selects which scene to begin with when the movieclip loads, and then the file plays through the scenes in normal fashion.
Any help will be amazingly appreciated!
Thanks.
How Can I Get The Browser To Select Header Images At Random?
Hi all,
Thank you for the interest in my post.
I have a series of different header images on all the pages of my HTML website. What I want to do though is to make the browser or whatever select these images at random from the folder they are stored in.
An example of what I mean is the main header images on http://www.franchitti.com but that is using CFM I think.
I know this is possible in Flash (but yet again don't know how to do it) but is it possible using Dreamweaver MX 2004 and if so, please could you point me to a tutorial or let me know how it's done.
Thank you very much and I hope to hear from you.
Take care,
Mark
How To Select Pixels From A Bitmap Data Object ?
Is there a way to select the pixels (or a Rectangle) say from (0, 0) to (100,100) from a BitmapData instance? Or to create a Bitmap instance where its bitmapData is a cropped section of another BitmapData instance?
I just dont know which methods to use from these two classes to achieve this... Any ideas?
thanks guys!
Message Select Function... Help Me Please...
Hi,I am making an interactive message device, which has messages that can be selected and deselected by clicking on a button called select.
I have created a Movieclip (called Asterix) with 2 frames: Frame1 = Blank keyframe Frame2 = *
I have used this script to make the messages select or deselect
on (press) {
if (a=!a) {
Asterix.gotoAndStop(2);
} else {
Asterix.gotoAndStop(1);
}
}
All above works so far.
The problem I have now... If I select a message which is on frame 1 then go to the second message in frame 2 and select it. When I return to previous message/frame it is no longer selected.
How can I make messages stay selected when moving back and forward thru the frames and also if I change scenes?
Each Message is in a frame from 1-5. Basically, I want to be able to select or deselect messages in any order across frames and scenes.
E.G. Message1*
Message2
Message3*
Message4*
Message5
Hope this makes sense if not, I can email an example.
Cheers
Using A Variable To Select A Function
Hi there.
I am looking to use a variable that is set when a user clicks a button to then use as the variable name to call a function. The actual functions work, but when using a variable as the function name it doesn't call the function. Here's my code so far, could anyone help with what I may be doing wrong (please see code snippet attached).
Thanks a lot
Tony Mead
Attach Code
// capture the 'open' panel so we know which one to close
var closeActive = "closeHome";
// button functions
btnHome.onPress = function() {
closeActive();
closeActive = "closeHome";
homePanel.gotoAndPlay(1);
};
btnAbout.onPress = function() {
closeActive();
closeActive = "closeAbout";
aboutPanel.gotoAndPlay(1);
};
btnWork.onPress = function() {
closeActive();
closeActive = "closeWork";
workPanel.gotoAndPlay(1);
};
btnContact.onPress = function() {
closeActive();
closeActive = "closeContact";
contactPanel.gotoAndPlay(1);
};
// functions close the panels
function closeHome()
{
// code to close this panel
};
// function to close the about panel
function closeAbout()
{
// code to close this panel
};
// function to close the work panel
function closeWork()
{
// code to close this panel
};
// function to close the contact panel
function closeContact()
{
// code to close this panel
};
Edited: 04/04/2008 at 05:04:38 AM by tony_mead
How To Select Random Entries Of An Array Till Theres None Left?
Hi im not sure how i should accomplish this problem. (flash mx)
im trying to create a little game. i need a script that creates an array with 26 entries (like array [tg,be,sh,...]) then select a random entry and pass it on. if the right selection (game) is done by the user, it removes that entry and goes on to choose the next random entry, until there's no entry left. if the user action is false, it shouldnt remove the entry and goes on to choose a new random entry. and so on.
may theres a way to do that other than with arrays?
any help is very appreciated!
thx in advance
soma
Select A Random Movieclip Form An Array Of Movieclips
Hi, iv been trying to find out how i can attach a random movieclip form an array of movieclips.
Iv got this so far, i have searched the forum etc for help and i am pretty stuck.
PHP Code:
var logo_arr:Array = new Array("logo01", "logo02", "logo03", "logo04", "logo05", "logo06", "logo07", "logo08", "logo09", "logo010", "logo011"); var randomLogo:Number = logo_arr[Math.floor(Math.random()*11)]; var dynamiclogo_mc = this.attachMovie("randomLogo", "randomLogo", 3); dynamiclogo_mc._x = Stage.width/2 - 180 ;dynamiclogo_mc._y = Stage.height/2 - 420;
All my movieclips are in the library and have the linkage for actionscipt enabled.
I cant see what it is im missing?
Any help is much apreciated
Thanks, Sam
Dynamic Text Select All Function
Hi there
I want to make a dynamic text box that when i click on it to focus it, it will select all the contents of the text box rather than having the user click and drag to select the contents. Is there some actionscript to get make the textbox select all when focused?
Many thanks
Trev
How Do You Select Or Target Dynamically Created Loader Object Instances
I am working on a bit of code the draws its images from a url generated from XML . I would like to then use the images to be click-able so I can further work with them. the last 3 lines aint doing the trick.
Here is what I got so far.
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("http://www.squisheesoft.com/xml/books.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseBooks(xmlData);
}
function ParseBooks(bookInput:XML):void {
disp1(xmlData);
}
function disp1(bookInput:XML):void {
var exp:int = 0;
for (var i:int = 0; i < bookInput.Book.length(); i++) {
var loader:Loader = new Loader();
loader.name = "loader_"+i;
this.addChild(loader);
loader.load(new URLRequest(bookInput.Book.image.text()[i]));
loader.x = exp;
exp += 100;
trace(bookInput.Book.length());
trace(loader.name);
}
}
this.loader_1.addEventListener(MouseEvent.MOUSE_DO WN, startDr);
function startDr():void {
this.loader_1.startDrag();
trace("hi");
}
Genius with a handicap( WHEE*THUD*WHEE*THUD*WHEE*THUD*)
String Search+select Kind Of Function..
i'm trying to write a function but with no luck. seems my brain capacity's limited
the function will take two parameters: a term to search for, and a string to be searched. what i want the function to return is a new string containing the term (the parameter) along with a couple of words before and after it (as found in the search string). is anyone so kind as to help me with that?
String Search+select Kind Of Function..
i'm trying to write a function but with no luck. seems my brain capacity's limited
the function will take two parameters: a term to search for, and a string to be searched. what i want the function to return is a new string containing the term (the parameter) along with a couple of words before and after it (as found in the search string). is anyone so kind as to help me with that?
Has Anyone Tested How Random Is The Math.Random() Function?
Just wondering whether anyone out there has ever run any tests on how random the Math.Random() function is as a random number generator?
I've been asked me to test it to prove that it is random and it seems a pointless waste of time, so I'm hoping to get evidence from elsewhere to convince the powers that be that there's no need to run the tests.
I've googled for it but come up with nothing so I'm hoping there might be someone out there who has already done the research?
Random Function & Unique Random Numbers
Hello, after some searching i can't seem to find any good explanation to how and why i should use the Math.random() function so maybe i should explain how a function i need should work and someone maybe has some ideas.
I'm making a guessing program where you guess the right answer.
The function i have now randomly selects a number from 0 to 5 and then put's these five numbers into an array, the thing is that i need the numbers to be unique and i have no idea on how to make this.
Another thing i need to do is between these numbers that the random() function gets one is to be removed and instead i put the right answer there so now i also need one of the randomizes numbers to not be the right answer.
Also, how should a Math.random() function call look like so i can edit the range of numbers to randomize from?
Select Doesn't Select. What Did I Screw Up?
I'm learning Flash from a book called "Essentials For Design:
Macromedia Flash 8"
THE SHORT STORY
Using the select tool, when I double-click an object to select it, it
doesn't. What happens is that it produces a light-blue square outline
surrounding the edge of the object and then "expands" or "explodes"
the outline to the limits of the stage. The object is not selected
yet.
If I double-click again, it selects the object but it doesn't behave
as it should.
What is this blue outline and why isn't it selecting the object like
it's supposed to...on the first double-click?
THE LONG STORY
In the intro to objects it has you draw a square and a circle. You
double-click the circle and move it onto part of the square.
Deselect, then select the circle again. Move it off the square and it
takes the intersection away from the square. Fine and dandy.
I did a few more exercises, none of which seemed to modify any
preferences, and now when I try the same operation on the circle /
square, it doesn't work.
What's different is when I double-click to select an object, rather
than selecting it, it draws this light-blue line that bounds the outer
dimension of the object and "expands" this square outline outward.
If I double-click AGAIN it selects the object but doing the same
procedure of moving it has no effect on the shape of the square. The
circle doesn't take a chunk out of the square.
I hope this makes sense.
Help! How can I get FLASH working like I think it's supposed to?
thanks
- peq
Target A Function In A Function In A Object :)
Uggg, how do I target a function that is in a function that is in an Object...
I am building a componet and when the componet runs though the script and finishes I want to call a genral function that will be replaced with a spacific function that I set in the Componets Properties window.
So my Object function X2 looks something like this...
ScalerClass.prototype.clipEndAction = function(loadHandler) {
loadHandler();
};
ScalerClass.prototype.myOtherFunction = function(){
trace("This function is a function")
}
//now if I target it like this within the object it works fine.
loadHandler=myOtherFunction
this.executeCallBack(loadHandler);
But How do I set up so that if this is in an componet i could target it from the Componets Pro Win.
"In(Object){...}" Function? Data Types For Object Variables?
I can create an object and use dot syntax to create, or reference, variables inside of it.
But how can I specify the data types of these variables?
Also, is there some way I can enter the namespace of the object over a number of lines via {}s instead of using repetitive dot syntax?
Thanks in advance.
Random() For XML Object
Presently I'm creating a offline XML data based objective type quiz.
myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("qes.xml");
quesFunction = function (status) {
if (status) {
currentQues = this.firstChild.childNodes;
}
delete myXML;
};
In XML file I'm using more than hundred questions, all questions and their options appear one by one, that's fine. But I want only 25 questions randomly every time quiz starts, so how it's possible.
Trace(currentQues.length);
Here output is 125 and they appear one by one by clicking next button, but I want only 25 questions at a time/session randomly based on that 125 question.
Thanks a lot to everyone.
Random Object Bouncing
I need the actionscript for a ball that bounces within the movie clip in different directions depending on what angle the mouse hit it
Random Object Instances
Hi,
I'm kind of stuck here trying to make a simple flash game... would be great if someone could help me out.. thanks heaps!
I would like to make a flash file with random object instances appearing in the file's XY plane. These instaces are actually the same button, which links to some URL.
To make things "look random", I know I can make a movie clip which just repeats over and over again, but then, the instances will always be in the same spot. So I was wondering, is the random instances effect achievable by by some kind of actionscript? There should be... but I couldn't seem to find it (maybe I don't know which category to at).
Any help will be very appreciated! Thanks!!
ET
Object Random Movement
Hallo, please can you help me?
How can I generate a continous random movement of a small
gif object(a ball for example) on a part of the screen?
Do I Have to give coordinates? Can I set the speed parameters?
the movement must be unstoppable...until a click on a button
Thank you very much
Bernie Lomax
Random Movement Of An Object
does anyone know where I can get some code to make an object move around randomly and somehow set parameters to how crazy it is moving around?
Thanks peeps!
Random Transform Object
hi there,
how can i let an object like a circle transform randomly via actionscript. i think somehow it can be done with variables & loops, though i dont know how...
heres the script for the circle
_root.createEmptyMovieClip( "circle", 1 );
with ( _root.circle )
{
lineStyle( 0, 0x0000FF, 100 );
beginFill( 0xFF0000 );
moveTo( 500, 500 );
curveTo( 600, 500, 600, 400 );
curveTo( 600, 300, 500, 300 );
curveTo( 400, 300, 400, 400 );
curveTo( 400, 500, 500, 500 );
endFill();
}
Random Position Of Object
i want to know how can i make the object changing its position randomly for two conditions simultaneously .. either i click on object then it should change its position or if i don't click with in 5 seconds then it should automatically change its position .
please write codes for this also ......
Random Placement Within An Object
Hi,
I was wondering how one would go about randomly placing a duplicated movieclip within the shape of another movieclip.
For example, I have a vectorised image of a tree and I want to randomly position leaves onto the branches of this tree.
I am able to randomly position duplicated movieclips within a square, but not within a more complex shape.
The solution I attempted was to run a loop which would place the duplicated movieclips within a square, and then do a hitTest to see if it was actually placed on the shape:
code:
// Height and Width of the movie
movieWidth = 550;
movieHeight = 400;
// grow tree
function placeLeaves(leaves) {
// Number of leaves
var leafNum = 50;
// places the tree
_root.attachMovie("tree","tree",++d);
// centers tree
wTree = _root.tree._width;
hTree = _root.tree._height;
_root.tree._x = (movieWidth/2)-(wTree/2);
_root.tree._y = (movieHeight/2)-(hTree/2);
menu.tree=_root.tree;
for(i=0;i<leafNum;++i){
var leafName = "leafLink"+i;
menu[leafName]= new menu["LeafLink"+eyes[i]];
_root.tree.attachMovie("leafLink", leafName, i+100);
_root.tree[leafName]._x = Number(random(wTree));
_root.tree[leafName]._y = Number(random(hTree));
if(_root.tree.hitMe.hitTest(_root.tree[leafName])){
_root.tree[leafName].gotoAndStop(2);
}
}
}
placeLeaves(leaves);
**I should also say that the movie tree contains another mc named hitMe which is a copy of the branches of the tree where I want the leaves to appear. Also the leaves have two states, which I am using to test if a leaf is hitting the tree.**
At the moment I am just trying to write a script that will change the state of a leaf if it is contained within the tree, rather than placing itself on the tree. It works, but it doesnt work the way I want it to. Its testing to see if the leaves are within the bounding box, and not withing the actual shape of the tree.
Any help, advice, tips or further reading would help me out. Im off to continue searching for clues myself.
Thanks
Ross
[F8] Object That Floats On A Random _y & _x
Is there a way I can have several mc's that float on random _y and _x directions? I don't necessarily care if they end up going off stage. I am trying to get them to go in one direction then change direction after a couple seconds. I have an intermediate knowledge of AS and have tried using the following code that I found on another post to no avail:
any help would be greatly appreciated; much thanks.
-----------------------------------------------------
kNbrHearts = 8; // number of hearts
kNbrPix = 3; // number of heart pix
kMinSpeed = -1;// minimum rise speed
kMaxSpeed = 1;// maximum rise speed
kMinSway = .0001; // minimum sway
kMaxSway = .01; // maximum sway
kSwayAmplitude = 10;
kDistance =1;
SW = Stage.width;
SH = Stage.height;
moveHeart = function()
{
var a = this.phase + getTimer()*this.sway;
var sway = Math.sin(a);
//this._x += sway;
this._x += sway*kDistance;
this._rotation = sway*kSwayAmplitude;
this._y -= this.speed;
if (this._y < -this._height) {
this._y = SH+this._height;
}
}
for (i = 1; i <= kNbrHearts; ++i)
{
var mc = _root.attachMovie('hearts', 'heart_' + i, i);
mc._x = random(SW);
mc._y = random(SH);
mc.onEnterFrame = moveHeart;
mc._alpha = 50 + random(50);
mc.phase = Math.random()*2*Math.PI;
mc.speed = kMinSpeed + Math.random()*(kMaxSpeed - kMinSpeed);
mc.sway = kMinSway + Math.random()*(kMaxSway - kMinSway);
mc.gotoAndStop(random(kNbrPix ) + 1);
}
Multiple Random Object
I have the following code on the first frame. It works successfully displaying a random object on the stage out of 14 objects. But i was wondering if its possible to allow 4 objects to be displayed on the stage, but none can be the same. Is there a simpler way to do it other then copying and pasting what i have already?
Code:
fruit = random(14) // choose a random 'fruit' out of 14 objects
function onEnterFrame(){
if(fruit == 0){
attachMovie("apple", "apple1", 1);
apple1._x = 200; // horizontal object coordinates
apple1._y = 200; // vertical object coordinates
}else if(fruit == 1){
attachMovie("orange", "orange1", 1);
orange1._x = 300;
orange1._y = 200;
}else if(fruit == 2){
attachMovie("bread", "bread1", 1);
bread1._x = 300;
bread1._y = 200;
}else if(fruit == 3){
attachMovie("broccoli", "broccoli1", 1);
broccoli1._x = 300;
broccoli1._y = 200;
}else if(fruit == 4){
attachMovie("carrot", "carrot1", 1);
carrot1._x = 300;
carrot1._y = 200;
}else if(fruit == 5){
attachMovie("cheese", "cheese1", 1);
cheese1._x = 300;
cheese1._y = 200;
}else if(fruit == 6){
attachMovie("cherry", "cherry1", 1);
cherry1._x = 300;
cherry1._y = 200;
}else if(fruit == 7){
attachMovie("chicken", "chicken1", 1);
chicken1._x = 300;
chicken1._y = 200;
}else if(fruit == 8){
attachMovie("corn", "corn1", 1);
corn1._x = 300;
corn1._y = 200;
}else if(fruit == 9){
attachMovie("fish", "fish1", 1);
fish1._x = 300;
fish1._y = 200;
}else if(fruit == 10){
attachMovie("grapes", "grapes1", 1);
grapes1._x = 300;
grapes1._y = 200;
}else if(fruit == 11){
attachMovie("pear", "pear1", 1);
pear1._x = 300;
pear1._y = 200;
}else if(fruit == 12){
attachMovie("pineapple", "pineapple1", 1);
pineapple1._x = 300;
pineapple1._y = 200;
}else if(fruit == 13){
attachMovie("strawberry", "strawberry1", 1);
strawberry1._x = 300;
strawberry1._y = 200;
}
}
any help would be much appreciated.... along with comments or explanations.
AS2 - Random Object From Array
Last edited by uxk8396 : 2008-08-01 at 08:45.
Hello:
I want the 3 movieclips (clouds) to be selected at random from the array and move randomly across the stage. Please find flash file attached for reference purposes.
Thanks
uxk
Random Move An Object In The Movie
Hey guys!
One more newbie came here for a question...
I have a movie where I want a box to be displayed randomly anywhere at the movie. My movie is 720x284 wide and if it's possible I want it to move at the center or the right side of the movie. I also used some actionscript from here, to achieve auto alpha blending and works like a charm.
Here's the test .fla:
Creating Random XML Object Placement...
I want to create swf file that calls in objects from an XML file and randomly places them inside a movie clip. The individual XML nodes would activate a certain symbols and avoids overlapping them. If the XML could also specify the exact coordinates of the symbol placement, then that would be great but not necessary. But I don't know how to do that. Does anyone know how to do that, or where I can find info regarding it. Thanks.
Move A Object In Random Directions
Hi guys.
This is kind of hard to explain, so i'll paint you a picure here:
I have a shoppingbag. Out of that bag, i want to have multiple stars flying out.
The stars have to move upwards, but in a random angel and speed.
And fade out in the end. Either after a duration of time, or when they have moved more then 300 pixel.
Please, anyone who can help me in the right direction here?
Setting Random Positon(X,Y) Of A Object Through XML
Hi , Guys
I am facing a problem : problem is that i have a xml file through which i am getting the value of an object name , path , X , Y position and set it on the screen . But the requirement is that every time when page is loaded position of the object should be changed . Like if the position of an object A is X=20 and Y=30 , first time on load of the page , then second time when page is loaded the position of the object A s hould be different or changed like X=40 , Y=50; This is the problem , i have a XMl file given below through wich i get the value of X, Y of an object.
So please suggest me what I have to do ?
Either i have to change in XMl file or have any script for random position of X, y after getting that value from XMl????
Please Help me out.
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="1" nme="object1" path="images/a.png" price="250" xpos="20" ypos="300"/>
<item id="2" nme="object1" path="images/b.png" price="320" xpos="80" ypos="300"/>
<item id="3" nme="object1" path="images/c.png" price="190" xpos="140" ypos="300"/>
<item id="4" nme="object1" path="images/d.png" price="120" xpos="200" ypos="300"/>
<item id="5" nme="object1" path="images/e.png" price="110" xpos="260" ypos="300"/>
<item id="6" nme="object1" path="images/a.png" price="900" xpos="320" ypos="300"/>
<item id="7" nme="object1" path="images/c.png" price="250" xpos="380" ypos="300"/>
<item id="8" nme="object1" path="images/d.png" price="310" xpos="440" ypos="300"/>
<item id="9" nme="object1" path="images/e.png" price="190" xpos="500" ypos="300"/>
<item id="10" nme="object1" path="images/c.png" price="120" xpos="560" ypos="300"/>
<item id="11" nme="object1" path="images/e.png" price="110" xpos="620" ypos="300"/>
<item id="12" nme="object1" path="images/a.png" price="900" xpos="680" ypos="300"/>
</items>
Setting Random Positon(X,Y) Of A Object Through XML
Hi , Guys
I am facing a problem : problem is that i have a xml file through which i am getting the value of an object name , path , X , Y position and set it on the screen . But the requirement is that every time when page is loaded position of the object should be changed . Like if the position of an object A is X=20 and Y=30 , first time on load of the page , then second time when page is loaded the position of the object A s hould be different or changed like X=40 , Y=50; This is the problem , i have a XMl file given below through wich i get the value of X, Y of an object.
So please suggest me what I have to do ?
Either i have to change in XMl file or have any script for random position of X, y after getting that value from XMl????
Please Help me out.
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="1" nme="object1" path="images/a.png" price="250" xpos="20" ypos="300"/>
<item id="2" nme="object1" path="images/b.png" price="320" xpos="80" ypos="300"/>
<item id="3" nme="object1" path="images/c.png" price="190" xpos="140" ypos="300"/>
<item id="4" nme="object1" path="images/d.png" price="120" xpos="200" ypos="300"/>
<item id="5" nme="object1" path="images/e.png" price="110" xpos="260" ypos="300"/>
<item id="6" nme="object1" path="images/a.png" price="900" xpos="320" ypos="300"/>
<item id="7" nme="object1" path="images/c.png" price="250" xpos="380" ypos="300"/>
<item id="8" nme="object1" path="images/d.png" price="310" xpos="440" ypos="300"/>
<item id="9" nme="object1" path="images/e.png" price="190" xpos="500" ypos="300"/>
<item id="10" nme="object1" path="images/c.png" price="120" xpos="560" ypos="300"/>
<item id="11" nme="object1" path="images/e.png" price="110" xpos="620" ypos="300"/>
<item id="12" nme="object1" path="images/a.png" price="900" xpos="680" ypos="300"/>
</items>
Random Movement Object Problem
I've been try to use the Random Movement code from the Flash MX section but I can't seem to get it to work right when I put it at the mid-section of my document.
I've been trying to tweak the code to adjust how far the objects will move and it works a little but some of the objects will stay stray to the top, I think because it is due to this.diffx and this.diffy.
I also tried putting it in it's own movie, but when that happens the object doesn't move anymore. It simply teleports form one position to another and I have no clue how to deal with that either.
Thanks for any help.
|