[CS3] Yahtzee: Reading Array Values
Hi, I'm new. Please don't kill me with your überness, as I am quite brittle.
As the game Yahtzee is typical Norwegian Easter entertainment, I decided to try to make a Maxi Yahtzee (6-die Yahtzee) game as my first large Actionscript project (that is not fiddling around with a tutorial). Been working tonight and I've managed to make the 6 dices roll when I want, and hold when I want, as well as getting the die values into an array after 3 rolls by converting it from the separate die values.
PHP Code:
on (release) { var points = [trn1,trn2,trn3,trn5,trn5,trn6]; //putting the 6 die (Norwegian: terning, abbr. trn) values into the array "points" gotoAndStop("points",1); // going to scene "points" where the scoreboard is }
Now, I can use the Array.sort to make them fall into place "numerically", but what I need is to make Flash understand what numbers are actually there.
For example, a large straight is 2, 3, 4, 5, 6 and another die value that is not put into consideration. I can make the actionscript recognize an array of "2,3,4,5,6,4" as a "Large Straight", but when these are put numerically, the array read "2,3,4,4,5,6", which wouldn't be read as a "Large Straight".
Is there a way to use if statements to check if an array contains a 2, a 3, a 4, a 5 and a 6 individually of placement in the line? If I knew this, the rest wouldn't be more than if's and else's and some lists, so I'd probably manage it on my own.
I use Actionscript 2.0 for this, as it is the one I'm most familiar with, but I guess I could transfer the project to 3.0 if I had to.
If someone could either tell me a way of achieving this, or point me to somewhere where a way is explained, I'd love the person(s) long time.
If this should be in the Game board, please move it. I just thought that this would be an array question more than a game question, so I put it here.
FlashKit > Flash Help > Flash ActionScript
Posted on: 03-21-2008, 11:47 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Reading Array Values From A Text Field
if you want to pull values out of an array in actionscript, it's easy... but how would you do it if you want a text field to reflect array values?
myArray.1 and myArray[1] don't pull the value correclty; the only way i could get it to pass was if i first defined a NEW variable that was always equal to the slot I needed, and then to reference that variable in the text field variable name. am i missing something?
Writing Values To A Text File And Reading Values From The Same File
Hi, I want to create a page counter in Flash and I was wondering how to write a value (the next number for the visitor) to the text file and read the current value from that file. In a simplified form I would just read the number currently in the file, add 1, and rewrite the number to the file. Eventually when I get that worked out I will adapt it to only add 1 for each different user session instead of each page hit, but I'll start with the easy stuff first.
Thanks
[MX] Weirdness With Values Used By Array Populated Clip Values.
Hi,
I have used invisible buttons on top of some text, as part of a volume control interface.
The text buttons are set out as 0 – 25 – 50- 75 -100 referring to the % that a music tracks volume will change to once a button is pressed – so far so good.
Now to give values to the text buttons in order for them to make the text clip that they are on top of go to & stop & the right frame I have used arrays to give a reference the location of the text clip:
numbs_array = [_root.volHold_mc.vol0, _root.volHold_mc.vol25, _root.volHold_mc.vol50, _root.volHold_mc.vol75, _root.volHold_mc.vol100];
I then reference that in a home made “release” function as “this.monica.gotoAndStop(2);” “monica” being the reference to the address of the clip.
It all works fine except the code seems to make the movie play clips in an order that they have not been designated in the array – Like a button on top of the “25”% value will play the animation for the “75”% clip?
The whole problem is probably much better seen through the movie – the problem section of which i have attached below.
Reading Values From DB
i want from flash
to call an asp page that will return me some value from a DB
how do i do that?
thnaks in advance
peleg
Reading In Values From MAX MSP (Flashserver)
At the moment i'm passing a value from MAX/MSP into Flash via flashserver. Basically I play a note on my guitar and MAx sends the note value to flash. so when I play a note flash will say "The note is a: "whateveritis".
What I'd like to know is how to take that value and use it to perform functions in flash. for example if I play an "A" on my guitar then something should happen in flash, such as a button being pressed.
Here is the code I have so far, just can't figure out how to use th enote values as functions.
Any help would be great! Thanks.
Code:
fscommand("allowscale", false);
fscommand("fullscreen", false);
function pdsendvars (symbol, value) {
fudi = symbol + " " + value + ";"
pd.send(fudi);
}
server = "localhost";
port = 31337;
pd = new XMLSocket();
pd.connect(server, port);
pd.onConnect = onPDconnect;
pd.onClose = onPDclose;
pd.onData = onPDdata;
function onPDconnect (success) {
if (success) {
msg = "Connected to "+server+" on port "+port;
} else {
msg = "There has been an error connecting to "+server+" on port "+port;
txt = "Error: Max is not listening on port 31337: Error in connection.";
//getURL('javascript:alert("' + txt + '");');
}
}
function onPDclose () {
msg = "Lost connection to "+server+" on port "+port;
//getURL('javascript:alert("Error: PD is not listening on port 31337: Lost connection.");');
}
/* receive data from flashserver */
function onPDdata(doc) {
msg = "The note is a: " + doc;
if (doc = "A;") {
txt = "It's a fookin A";
}else {
txt = "It is NOT a fookin A";
}
}
Reading Values Set When Loading Swf
Hi all, I've got a unique situation on my hands.
I have some server side code that takes a url visited and returns a swf file. This swf file needs to know the address that it is being loaded from so that it can take certain actions.
So if I have:
- example.com/ex1/movie.swf
- example.com/ex2/movie.swf
I need the video to be able to know if it is being loaded from ex1 or ex2.
Is this possible without JavaScript being present in the code loading the swf file? If not what alternatives would be available to me?
Thank you.
**As a note I am working in Flex 3 so all related libraries are available.
Reading Values From A XML File...
from this file i want to read the values from <model> tag using a for loop
help me with code. i don't know xml well.
thank u
- <cat-product-structure>
- <Product_Group>
<ProductGroup>DI</ProductGroup>
<Description>Digital Images</Description>
- <Category>
<PrimaryCat>DSC</PrimaryCat>
<Description>Digital Still Camera</Description>
<CatCaption>Welcome to xxxx Digtial Images Product Line up 2004</CatCaption>
<CatWelcomeNote>Welcome to xxxx Digtial Images Product Line up 2004 .. A detailed discription goes here ... many lines</CatWelcomeNote>
<CatPictureName>digitalImages.jpg</CatPictureName>
- <compare_features>
<specname>Lens construction</specname>
<specname>Optical Zoom</specname>
<specname>Precision Digital Zoom</specname>
<specname>Smart Zoom</specname>
<specname>Focal length f=(35mm conversion)</specname>
</compare_features>
- <Sub-Category>
<SecondaryCat>Cyber-shot</SecondaryCat>
<Description>Cyber-shot</Description>
<CatCaption>Welcome to xxxx Cybershot Digtial Camera Product Line up 2004</CatCaption>
<CatWelcomeNote>Welcome to xxxx Cybershot Digtial Camera Product Line up 2004 .. A detailed discription goes here ... many lines</CatWelcomeNote>
<CatPictureName>cybershot.jpg</CatPictureName>
- <compare_features>
<specname>Lens construction</specname>
<specname>Optical Zoom</specname>
<specname>Precision Digital Zoom</specname>
<specname>Smart Zoom</specname>
<specname>Focal length f=(35mm conversion)</specname>
</compare_features>
- <Models>
- <Modelname Name="DSC-T1">
<Description>DSC-T1</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
- <Modelname Name="DSC-U40">
<Description>DSC-U40</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
</Models>
</Sub-Category>
- <Sub-Category>
<SecondaryCat>Mavica</SecondaryCat>
<Description>Mavica</Description>
<CatCaption>Welcome to xxxx Mavica Ditial Camera Product Line up 2004</CatCaption>
<CatWelcomeNote>Welcome to xxxx Mavica Ditial Camera Product Line up 2004 .. A detailed discription goes here ... many lines</CatWelcomeNote>
<CatPictureName>Mavica.jpg</CatPictureName>
- <compare_features>
<specname>Lens construction</specname>
<specname>Optical Zoom</specname>
<specname>Precision Digital Zoom</specname>
<specname>Smart Zoom</specname>
<specname>Focal length f=(35mm conversion)</specname>
</compare_features>
- <Models>
- <Modelname Name="MVC-FD100">
<Description>MVC-FD100</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
- <Modelname Name="MVC-CD400">
<Description>MVC-CD400</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
</Models>
</Sub-Category>
</Category>
</Product_Group>
</cat-product-structure>
Reading Values From A XML File...
from this file i want to read the values from <model> tag using a for loop
help me with code. i don't know xml well.
thank u
- <cat-product-structure>
- <Product_Group>
<ProductGroup>DI</ProductGroup>
<Description>Digital Images</Description>
- <Category>
<PrimaryCat>DSC</PrimaryCat>
<Description>Digital Still Camera</Description>
<CatCaption>Welcome to xxxx Digtial Images Product Line up 2004</CatCaption>
<CatWelcomeNote>Welcome to xxxx Digtial Images Product Line up 2004 .. A detailed discription goes here ... many lines</CatWelcomeNote>
<CatPictureName>digitalImages.jpg</CatPictureName>
- <compare_features>
<specname>Lens construction</specname>
<specname>Optical Zoom</specname>
<specname>Precision Digital Zoom</specname>
<specname>Smart Zoom</specname>
<specname>Focal length f=(35mm conversion)</specname>
</compare_features>
- <Sub-Category>
<SecondaryCat>Cyber-shot</SecondaryCat>
<Description>Cyber-shot</Description>
<CatCaption>Welcome to xxxx Cybershot Digtial Camera Product Line up 2004</CatCaption>
<CatWelcomeNote>Welcome to xxxx Cybershot Digtial Camera Product Line up 2004 .. A detailed discription goes here ... many lines</CatWelcomeNote>
<CatPictureName>cybershot.jpg</CatPictureName>
- <compare_features>
<specname>Lens construction</specname>
<specname>Optical Zoom</specname>
<specname>Precision Digital Zoom</specname>
<specname>Smart Zoom</specname>
<specname>Focal length f=(35mm conversion)</specname>
</compare_features>
- <Models>
- <Modelname Name="DSC-T1">
<Description>DSC-T1</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
- <Modelname Name="DSC-U40">
<Description>DSC-U40</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
</Models>
</Sub-Category>
- <Sub-Category>
<SecondaryCat>Mavica</SecondaryCat>
<Description>Mavica</Description>
<CatCaption>Welcome to xxxx Mavica Ditial Camera Product Line up 2004</CatCaption>
<CatWelcomeNote>Welcome to xxxx Mavica Ditial Camera Product Line up 2004 .. A detailed discription goes here ... many lines</CatWelcomeNote>
<CatPictureName>Mavica.jpg</CatPictureName>
- <compare_features>
<specname>Lens construction</specname>
<specname>Optical Zoom</specname>
<specname>Precision Digital Zoom</specname>
<specname>Smart Zoom</specname>
<specname>Focal length f=(35mm conversion)</specname>
</compare_features>
- <Models>
- <Modelname Name="MVC-FD100">
<Description>MVC-FD100</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
- <Modelname Name="MVC-CD400">
<Description>MVC-CD400</Description>
<ModelCaption />
<ModelWelcomeNote />
<FeaturedFlag>Yes</FeaturedFlag>
<NewFlag>No</NewFlag>
<Currency>SGD</Currency>
<Price>110.00</Price>
<modelpicturename />
<specification_code code="E32" />
- <compare_features>
<specname>Lens construction</specname>
<value>5 elements in 4 groups(including 1 aspheric elements)</value>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Precision Digital Zoom</specname>
<value>No</value>
<specname>Smart Zoom</specname>
<value>No</value>
<specname>Focal length f=(35mm conversion)</specname>
<value>f=5mm(33mm)</value>
</compare_features>
- <unique_features>
<specname>Optical Zoom</specname>
<value>1x</value>
<specname>Gross Pixels</specname>
<value>Approx2,110KPixels</value>
<specname>Effective Pixels</specname>
<value>Approx2,020KPixels</value>
<specname>Recording Format</specname>
<value>JPEG MPEG</value>
<specname>Playback Still Image Size</specname>
<value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
</unique_features>
</Modelname>
</Models>
</Sub-Category>
</Category>
</Product_Group>
</cat-product-structure>
Reading The Values Of A Variable
Last edited by glazedeye : 2007-05-21 at 07:49.
Hello,
Could anyone help me please? I'm stuck on a bit of AS that is driving me mad!
I have some code on the main timeline, which executes when a button is clicked:
ActionScript Code:
_root.profile_btn.onRelease = function() {
var frameSelected:Number = 3;
_root.home_btn.gotoAndPlay(36);
_root.profile_btn.gotoAndPlay(36);
_root.projects_btn.gotoAndPlay(36);
_root.services_btn.gotoAndPlay(36);
_root.extras_btn.gotoAndPlay(36);
trace (frameSelected);
};
Now, when one of these Movie Clips reaches frame 36 (if you are currently on the Home frame, it will be home_btn etc), I have another script:
ActionScript Code:
if (frameSelected = 3){
_root.gotoAndStop(3);
} else if (frameSelected = 4){
_root.gotoAndStop(4);
}
stop();
The problem I am encountering, is that no matter which button I click on (which determines the value of frameSelected), I only ever get taken to frame 3. I've reversed the order of the If Statement , and it only ever reads the value at the top.
I'm sure there is something monumentally simple that i am overlooking, but can't figure it out, and it's driving me mad.
Please help!!
Many thanks.
Problem Reading Param Values
Hello again everyone. I am having trouble reading variables in action script that are passed along in the html as a param tag within the flash object tag. Can anyone give me any ideas about what I might be doing wrong, or suggest another way to do this?
Here is the code:
HTML Code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="400" id="Untitled-1" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="Untitled-1.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="imagefilename" value="doot.jpg"></param>
<param name="videofilename" value="doot.flv"></param>
<embed src="Untitled-1.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="Untitled-1" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Here is the AS in _root:
Code:
imageNameText.text = imagefilename;
videoNameText.text = videofilename;
Reading Values From Attribute With For Loop
Hi,
I want to read attributes values from an XML file using an array. Here is the sample script which narrates my problem. Its fetching the values from the first node only and displays the same values twice.
M
22/121980
M
22/121980
Somewhere i am making a mistake in this Loop..can anybody works out where????pls,,,thanx
var oXML = new XML();
oXML.parseXML("<reportdatas><reportdata gender="M" dateofbirth="22/12/1980" address="XYZ" /><reportdata gender="M"dateofbirth="12/05/1982"address="XYZ" /></reportdatas>");
// Grab attribute names
var a = oXML.firstChild.firstChild.attributes;
// Enumerate name/value pairs
len = oXML.firstChild.childNodes.length
//trace(len)
attValue = [];
for(i=0; i<len; i++){
for(att in a){
attValue[i] = eval("a." + att);
trace(attValue[i]);
}
}
Ashish
Reading Values From Attribute With For Loop
Hi,
I want to read attributes values from an XML file using an array. Here is the sample script which narrates my problem. Its fetching the values from the first node only and displays the same values twice.
M
22/121980
M
22/121980
Somewhere i am making a mistake in this Loop..can anybody works out where????pls,,,thanx
var oXML = new XML();
oXML.parseXML("<reportdatas><reportdata gender="M" dateofbirth="22/12/1980" address="XYZ" /><reportdata gender="M"dateofbirth="12/05/1982"address="XYZ" /></reportdatas>");
// Grab attribute names
var a = oXML.firstChild.firstChild.attributes;
// Enumerate name/value pairs
len = oXML.firstChild.childNodes.length
//trace(len)
attValue = [];
for(i=0; i<len; i++){
for(att in a){
attValue[i] = eval("a." + att);
trace(attValue[i]);
}
}
Ashish
Database Values To Array Values
Hi all,
I've created a movie which uses a number of arrays to construct the elements of a flash-based gallery.
What I need is a practical method of getting values from a database into an array via an ASP page.
The plan was to load the variables into these arrays using the an asp page and a loadvars object to create a string (basically the array values in quotes separated by commas) which was then to be inserted into the parameters for the creation of the array. Needless to say this hasn't worked- the create array object seems to interpret the whole string as the first value in the array, i can't find a way of populating the array from just a single asp page.
I've given up with this method and really need a few pointers.
Thanks
Setting Array Values To Variables In Another Array
I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated.
A way I've tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an "apply" button is pressed which will set the values found in array2 to the variables in array1.
So...
Code:
PHP Code:
//variables on the main or root timelinevar1 = 1; var2 = 2; //... //within options mc timelinearray1 = [var1, var2]; array2 = [var1Display, var2Display]; apply.onRelease = function() { //set values in array2 to variables in array1 and update the main timeline's variables//... }
How would you do this so that var1, var2... are updated properly according to the values found in array2?
And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?
hope this all makes sense to everyone
Reading Array, Not Setting Array
Sorry everyone, I think I'm making a simple mistake but I just can't see it.
I'm using an array to store the order of something, I also make a backup of that array as a reference to remember what that first array looked like.
The problem comes when I'm using the values of that backed up array to populate the first array. What happens is that the backed up array gets it values overwritten, when all I wanted to do was read its values, not set its values.
Heres what I'm up to :
Code:
// Sets initial array
var ButtonOrder = new Array("One", "Two", "Three", "Four");
// Makes a backup of the initial array
ButtonOrderBackup = ButtonOrder;
// Changes the initial array with values from the backup
// (This is where I think the problems at)
ButtonOrder[0] = ButtonOrderBackup[3];
ButtonOrder[1] = ButtonOrderBackup[2];
ButtonOrder[2] = ButtonOrderBackup[1];
ButtonOrder[3] = ButtonOrderBackup[0];
// Trace Backup array
for (i = 0; i < ButtonOrderBackup.length; i++)
{
trace("Backup " + i + " " + ButtonOrderBackup[i]);
}
trace("");
// Trace initial array
for (i = 0; i < ButtonOrder.length; i++)
{
trace(i + " " + ButtonOrder[i]);
}
trace("");
Heres what the debugger feeds back to me :
Code:
Backup 0 Four
Backup 1 Three
Backup 2 Three
Backup 3 Four
0 Four
1 Three
2 Three
3 Four
I was wanting the initial array to have the values: Four, Three, Two, One. And the backup array to be how it was originally : One, Two, Three, Four.
What have I done wrong, thank you.
Populate An Array Values From An Array
ok i have this xml file
Code:
<artworkinfo>
<movieinfo>
<artLocation>cover1.jpg</artLocation>
<movie>Live Free or Die Hard</movie>
<plot>John McClane takes on </plot>
</movieinfo>
<movieinfo>
<artLocation>cover2.jpg</artLocation>
<movie>Meet the Robinsons</movie>
<plot>Lewis is a brilliant inventor </plot>
</movieinfo>
</artworkinfo>
the xml will tell where the cover art is the movie title and plot.
i want to populate my movie with this info what is the best approach to create empty movieclips using actionscript or create individuals MC , i try the second one and create 4 movieclips (cause the xml have 4 elements just post 2) and make an array of mc but i can find how to match the xml array to the mc array , this is the code for better explaining,
Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
movie = [];
plot = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
movie[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
plot[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
}
placeholder=new Array(loader1,loader2,loader3,loader4);
placeholder_total = placeholder.length;
for (e=0; e<placeholder_total; e++){
placeholder[e].contentPath=this.image[i];
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("movieinfo.xml");
the stage have 4 movieclips name loader1,loader2,ect... each mc have 2 dynamic text field one for title and one for the plot.
Reading Array
I have a array in a MC, pt = new Array(2, 4, 2, 3, 8, 6, 7, 8, 6, 9, 1, 4);
Second MC pt2 = new Array(1, 4, 2, 4, 8, 5, 7, 2, 8, 1, 4, 2);
A random number will be choosed from array1 and for array 2, for example Number 2 and Number 5.
Number 2 in the first array is the Number 4
Number 5 in the second array is the number 8
They are not the same so nothing will happen, but now comes my problem.
How can you make a action if both numbers are equal.
Something like If the number in array pt == Number in pt2
Please can anyone help me?
Reading From Array
I'm trying to make a photo gallery that loads thumbs from an array and when you click the thumb, it brings up the larger image. Pretty straight forward.
The problem is that I don't know how to tell which thumbnail the user clicked on, so that I can pull the appropriate larger image.
---------------
var thumbArray:Array = new Array("s1.jpg", "s2.jpg", "s3.jpg");
var arrayCount:Number = thumbArray.length;
//placement on stage
var startX:Number = 100;
var startY:Number = 100;
var count:Number = 0;
var shift:Number = 0;
while (count != arrayCount) {
//draw array images
var myThumbLoader:Loader = new Loader();
var url:URLRequest = new URLRequest(thumbArray[count]);
myThumbLoader.load(url);
myThumbLoader.x = startX;
myThumbLoader.y = startY + shift;
addChild(myThumbLoader);
myThumbLoader.addEventListener(MouseEvent.CLICK, makeMeBig);
//shift the next image below it
count = count + 1;
shift = shift + 150;
}
function makeMeBig(e:Event):void {
// what goes here?!
}
Reading Array Value
Hello, I have a sprite object which contains a textfield.
I have saved that sprite into an array.
How do I construct a trace statement to read the value of the textfield within the sprite, within the array.
thanks for any help.
Reading Array Variable
Code:
stop();
for(i=0;i<6;i++){
myHitArea = "ha" + i;
trace(eval(myHitArea));
eval(myHitArea).onRollOver = function() {
locateInArray = i;
var mcLabel = leadership_ary[locateInArray];
var mcName = mcLabel + "_mc";
eval(mcName).gotoAndPlay("rollOver");
}
eval(myHitArea).onRollOut = function() {
var mcLabel = leadership_ary[i];
var mcName = mcLabel + "_mc";
eval(mcName).gotoAndPlay("rollOut");
}
}
why won't the locateInArray variable locate the position in my array? It just says it is undefined. But when I put a 0 in there, it reads it fine!?!?
-Kac
Probes Reading An Array..I Think.
hi,
I need to get the information in the array left to be reflected in the the red box. using a small circle that changes color depending on the contents of the array cell.
In frame 1 of the root movie a prototype called drawCircle sets out the code to draw a single circle. I then created a function to pass this prototype the x,y and c_color for the circle, but for some reason in stead of drawing a grid of circles reflecting the array It just draws in the same spot or moves diagnal off the screen.
At the moment it just reads the last cell of the array and places it in the location of the first circle......
Please can someone take a look at the FLA file?
the main part of the actionscript is in frame 3 as follows
Code:
// this script scrolls through each cell starting @ 0.0
do {
for (grid_y=0; grid_y<10; grid_y++) { // moves accross left to right +1 each pass
// start turn/pass, every this untill end turn pass will be exicuted untill the all
// cells are calculated
rand_color =random(3); // creates random number between 0 and 2
grid[grid_x][grid_y] = rand_color; // inserts a random number between 0 and 2
c_color = (grid[grid_x][grid_y]); // reads the number/color of the current cell
circle(grid_x, grid_y, c_color); // call to function to draw circle
gridarray = (grid); // sends the text array to a var for display on stage
// end turn/pass
};
grid_x++; //moves the target down 1
} while (grid_x<10); // checks to see if last line of grid. if so contine
function circle(x, y, c_color) {
x = grid_x+6;
y = grid_y+6;
switch (c_color) {// selects hex number for color of each circle
case 0:
hex_color = 0x000000 ;
break;
case 1:
hex_color = 0xff0000 ;
break;
case 2:
hex_color = 0x0000CC ;
break;
default:
trace ("the cell has not been assigned a color")
}
var c = this.createEmptyMovieClip("c", 1);
c.lineStyle(1, 0x000000, 100);
c.beginFill(hex_color, 100);
c.drawCircle(10, x , y);
c.endFill();
}
Reading From Array PROBLEM
ok this is my code:
var myArray = new Array();
myArray = ["c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8"];
Button:
on (press) {
mc = myArray.splice(random(myArray.length), 1);
}
// this returns: from c1 to c8 randomly, fine
now here is the problem
on (release) {
_level0.cont.mc._alpha = 10;
}
It just do NOTHIG - I've got 8 movieClips inside "cont" MC
i want'em to change their alpha randomly taking the names from the array.
Reading Xml Data Into An Array
hi,
the code below should read the data from an xml file into an array then into a datagrid but its not working? i get the errors:
"TypeError: Error #1009: Cannot access a property or method of a null object reference.
at xmlreader_fla::MainTimeline/LoadXML()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader:nComplete()"
I'm not sure what any of theses errors really mean so i can't really debug the below code??
the function is called by
Code:
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
Could someone explain the errors to me?
Code:
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
trace(xmlData);
var nodes = xmlData.firstChild.childNodes;
for(var i:int =0;i<nodes.length;i++){
trace("New Data In Array"+i);
var xml_array:Array = new Array(nodes[i].firstChild.nodeValue);
}
for (var x:int = 0; x < xml_array.length; x++) {
var User_Login:String = xml_array[x];
dataGridMain.addItem({Username:User_Login});
}
dataGridMain.setStyle("fontFamily", "Verdana");
dataGridMain.setStyle("headerColor", "0xA6CBDD");
dataGridMain.setStyle("alternatingRowColors", ["0xF0F0F0", "0xFFFFFF"]);
dataGridMain.setStyle("rollOverColor", "0xDCEBF1");
dataGridMain.setStyle("selectionColor", "0xFFF97D");
dataGridMain.setStyle("selectionDuration", 300);
}
the xmlData variable holds data becuase it gets traced so i know the variable has values in it.
Thanks
Jon
Reading Array Problem
I cannot figure this one out. Maybe there is a key concept I am missing here and hopefully you guys can help.
The trace commands illustrate the problem - The playString function does not seem to be able to read the array created by the getChord function. I guess my question is why? It reads the default values listed below. Any guidance is greatly appreciated.
private var chordArray:Array = ["6,0","5,0","4,0","3,0","2,0","1,0"];
private var chordArrayCopy:Array = new Array();
A little background - getChord function is called from one class file and playString function is called from another. I don't know if this has anything to do with it. But that's why these are public functions within a public class.
Thanks in advance.
Attach Code
public function getChord(arr:Array):void {
chordArray = arr;
trace(chordArray); //6,1,5,0,4,0,3,0,2,0,1,0 (successful)
updateChordArray();
}
public function updateChordArray():Array {
chordArrayCopy = chordArray;
trace(chordArrayCopy); //6,1,5,0,4,0,3,0,2,0,1,0 (successful)
return chordArrayCopy;
}
public function playString(str:String):void {
var tmpArray:Array = updateChordArray();
for (var i:int; i < tmpArray.length; i++) {
var nestedNoteArray:Array = tmpArray[i].split(",");
if (nestedNoteArray[0] == str) {
playSound(tmpArray[i]);
trace(tmpArray); // 6,0,5,0,4,0,3,0,2,0,1,0 (UNSUCCESSFUL)
} else {
}
}
}
Reading Info Into 2d Array
hey
ive got a page "news.php?search=" outputting this:
id1=1&titel1=owaaa&text1=content2222212&ort1=Tranå s&
id2=4&titel2=sadas&text2=test tesxt Aneby&ort2=Aneby&
id3=9&titel3=titasd&text3=ingassdssadsdset&ort3=An eby Tranås ÖdeshÖG&
this is just an example of a possible output.
The output varies with what search criteria was given , there could be anywere from 0 to 400 hits, were they are listed in this way.
now im wondering how i would get this into a two dimensional array in flash
so that (array[row,column])
array[0,0]=variable id1, array[0,1]=contents of variable titel1 ... and so on..
so the 4 variables are listed in horizontal manner and
array [1,0]= content of the variable id2 and array[2,2]=contents of titel2 ..a nd so on ..
hope this wasent to confusing
thanks
//VoS
[AS] Loop Not Reading Array
I can't get my button's to trace out; it's not reading my rollovers. When I manually write it out (bottom) it works. Any help with what's wrong would be appreciated.
var btnAction:Array = new Array (homeBut, aboutBut, portBut, contBut);
// var btnAction:Array = [homeBut, aboutBut, portBut, contBut];
for (var i = 0; i < btnAction.length; i++) {
this.menuMC.btnAction[i].onRollOver = this.menuMC.btnAction[i].onDragOver = function() {
//this._parent.homeTxt.gotoAndStop("on");
trace("bob");
}
};
Written out it works.
/*
this.menuMC.homeBut.onRollOver = this.menuMC.homeBut.onDragOver = function() {
this._parent.homeTxt.gotoAndStop("on");
};*/
Reading Info Into 2d Array
hey
ive got a page "news.php?search=" outputting this:
id1=1&titel1=owaaa&text1=content2222212&ort1=Tranå s&
id2=4&titel2=sadas&text2=test tesxt Aneby&ort2=Aneby&
id3=9&titel3=titasd&text3=ingassdssadsdset&ort3=An eby Tranås ÖdeshÖG&
this is just an example of a possible output.
The output varies with what search criteria was given , there could be anywere from 0 to 400 hits, were they are listed in this way.
now im wondering how i would get this into a two dimensional array in flash
so that (array[row,column])
array[0,0]=variable id1, array[0,1]=contents of variable titel1 ... and so on..
so the 4 variables are listed in horizontal manner and
array [1,0]= content of the variable id2 and array[2,2]=contents of titel2 ..a nd so on ..
hope this wasent to confusing
thanks
//VoS
Reading The Array Works, Then It Doesnt...
hell there...i have this function that is supposed to build a menu:
Code:
//create menu items
rnMenu = new Array("Getting Started", "Starting Your Shift","Working With Basic Patient Information",
"Working With Exisisting Orders", "Working With Stage and Transfer Orders",
"Updating Patient Care Data", "Placing Orders", "Shift Change Procedure");
//build main menu
function mainMenu (whichMenu){
trace (whichMenu);
//set starting point for first menu item
startX = 26;
startY = 57;
//loop through array for menu button labels
for (i=0; i<whichMenu.length; i++){
attachMovie (menuButton, "menuButton" + i, i);
//pull button name from menu array
//and assign it to the dynamic text field
//inside the "menuButton" movie clip
_root["menuButton" + i].buttonText = whichMenu[i];
trace (_root["menuButton" + i].buttonText);
//position menu Items
_root["menuButton" + i]._x = startX;
_root["menuButton" + i]._y = startY;
//update startY for next menu item
startY = startY + _root["menuButton" + i]._height;
}
}
i call it with:
Code:
mainMenu (rnMenu);
the first trace in the function works fine, but when i try the second time it comes back as undefined, and the movie clips arent attaching at all.
[F8] Problem Reading Array Value In Function
does anyone know why "aButtons[i]" inside the "if" and "else" statements are not returning any values? do i have the correct syntax? thanks
code:
function ButtonFade(currentButton):Void {
trace(currentButton);
for (var i:Number = 0; i<aButtons.length; i++) {
trace (aButtons[i]);
if (aButtons[i] == "mcButton"+currentButton) {
trace ("mcButton" + currentButton + " if");
mcTween(aButtons[i], 0, 0, 0, 0, 30, 0);
aButtons[i].useHandCursor = false;
} else {
mcTween(aButtons[i], 0, 0, 0, 0, 100, 0);
aButtons[i].useHandCursor = true;
}
}
}
[F8] Reading Entire Contents Of 2D Array
I've got a 2D object array that hold varying data:
StudentArray[0].FirstName
StudentArray[0].LastName
StudentArray[1].FirstName
StudentArray[1].LastName
StudentArray[1].Grade
StudentArray[2].FirstName
StudentArray[2].LastName
StudentArray[2].Address
Each index number can hold different attributes (some might have "grade", others "address"), and we don't know what each in each set, as they are read in via outside data sources.
The question: How can I loop through each array element and whatever info might be stored in it, without knowing the name of the attributes ahead of time?
Thanks in advance!
Reading From An Array Into A Dynamic Txt Field
hi
i have 25 arrays setup (all following the same format) that hold info about a company and share prices for 5 days.
eg.
PHP Code:
company1_arr = new Array("Company1 name", "99.99", "88.88", "77.77", "88.88", "77.77")
these variables are stored in a seperate movie file that loads in at level 100
i then have dynamic txt fields in another movie where i am trying to load in relavant info from the arrays. i have tried the following but it does not work
PHP Code:
for (i=1; i<=25; i++){
// set company name
shares_mc.cName_txt.text = _level100["company"+i+"_arr"][0];
// set days share price
shares_mc.sPrice_txt.text = _level100["company"+i+"_arr"][dayNum];
}
the day num variable is used elsewhere but i've also used it to strip out the share price for each day as it will match the relevant element number in the arrays.
any help is greatful
cheers
[MX] Question On Reading Array Information
Hello, I'm working on making Back and Forward buttons (like browser buttons) for the projector file I'm creating. I have looked briefly at swfaddress, but I don't think that will work on my case since I want the file to run as a standalone movie, not in a browser. Anyhow, my question is how can I read the last value in my array? Or even better, how can I read the second to last value in my array? I've got the back button to work slightly by using the .pop() function. I ran into a problem though doing it that route. I don't necessarily need the information stripped from the array, I simply want to have Flash read the data within it. As I was typing this I had an idea and tried it, it seems to work out for the most part, some bugs still, but hey. I'm going to post the .fla to get opinions anyhow. Is there a better route to take then what I'm doing? Is there a more efficient way? Appreciate any comments. Thanks.
Mo
P.S. the forward is yet to be coded, and to nav you use the "2, 3, 4, and 5" keys. "Back Arrow" is to go back.
Reading Into A Nested Array Problem
hey all, now i have done some looking, and have seen many threads with how to look into a nested array, but i suppose since i never done one, most of things i see are too complex for me to get a grapple on this....
so here i go, i have let's say 3 arrays with images i'm nesting in an another array, and i want to trace to individual images inside each array, but all i can trace is through the images in the "allImges" array. i need another loop inside but don't understand how to trace individual imgs ...
PHP Code:
var web_pre = ["images/i_1.jpg", "images/i_2.jpg", etc ...]
var print_pre = ["images/p_1.jpg", "images/p_2.jpg", etc ... ];
var photo_pre = ["images/f_1.jpg", "images/f_2.jpg", etc ...];
//
var allImages_pre = [[web_pre],[print_pre],[photo_pre]];
//
objNum =30; // this is the amount of clips I'm loading imgs into will be more then length of my array
//
for (var i = 0; i < objNum; i ++) {
trace(i+" "+_root.allImages_pre[i%_root.allImages_pre.length][0]); //getting images in arrays here
for (var j = 0; j < allImages_pre.length; j ++) {
trace(_root.allImages_pre[i][j]); // how do i get imgs here?
}
}
i'd appriciate any help, as this must be really simple to lots of you....
Reading In An Array From A Text File
I'm trying to use a text file to load in some configuratin data (using actionscript 3) I have it working ok for simple stuff like gamename=Chess&gamescore=100 , etc... but some of the data needs to be in an array. Can someone please point me in the right direction to how I can read in an array from a text file?
Thanks!
Problem With Reading Object # In Array
Hello,
I've written some php (w/ help from hans and some others, thanks!) and loaded it into to flash to make a list of images to read into a photo gallery. Then I wrote the function in order to be able to change images:
ActionScript Code:
function changeSlide(number) { if (number>=0 && number<images.length-1) { currentSlide = number; loadMovie(images[number], "_root.placeholder"); }}
The length-1 part has to do with an extra string once the php is split, so dont worry. The images change on clicking buttons, which have the following codes:
forward
ActionScript Code:
on(release){ changeSlide(_root.currentSlide + 1);}
back
ActionScript Code:
on(release){ changeSlide(_root.currentSlide - 1);}
I am making an image count (ex. 1 of 12) or (ex. currentslide of total).
Now, the problem is. I've figured out how to dynamically make flash figure out how many image filenames were loaded (total):
ActionScript Code:
total.text = images.length-1;
but I can't figure out how to load the number slide it is on into a dynamic text field. This, for example, outputs [type Function] into the textfield:
ActionScript Code:
slidenum.text = number;
I tried a few things but basically I'm stuck. Any help or advice is extremely appreciated. I tried searching believe me its my last resort to actually post. If anyone needs more info about this to clarify, tell me I'll post it.
Thanks in advance!
Problem With Reading Object # In Array
Hello,
I've written some php (w/ help from hans and some others, thanks!) and loaded it into to flash to make a list of images to read into a photo gallery. Then I wrote the function in order to be able to change images:
ActionScript Code:
function changeSlide(number) { if (number>=0 && number<images.length-1) { currentSlide = number; loadMovie(images[number], "_root.placeholder"); }}
The length-1 part has to do with an extra string once the php is split, so dont worry. The images change on clicking buttons, which have the following codes:
forward
ActionScript Code:
on(release){ changeSlide(_root.currentSlide + 1);}
back
ActionScript Code:
on(release){ changeSlide(_root.currentSlide - 1);}
I am making an image count (ex. 1 of 12) or (ex. currentslide of total).
Now, the problem is. I've figured out how to dynamically make flash figure out how many image filenames were loaded (total):
ActionScript Code:
total.text = images.length-1;
but I can't figure out how to load the number slide it is on into a dynamic text field. This, for example, outputs [type Function] into the textfield:
ActionScript Code:
slidenum.text = number;
I tried a few things but basically I'm stuck. Any help or advice is extremely appreciated. I tried searching believe me its my last resort to actually post. If anyone needs more info about this to clarify, tell me I'll post it.
Thanks in advance!
Reading Of Array Items Works Until Online
I have a pre-loader code that loads all of my exteranl XML text files. When I click on a link several frames later, the appropriate file is pulled from the resulting Array and placed on the stage. It works perfectly offline, but as soon as I upload it I get random text files loaded instead of the correct one. Any ideas?
Thanks!
Code below:
//combine all the arrays into one and send it to the preloader
allText = new Array().concat(introText,textForCard1,textForCard2 ,textForCard3,
textForCard4,textForCard5,textForCard6);
textForContent = allText;
//text preloader starts here
var counter:Number = textForContent.length, ii:Number = 0;
for (var i:Number = 0; i<counter; i++) {
xmlToLoad = textForContent[i];
this["xmlData"+i] = new XML();
this["xmlData"+i].load(xmlToLoad);
// Check if data loaded
this["xmlData"+i].onData = function(src:String) {
if (src != "undefined") {
AfterData(src, num);
}
};
}
AfterData = function (src:String) {
++ii;
if (ii<counter) {
_level0["xmlToDisplay"+ii] = src;
} else {
_global._level0["xmlToDisplay"+ii] = src;
//stop();
play();
}
};
//hard coded line sends #2 in this case to function that places text on stage
textForStage = _level0.xmlToDisplay2;
Add Up All Values In An Array
Hi there
I need a bit of help I am have loads of trouble adding all the variables
In an array together. I just not sure how to go about doing it.
I have try using a for loop but the out put does match up with the
To the total of all the values.
Code:
for (k=0; k<totalprice.length; k++) {
allprice = parseInt(totalprice[k-1])+parseInt(totalprice[k]);
}
I know there is some thing wrong with this code but I am not sure what
Think I’ve been looking at it for to long.
Hope you can help
Thanks
Mac-10
Array Values..HELP
I want to create a memory game, but i got stuck here:
on (release) {
bricka=new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 ,19,20,21,22,23,24);
for (i=1; i<13; i++) {
arrayPos=random(bricka.length);
frameNum=myArray[arrayPos];
_root[bricka(i)]=frameNum;
myArray.splice(bricka,1);
}
}
the _root[bricka(i)]=frameNum; is wrong somehow.
it set bricka[1]=2,bricka[2]=3,bricka[3]=4 and so on, instead of
the random numbers that comes out from arrayPos.
what am i doing wrong ?
Array Values Into A For()
I'm trying to use the following values in a for so I don't have to type them out all the time.
But it ain't working [obvioulsy]!
Also I'd like to put it into a function so that I only have to type out the array values then call the function rather than repeating the for code all the time.
Any clues?
squares = Array("s2","s11","s19","s27","s30");
opacity = Array("15","22","40","17","12");
for (x = 0; x < squares.length; x++) {
_root.Grid[squares[x]].gotoAndStop(1);
setProperty(_root.Grid[squares[x]], _alpha, opacity[x]);
}
Array Values?
Hi,
I have two arrays which attach random movie clips to the stage. One array contains pictures and the other contains words. So for example the word array contains the words "apple" "dog" "cat" and the picture array contains pictures of an apple, dog and a cat. Ive got the movie clips to display randomly when you click a button, so a picture and a word displays at the same time.
Is it possible to assign a number to each item in the array, so for example the dogword = 1 and the dogpicture = 1
appleword = 2 and the applepicture = 2
catword = 3 and the catpicture = 3
so if the dogword and dogpicture are on the stage at the same time it is possible press a button to say that they match and then to add a point to the score?
Could anyone tell me if this is possible?
this is the code i am using to display my movie clips randomly
on (press) {
_root.blankpicture.attachMovie(_root.pic[random(3)], pic1, 0);
_root.blankword.attachMovie(_root.word[random(3)], word1, 0);
}
and then my arrays are:
pic = new Array ("applepic", "dogpic", "catpic");
word = new Array ("appleword", "dogword", catword");
I am using flash mx
thanks
Array Values
I am Using Flash MX 2004........
Ok i have an array with 4 elements wich are coordinates that i will be using for another function in my application.... they are as such
test[0]=12;
test[1]= 205;
test[2]=167;
test[3]=355;
now i have a function that will take the the array element values and do what they do with them.... for right now that function looks like this
function makeButton(x1,y1,x2,y2) {
trace(x1 + ", " + y1 + ", " + x2 + ", " + y2);
}
Now i know i can access the aray element values independently but i dont want to do that, what i want to do is concatenate the array and use its resulting string as the parameter values for the function when i call it....the Problem is it is not working and im not sure if can be done when ...I tried using test.join() and i also tried using test.toString() both of these output
12,205,167,355 which is exactly what i need to pass to my Function but even after setting a variable equal to these the output of the function is....
12,205,167,355, undefined, undefined, undefined.............. which means that the entire array.join() value is only being passed as the x1 value......Is there away around this? Help if you can...Thanks
Suzy
[F8] _x And _y Values From MC's In Array
Hi
I have created an Array with 5 duplicated movieclips. I am now trying to use the _x and _y values of these movie clips, but this value comes out as UNDEFINED. What am I doing wrong?!
Code:
for (var i:Number = 0; i < 5 ; i++) {
duplicateMovieClip(dot_mc, "dot_mc_" + i, this.getNextHighestDepth());
_root.dot_mc._x = Math.floor(Math.random() * Stage.width);
_root.dot_mc._y = Math.floor(Math.random() * Stage.height);
aDotArray.push("dot_mc_" + i);
trace(aDotArray[i]._x);
}
Array 2 Values
By any chance can I have 2 values per item?
line a name and a price?
Thanks
Array Values
Hi,
I have two arrays which attach random movie clips to the stage. One array contains pictures and the other contains words. So for example the word array contains the words "apple" "dog" "cat" and the picture array contains pictures of an apple, dog and a cat. Ive got the movie clips to display randomly when you click a button, so a picture and a word displays at the same time.
Is it possible to assign a number to each item in the array, so for example the dogword = 1 and the dogpicture = 1
appleword = 2 and the applepicture = 2
catword = 3 and the catpicture = 3
so if the dogword and dogpicture are on the stage at the same time it is possible press a button to say that they match and then to add a point to the score?
Could anyone tell me if this is possible?
this is the code i am using to display my movie clips randomly
on (press) {
_root.blankpicture.attachMovie(_root.pic[random(3)], pic1, 0);
_root.blankword.attachMovie(_root.word[random(3)], word1, 0);
}
and then my arrays are:
pic = new Array ("applepic", "dogpic", "catpic");
word = new Array ("appleword", "dogword", catword");
thank you.
Using Values From Array
ActionScript Code:
function setButtonDefaults(){
buttonPropertiesArr=["buttonOne``150", "buttonTwo``110", "buttonThree``128];
for(i=0; i<buttonPropertiesArr.length; i++){
var tempArr:Array = buttonPropertiesArr[i].split("``");
_root.tempArr[0].button_tpl_ins.outer._x=0;
_root.tempArr[0].button_tpl_ins.outer_orange._x=0;
_root.tempArr[0].button_tpl_ins.inner._x=0;
trace("arr length: "+buttonPropertiesArr.length+", arr: "+_root.tempArr[0]+", "+_root.tempArr[1]+", orange x: "+_root.tempArr[0].button_tpl_ins.outer_orange._x+", button: "+_root.tempArr[0]+", orange x buttonOne: "+_root.buttonOne.button_tpl_ins.outer_orange._x);
}
}
Ok, inside the function, for example:
tempArr[0] - traces as something valid
_root.buttonOne.button_tpl_ins.outer_orange._x - traces as something valid
_root.buttonOne.button_tpl_ins - traces as something valid
yet as soon as I replace a static value with an array value it becomes undefined:
_root.tempArr[0].button_tpl_ins.outer_orange._x - traces as undefined
_root.tempArr[0].button_tpl_ins - traces as undefined
I don't understand, and I don't know what to search for to find the answer...
Array Values
Hi everyone! I'm trying to assign values to my array. Here is what I have so far.
Code:
_root.createEmptyMovieClip("Placement", 2);
var shapes:Array = new Array("square", "circle", "triangle");
function selectshape():String {
//get the index for the letter
var index:Number = random(shapes.length);
//assign the letter to a var
var s:String = shapes[index];
//display letter
return s;
}
trace(selectshape());
//calls the function that will place the shapes on the stage
pulltogether(shapes);
function pulltogether(test:Array) {
for (var i = 0; i < test.length; i++) {
Placement.attachMovie(shapes[i], shapes[i], i+10, {_x:random(200), _y:random(200)});
}
}
What I want to do is say if "circle" is selected than I want to assign a value of "yellow circle".
Code:
if ("circle" ){
storedvalue="yellow circle"
]
else if ("square"){
storedvalue="blue square"
}
else if ("triangle") {
storedvalue="green triangle"
}
Hope this makes sense???
|