Arrays :: Saving X And Y Cords As Variables On Mouse Click?
Jan 7, 2012
I have a piece of code worked out that creates circles on a mouseDown function. I'm trying to save the x and y cords of the circles but cannot figure out a way around this. I need to save multiple instances of the cords from mouseDown.
Is it possible to do this in an array?
var posOne:Number;
//var posTwo:Number;
//var posThree:Number;
[Code]....
View 2 Replies
Similar Posts:
Nov 8, 2011
I'm working in Actionscript 3, but this is pretty general.I'd like to make a simple function that I can call, e.g. GiveCords(Width, Height, Num) that will take a width and height, map that out and using the Num variable place the given amount evenly across the space.Say I give it a value of 500, 500, 1. I'd expect it to return an X, Y position of 250, 250.But I'd like it to return an array of given points with X, Y.So If I gave it 10 points, it would find the best position for them all to be of even distance apart from each other.
View 1 Replies
Feb 4, 2011
I have Flash var array that I want to swap for another array on mouse click. It currently loads the initial array into the empty MC perfectly. Now I need it to swap to var productTxt2 when the user presses buttonMC. My code is below.
AS2 code:
var productTxt1 = new Array(
"Product Name 1", "Price 1", "Headline 1", "Copy 1");
var productTxt2 = new Array(
"Product Name 2", "Price 2", "Headline 2", "Copy 2");
_root.createEmptyMovieClip("productInfoMC", 0);
[Code] .....
View 1 Replies
Jun 21, 2006
I have an application where I need to detect if the mouse is less than 200 px from the left sie of the screen, then play an animation... Once the mouse is moved back out of the 200 px area I want the animation to reverse.I'm using the Tween Class for animation and have been messing around with onclipevents with no luck like:
onClipEvent (enterFrame) {
if(_xmouse <= 200)
{
_root.theSwitch = "on";
[code]....
This will obviously produce a million "on" traces when the mouse is over there - what is the best method for detecting the change once, setting a variable, then playing the animation?
View 1 Replies
Apr 6, 2009
How can I put the X and Y coordinates of the mouse in two variables, but only on a click on the workspace.
View 1 Replies
Aug 2, 2009
im messing with a movieclip symbol and i want to make a button, what'd i mean on Mouse over display/change this image in this X,Y cords or replace this image, something close to what buttonSymbol does but i want to make it using movieClip symbol...
and i have no idea how to do it.. i started like this:
[Code]....
View 0 Replies
Jun 25, 2004
correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.The hierarchy I want to create is as follows:
AllBrigades (array of Brigades)
Brigade (object)
BrigadeUnits (array within Brigade object)
Unit (Object to be stored in BrigadeUnits array)
I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:
AllBrigades [0] [2].push (MyUnit);
But when I trace this I just get undefined.
View 14 Replies
Feb 14, 2007
I have used SO's to save and retrieve simple variables successfully, but I am a problem saving and retreiving array data in the following example: [URL] A user selects several options using radio buttons. All that happens is that the SO should store in memory which buttons the user clicked on. If run through flash with the output window, you can see that when the save button is clicked, the data is saved. But when you load the activity a second time, the array data that was stored in the SO only gets recalled as 'undefined'.
View 3 Replies
Mar 25, 2012
how to save the content of an array in an csv file that already has a content. its like overwriting the content of the csv file. the array is like this (Array [1][1]). i've search and googled it but every answer i got is still wrong.
View 1 Replies
Jan 26, 2005
I'm trying to save a change to a text document (In this case a variable "Title" just to test) and then view the changes from another swf movie... In the end I'm hoping to build a client updatable flash site. In particular menu items... feature items & prices.
A Recap: a client types in the items, php/flash saves the changes to the text document, and site visitors can views those changes.
Something in my code isn't clicking:
My PHP is:
Code:
<?php
$Title = $_POST['Title'];
$toSave = "Title=".$Title;
[code]....
View 1 Replies
Jun 14, 2010
Well i am trying to save variables into a file, prefirable .txt files, but i am having some troubles doing so, all the tutorials say stuff like you need to use php and java, but i am trying to save it to the client's comnputer, so you save it local.here is my script i have so far:
Code:
var sex:int;
sex = 0;
[code].....
View 1 Replies
Jun 18, 2008
Is it possible to make such a thing: When Button_btn is clicked (onRelease), var( var Name:String = new String("Flash MX|) ) is send to file (File.txt) and saved there.
View 1 Replies
Oct 26, 2011
I was given the task of altering a Flash animation (no AS) in a way that it would collect data from WSDL, write it to a text file and then use that data each subsequent time it runs.
You see, the Flash animation is part of a playlist (digital signage) and has a set duration which doesn't allow for network problems while retrieving data from WSDL. So while I got it to work fine by just displaying the WSDL data directly - it sometimes times out.
I have the retrieving from WSDL part down (flex), I can even read stuff from .txt files, but can't do the middle part - writing the variables into a .txt file.
View 2 Replies
Jun 21, 2011
So I want to do saving and loading for variables. I.E. I want to save a variable by pressing the save button. When you use the "load" button, the variable is what it was when it was saved. I've tried this but it didn't work...
Code:
//Code on the frame
var saveState = SharedObject.getLocal("Cookie");
//Code on the save button
on (release) {
_root.save.gotoAndPlay(2);
savefile.data.blah = _root.blah;
savefile.flush();
}
//Code on the load button
on (release) {
gotoAndStop(3);
_root.blah = savefile.data.blah;
}
View 3 Replies
Jan 15, 2012
how to set o click the button saving of a particular portions of the flash as .jpg/.gif.. the part included a dynamic text field
View 0 Replies
Jan 26, 2012
I just started playing around with as3 and I have a function for mouse clicks that draws a shape on each click. However the mouse click event does not appear to work unless I click a movieClip object I placed in the middle of the screen. Is there a way to make the mouse click event recognize when I click anywhere on the screen?
[Code]...
View 2 Replies
Nov 14, 2006
Hello all,
I am having some weirdness with arrays and variables. I'm sure this is something basic but I can't get it to work. I have a an MC name "circle" this also contains dynamic text field name nameMC. Writing to that textfield is simply circle.nameMC.text = "New copy";
So below I have two arrays.
Code:
var textArray:Array = [one, two, three];
var newArray:Array = ["one", "two", "three"];
for (var i:String in newArray) {
this.attachMovie("circle", newArray[i], this.getNextHighestDepth(), {_x:Math.random()*300, _y:Math.random()*200});
textArray[i].nameMC.text = newArray[i];
}
This doesn't work. I've tried swapping the various arrays but no luck. So why does the movieclip want to use the "quoted" array value and not the unquoted. Also, when I use"
Code:
one.nameMC.text = "hello";
everything works fine, but the arrays won't. So:
Code:
textArray[i].nameMC.text = "hello";
for example doesn't work.
Thanks for any guidance!
View 3 Replies
Dec 26, 2006
why cant the variable "height" modify the position of y? =S im new at ac so i dont know if an element of an array can be a variable? and how do i make it a variable?this is a par of the code im writing to make a group of movieclips appear offstage in a random positions as long as it is offstage (i know the array is not random since i give the values of each element but i tried by putting y= math.random * number?... but in the coordinates i didnt knew how to specify that it could be any random number exept the lenght of the stage)
onClipEvent (load) {
myArray = new Array ();
myArray[0]=-100;
[code].....
View 8 Replies
Jul 9, 2011
This is code i used for saving pictures to user computer on button click:
Code:
// Create a new instance of the FileReference class to work with.
var myfileReference:FileReference = new FileReference();[code].....
View 0 Replies
Apr 21, 2011
i want to choose one of these randomly, I have a loop way in which there is a loop searching for the index number which is inside an array like M1[1]=1 , M2[1]=2 and if I have a random number between 1 and 20 I can loop the arrays [1] element.
But is there another way with directly get the random array buy name. For example I have the random number 14 which directs me to M14. how Name of the array help me to choose M14 when I have the number 14....
View 2 Replies
Jul 2, 2004
I changed the mouse cursor using a tutoral from this forum, but when I press the right mouse button,the standard mouse cursor reapears.How to prevent that?
View 10 Replies
Oct 11, 2011
I am trying to have two guestures on a SpriteVisualElement which I thought should be pretty simple implemented: Mouse_Move for sweep Gestures and mouse click to enable.. So I have 2 Eventlisteners on my stage:
[Code]...
The main problem is that every type of sweeping on the screen also fires the taphandler().. how to identify the correct event? I tried to to my taphandler only if(!event.buttondown) but no success.
View 1 Replies
Jul 27, 2010
Frame 1
Code:
band_button.buttonMode = true;
band_button.useHandCursor = true;
[code].....
View 3 Replies
Jul 2, 2004
I changed the mouse cursor using a tutoral from this forum, but when I press the right mouse button, the standard mouse cursor reapears...
How to prevent that?
View 10 Replies
Feb 14, 2005
I have a series of mc's that are in a grid position and another set on top. I want to move the ones on top to different positions over the others but I want to check to see if one is already there. I dont' want to use hitTest, it doesn't work for what I want to do. I want to position my top mc's base on the x and y positions of the bottom mc's. How do I check a mc for a value if all my names start the same, i.e. mc_ and end in numbers that represent their position, i.e. mc_12070. I was thinking something like:
newY = this._y - 50;
newX = this._x;
but how would I call the clip?
_root.mc_+newY+newX
what is the syntax to make that work?
View 1 Replies
Feb 14, 2005
I have a series of mc's that are in a grid position and another set on top. I want to move the ones on top to different positions over the others but I want to check to see if one is already there. I dont' want to use hitTest, it doesn't work for what I want to do. I want to position my top mc's base on the x and y positions of the bottom mc's. How do I check a mc for a value if all my names start the same, i.e. mc_ and end in numbers that represent their position, i.e. mc_12070. I was thinking something like:
newY = this._y - 50;
newX = this._x;
but how would I call the clip?_root.mc_+newY+newXwhat is the syntax to make that work?
View 1 Replies
May 4, 2009
After unexplainable problems with external class files, I'm trying another way of doing what I need to do: an Object variable declared in the fla file. Well, this has its own set of problems. The big picture is: I need to get user data and populate fields in their profile when they sign on. Then save changes to their profile during the session, add new users and make changes to their profiles. Pretty normal stuff.
Here's the problem I'm having with the object.
Frame 1 Script:
/* Define the object to use as an associative array.*/
var Person:Object = new Object();// Define a series of properties.Person.HomName = "Joe";Person.HomEmail = "joe@gmail.com";
Then go to a new keyframe, where I have my fields that need to be populated
Script:
EnterName.text = Person.HomName;EnterEmail.text = Person.HomEmail;stop();
When I compile, I get this error twice (once for each field) "The property being referenced does not have the static attribute."
What does the mean and how do I fix it?
Here is a link to the source file if you care to look.
[URL]
The only way I've been able to get variable data from one script to another is through a _global.variable. Is this the only way? No arrays or objects vars?
Thanks in advance for all who assist. Some day soon I hope to be able to return the favor!
View 3 Replies
May 17, 2009
- I tried, when I first started making this site, to load all of the artwork images into an array and then copy the array before resizing them for their specific functions (being seen as thumbnails or as full size pics.) Unfortunately, I ran into the well known issue of Array cloning only creating a pointer to the same group of items. I tried the newArray = oldArray.slice() trick, but it didn't seem to work. Finally, I just loaded the images twice into two separate arrays, and it works, but I hate this solution. Anyone got a better one?
- I'm trying to maintain some sort of connection between the two sets of Arrays so that, for example, when someone clicks on Thumbnail 15, Fullsize Image 15 will open up but I couldn't find anything that worked. Renaming the Instance Name dynamically didn't seem to work and adding an Instance Variable dynamically doesn't seem possible either as I can't make the Class I am working with (Sprite, in this case) dynamic ahead of time. I'm sure there's a simple method for this.opens up, the different animations seem to interfere with each other and slow each other down (they also seem to get interference from the time taken to load the image Arrays.)
View 9 Replies
Mar 8, 2012
I have a string variable that looks something like this:
2012-03-07 135.06 135.91 134.93 135.69 143616800 135.69
2012-03-06 135.35 135.43 134.36 134.75 202129900 134.75
It continues like this, a list of reoccurring variables seperated by spaces, for a few more lines.How can I separate the string and push the different variables into their appropriate arrays. The end result should look like this:
dates = [2012-03-07, 2012-03-06]
variable1 = [135.06, 135.35]
variable2 = [135.91, 135.43]
View 10 Replies
Mar 31, 2011
I am trying to load variables from my webpage onto my .swf
ActionScript Code:
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, loading);
[code]....
This code works perfect for loading variables in a &var1=1&var2=2& etc...But how can I load variables from the page?like do I need to put in &array_name[incrementing_var]=value& and then when i go to access it it should be loader.data.array_name[0] but this doesn't work for me? I realize my URLLoaderDataFormat.VARIABLES is for variables but can i still pass arrays with this? or do i need a new format? or do i need to pass the values as variables and convert them into an array in my AS?
View 5 Replies