Pushing Values From Text Field Into Array
Hello everybody!
Please help! I created dynamically a text field. If the user types a number to it and clicks on the button, it generates other x (number) text fields. Now the user should fill these fields with numbers too. What I would like to get: I want to get the numbers from these fields and put them into array, like the number from first field should be on position [0], from the second field on position [1] and so on. This is the part of the code, where the 2nd level fields are generated:
code:
for (var i = 1; i<=number_input_1stfield; i++) {
_root.createTextField("varValues"+i, 1000+i, 400, 20*i, 20, 20);
_root["varValues"+i].border = true;
_root["varValues"+i].borderColor = 0x000000;
_root["varValues"+i].background = true;
_root["varValues"+i].backgroundColor = 0xFEF9C2;
_root["varValues"+i].type = "input";
_root["varValues"+i].variable = "ar"+i;
myArray.push(WHAT TO WRITE HERE???);
}
How can I put the value of each field into an Array? I simply can't figure it out!
Any help greatly appreciated! Thanks a bunch!
Poco
FlashKit > Flash Help > Flash ActionScript
Posted on: 05-12-2005, 02:06 PM
View Complete Forum Thread with Replies
Sponsored Links:
Pushing XML Values Into An Array...
I need to push values from an XML file into the array. The problem is there may be 2-6 possible values... for example:
Code:
<options>
<option1>here's the first one</option>
<option2>here's the second one</option>
<option3>here's the third one</option>
</options>
but there could be 2, 4, 5, 6, etc. options in the <option> area.
I'm using this tutorial to create a quiz, but modifying it to load the data from XML: Create a Quiz Application Using AS3 Classes
In the tutorial the quiz pieces are pushed into an array like so:
Code:
quizQuestions.push(new QuizQuestion("What color is an orange?",
1,
"Correct",
"Incorrect",
"Orange",
"Blue",
"Purple",
"Brown"));
The first 4 things are easy to push in from my XML document:
Code:
quizQuestions.push(new QuizQuestion(quizXML.quiz.items.question[i].question,
currentCorrectAnswer, //CORRECT ANSWER
quizXML.quiz.items.question[i].correctFeedback,
quizXML.quiz.items.question[i].incorrectFeedback
//CHOICES SHOULD GO HERE
));
But I don't know how to push the choices into the array because it could be as many as 6 to as few as 2... how would I go about this? I don't need exact code, just an idea, but code can help for an example...
View Replies !
View Related
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?
View Replies !
View Related
How Do I Populate Scrolling Text Field With Multidimension Array Values?
In my Flash quiz, I have a detailed results page to which I want to post all the questions, answers, and whether the user answered correctly or incorrectly. All this information is stored in a multidimensional array and its successfully showing the results via the trace method.
My question is, what is the syntax for populating a dynamic text field with these results? Do I just write out one long line of AS with the newline command to separate the data? How would I go about applying bold to certain parts of the stored data that I will be showing?
Here is current code for my detailed results page:
function showResults(){
trace("Now showing results");
for(var i:Number = 0; i < NumberOfChallenges; i++){ //This calls the length of the original array (not the spliced copy)
//trace(NumberOfChallenges);
//Make sure that the correct answers are marked in the aShuffledChallenges array
trace("POPULATING TEXT FIELD WITH A RESULT NOW.");
trace("QUESTION:" + aShuffledChallenges[i][0] + newline); //write out the question
trace("ANSWER:" + aShuffledChallenges[i][3] + newline); //write out the answer
trace("Your answer to this question was:" + aShuffledChallenges[i][2] + newline);
}
}
showResults();
View Replies !
View Related
Pushing Text Into An Array With A Button
I have an array called lotr that is being displayed into a textfield. I've created an input textfield and a button to allow users to add to the array. My script looks like this:
Code:
addto_btn.addEventListener(MouseEvent.CLICK, lotrAdd);
function lotrAdd(event:MouseEvent):void {
var lotrNew:String = myvalue_txt.text;
lotr.push(lotrNew);
trace(lotr);
}
The output window shows new values, but the values don't get updated in the textfield. Is there such a thing as an update or refresh command for the player?
Thanks.
View Replies !
View Related
Compare Values From Array With A Random Value From A Field
Hello there
I'm working with a project that i need to load 3 external images, so i create an empty array to insert the values later.
I first write a test. This is what i did:
var objArray:Array = new Array();
for (var i:Number = 0; i < 5; i++) {
var numPush:Number = random(10);
objArray.push(numPush);
}
Working right, but i really now to write an script that verify if any of the values in the array are equal to the new value in the "numPush", if so then try another random value and verify again and if the new value is not equal to the other ones, push it to "objArray".
I try this, but get an error:
var objArray:Array = new Array();
for (var i:Number = 0; i < 5; i++) {
var numPush:Number = random(10);
for (var u:Number = 0; u < 10; i++) {
if (numPush != objArray[i]) {
objArray.push(numPush);
}
}
}
Any idea to do this ???
View Replies !
View Related
Using Text Field Values
I thought this was simple but I seem to be getting problems -
all I want to do is add a value to a input textbox and on the press of a button set a variable to that value - simple.
I have an input txtbox called myvalue
I have a button with -
on(press){
trace(myvalue);
}
I test it and get - _level0.myvalue
eh?!!!
monkey
View Replies !
View Related
How To Keep Text Field Text Values After Moving In Time Line?
I'm trying to to make flash application that requires the user to input data on several keyframes in the time line. I have buttons that take the user back and forth between the different keyframes so a user can input the needed data in what ever order they wish and/or go back and change it if they want.
My problems is, that as soon as the user clicks the button to go to another point in the timeline, and they come back, those input textfields that they entered data in are now empty again.
I hope that all makes sense. It seems that there must be an easy way (or even a hard way) to prevent this, and get these fields to retain the input data.
Any help would be GREATLY Appreciated!!!!!
Thanks in Advance!
View Replies !
View Related
Text Field Only Accepting Values Between 11 - 25
hi
im making a thing where people buying a product enter in the number of products they want to buy. There are different prices for different quantity ranges eg under 10, 11-25, 26-50 etc.
How can i make a text field where the user can only type in a number within that range eg....
...In the 11-25 text field column they can only type in a number between 11 and 25. If they type in 26 it brings up an error box?
thanks for any help
cheers
View Replies !
View Related
Saving Input Text Field Values.
Is it possible to save text entered by a user in a flash movie? The problem I have come across is this: I have two date fields with a default date of 00-00-0000, a city field, and a state field. The user is prompted to fill in the two date fields and the city field, and then the user is directed to another area in the movie to find the correct state abbreviation, and then returned to the previous area to enter the state abbreviation. When the user returns to the input screen, the data he or she has entered is gone. Is there a way to temporarily store/save the data that the user types into these fields?
View Replies !
View Related
Pushing On To An Array
I'm just learning how to do an array and am apparently not getting it completely.
I have data from an xml file that I'm loading into my .as file. I need to have each
piece of info pushed onto an array, but I keep getting the following error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at XMLLoader/resultsArray()
at XMLLoader()
at Document()
Attach Code
package
{
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class XMLLoader extends Sprite
{
private var electionData:XML;
private var urlLoader:URLLoader;
public function XMLLoader ()
{
var urlRequest:URLRequest = new URLRequest("http://www.kgwcreative.com/election/results.xml");
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, completeListener);
urlLoader.load(urlRequest);
resultsArray();
}
private function completeListener(e:Event):void
{
electionData = new XML(urlLoader.data);
//trace("electionData.toXMLString is " + electionData.toXMLString());
}
public function resultsArray():void
{
var xmlResults:Array = [];
xmlResults.push(electionData[0]);
trace (xmlResults);
}
}
}
View Replies !
View Related
Pushing Onto Array
I'm just learning how to do an array and am apparently not getting it completely.
I have data from an xml file that I'm loading into my .as file. I need to have each
piece of info pushed onto an array, but I keep getting error messages. Here's the
code:
package
{
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class XMLLoader extends Sprite
{
private var electionData:XML;
private var urlLoader:URLLoader;
public function XMLLoader ()
{
var urlRequest:URLRequest = new URLRequest("http://www.kgwcreative.com/election/results.xml");
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, completeListener);
urlLoader.load(urlRequest);
resultsArray();
}
private function completeListener(e:Event):void
{
electionData = new XML(urlLoader.data);
//trace("electionData.toXMLString is " + electionData.toXMLString());
}
public function resultsArray():void
{
var xmlResults:Array = [];
xmlResults.push(electionData[0]);
trace (xmlResults);
}
}
}
I keep getting this error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at XMLLoader/resultsArray()
at XMLLoader()
at Document()
any suggestions much appreciated!
View Replies !
View Related
Extracting Variable Values From An Input Text Field
Is it possible to extract numbers from a text input field so that I could perform actions. Say I had the following in a single text field:
REPEAT 4
FORWARD 50
RIGHT 90
END
Can I extract the number 4 and apply it to repeat variable, 50 to a Forward variable
Therefore:
_root.repeat=4
_root.forward=50
_root.right=90
Many thanks
Ol
View Replies !
View Related
Incrementing Values In A Dynamic Text Field Using Buttons
Second question today.
So I have a movie with 2 dynamic text fields and 2 buttons for each. I want one button for each field to increase the number in the text field by 5 and one to decrease it by 5. Here's how I'm trying to do this:
Code:
var leftTextVar:int = 0;
var rightTextVar:int = 0;
LeftText.text = leftTextVar;
RightText.text = rightTextVar;
LeftUpButton.addEventListener(MouseEvent.MOUSE_UP, leftScoreUp);
LeftDownButton.addEventListener(MouseEvent.MOUSE_UP, leftScoreDown);
RightUpButton.addEventListener(MouseEvent.MOUSE_UP, rightScoreUp);
RightDownButton.addEventListener(MouseEvent.MOUSE_UP, rightScoreDown);
function leftScoreUp(evt:MouseEvent):void {
leftTextVar += 5;
LeftText.text = leftTextVar;
}
function leftScoreDown(evt:MouseEvent):void {
leftTextVar -= 5;
LeftText.text = leftTextVar;
}
function rightScoreUp(evt:MouseEvent):void {
rightTextVar += 5;
RightText.text = rightTextVar;
}
function rightScoreDown(evt:MouseEvent):void {
rightTextVar -= 5;
RightText.text = rightTextVar;
}
here's the error I get:
[i]1067: Implicit coercion of a value of type int to an unrelated type String.
View Replies !
View Related
Pushing A Multidimentional Array
Hi,
I am trying to add an Array to an Array, if that makes sence...
myarray [[titel,preis,ID],[titel,preis,ID]];
now, how can I push/add another one like this: [titel,preis,ID]?
myarray.push(??HOWWWWWWWW???);
Does anybody know a very cool, basic, but complete array tutorial?
View Replies !
View Related
Pushing A Xml Node Into A New Array
Hello.
I am trying to store a xml nodes childrenNodes values into a duplicated movieClip, it works...almost, unfortuantely it's not storing all of the info in the node. If you can help that would be awesome-O.My code looks like this:
ActionScript Code:
for (i=0; i<Object.workNode.childNodes.length; i++) {
this["clone"+i].myJoin = new Array();
this["clone"+i].myJoin.push(Object.workNode.childNodes[i].childNodes[i].attributes.Name);
}
View Replies !
View Related
Pushing To An Array With A Function
Hi all,
I'm having problems pushing element to an array within a function. The first time i press the button it works fine. The problem is occuring if i press the another button, what it is doing is replacing the first item instead of adding it to the Array that was already created. Here is the code that i'm using:
PHP Code:
btn_1.onRelease = function(){
correctAnswer(this);
}
btn_2.onRelease = function(){
correctAnswer(this);
}
//it the answer is correct
function correctAnswer(btn_clip){
btnAdded = new Array();
//
btnAdded.push(btn_clip);
trace("btnPushed="+btnAdded);
//
}
Thanks,
Jake
View Replies !
View Related
Pushing To Multidimensional Array.
Can anyone help me with the 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 hope this makes sense!
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.
Where am I going wrong?
View Replies !
View Related
Pushing And Popping An Array
I have two buttons, one that adds a ball to an array and displays it and one pops a ball from the array and removes it from the display list, the add button works fine, however when i push the subtract button I get this message ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
Here is my code, thanks:
var iconArray:Array = new Array();
var ball:Ball;
var icon_count:int = 0;
add_btn.addEventListener(MouseEvent.CLICK,startAdd );
sub_btn.addEventListener(MouseEvent.CLICK,stopAdd) ;
function startAdd(evt:MouseEvent){
addBall(1);
}
function stopAdd(evt:MouseEvent){
subBall(1);
}
function subBall(num_ball:int){
add_btn.removeEventListener(MouseEvent.CLICK,start Add);
for(var i:int = 0; i < num_ball; i++){
iconArray.pop()
removeChild(ball);
trace(iconArray);
}
}
function addBall(num_ball:int){
for(var i:int = 0; i < num_ball; i++){
ball = new Ball();
iconArray.push(ball);
trace(iconArray);
addChild(ball);
ball.x = icon_count * 100;
ball.y = 100;
icon_count++;
}
}
View Replies !
View Related
Pushing To Multidimensional Array.
Can anyone help me with the 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 hope this makes sense!
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.
Where am I going wrong?
View Replies !
View Related
Pushing Items Onto An Array And Them Staying There
Hey ppl,
Im learning actionscript and im doing a simple translator that will also allow you to add words. I have a couple of arrays, one for the english and one for the translation.
I am using the push command to insert the contents of an input text box into the array which, when traced, does work, however, when i return to the main menu (backwards in the timeline) it will not remain in the array?
Is there some fundamental that im missing here (wouldnt suprise me!)
Thanks, in advance for anyone who can help.
ANdy
View Replies !
View Related
[F8] Pushing Data To An Array Then To DataGrid
i want to push the data that is entered by the user in Input text
in the datagrid
i'm using an array to push the data in, and then enter the data into the datagrid
this script in the first frame
PHP Code:
var myDataGrid:mx.controls.DataGrid;
myDataGrid.addColumn("Username");
myDataGrid.addColumn("score");
var myDP_array:Array = new Array()
myDataGrid.dataProvider = myDP_array;
script in button
PHP Code:
on (release)
{
myDP_array.push({Username:Std_txt.text,score:score_txt.text});
}
it doesnot work
View Replies !
View Related
Pushing Multiple Movieclips In An Array
my problem is simple... i have a lot of movieclips in the library, all of then are exported and have similar class names (class1, class2,...). to insert those movieclips in the array i use:
array.push(new class1());
but i dont want to make that for every single movieclip.
i even tried using a for function with a string to generate the of the movieclip but it was hopeless from start. (knew that strings wouldnt work, it was just a desperate guess).
So... is there anyway to do it?
View Replies !
View Related
Trouble Pushing Some Code Into An Array
Hi,
I’m trying to create an xml-based slideshow in flash and am having trouble pushing some code into an array.
The following is an extract showing how my xml file is structured:
Code:
<slideshow>
<garment url="formal01.jpg">
<title>Classic Design Formal Suit</title>
<style>5993</style>
<description>Olorperat illaor sim dio od dolore velit atie modiatem adio et ipit praesectem erit, vel ipsuscip er sit velit ipisciduis nulla.</description>
<price>$???</price>
<colours>Black</colours>
<sizes>87cm to 152cm</sizes>
</garment>
<garment url="formal02.jpg">
<title>Another title goes here</title>
<style>5994</style>
<description>Olorperat illaor sim dio od dolore velit atie modiatem adio et ipit praesectem erit, vel ipsuscip er sit velit ipisciduis nulla.</description>
<price>$???</price>
<colours>Black, White</colours>
<sizes>87cm to 137cm</sizes>
</garment>
</slideshow>
The urls are stored as attributes within the garment tag and the rest of the caption is stored with separate tags nested within the garment tags:
In my .fla file I have the following code:
Code:
var ssx:XML = new XML();
ssx.ignoreWhite = true;
var currentIndex:Number = 0;
var captions:Array = new Array();
var urls:Array = new Array();
ssx.onLoad = function(success) {
if (success) {
var ss:Array = ssx.firstChild.childNodes; //stores pictures as separate elements
for (i=0;i<ss.length;i++) {
urls.push("images/" + ss[i].attributes.url);
captions.push(ss[i].childNodes[0].firstChild.nodeValue);
}
frame_mc.images_mc.loadMovie(urls[currentIndex]);
captions_txt.htmlText = captions[currentIndex];
}
else
{
trace("XML file failed to load.");
}
}
ssx.load("formalwear.xml");
With the for loop I'm trying cycle through the ss array, pull out the url attributes as well as the rest of the caption, and assign the values to the arrays called "captions" and "urls".
Since my url was stored as an attribute, the following line of code works to push the url into the urls array:
urls.push("images/" + ss[i].attributes.url);
...however, the captions line entered as follows doesn’t push the captions into the captions array:
captions.push(ss[i].childNodes[0].firstChild.nodeValue);
It only outputs the information contained in the <title> tag, ie. Classic Design Formal Suit
Since the caption isn't stored as an attribute, I assume I need the following code to be pushed into the captions array, but I don’t know how to do it.
Code:
var caption:String = ""
caption += "<b>"
caption += ss[0].childNodes[0].firstChild.nodeValue;
caption += "
</b>";
caption += "<b>Style Number</b>
"
caption += ss[0].childNodes[1].firstChild.nodeValue;
caption += "
";
caption += "<b>Description</b>
"
caption += ss[0].childNodes[2].firstChild.nodeValue;
caption += "
";
caption += "<b>Price</b>
"
caption += ss[0].childNodes[3].firstChild.nodeValue;
caption += "
";
caption += "<b>Colours</b>
"
caption += ss[0].childNodes[4].firstChild.nodeValue;
caption += "
";
caption += "<b>Sizes</b>
"
caption += ss[0].childNodes[5].firstChild.nodeValue;
Can someone tell me how I can fix the code?
Appreciate any help offered.
View Replies !
View Related
Loading In A Array Of Values From A Text File
OK, I think I know how to load values using the loadVar command...but how do I go about loading an array of values from a text file? For example, the text file will be this format:
name = file1 size = 10 descrip = roses
name = file2 size = 12 descrip = tulips
name = file3 size = 13 descrip = daisies
And so I want three arrays, name[], size[], descrip[] to hold all these values...how do I set that up? And the code to do the loading from the textfile would be nice, newbie that I am .
View Replies !
View Related
Assigning Array Values To Dynamic Text
I've got an array with a lot of things I want to display in dynamic text fields, but I cannot get them to display. Just putting MyArray[1] in the varable field dosen't work. I've also tried assigning the varables in a for loop like this:
ActionScript Code:
["var"+i]=myArray[i];
also I've tried not useing the varable field and useing the instance filed
ActionScript Code:
["var"+i].text=myArray[i];
none of these worked for me. Any ideas?
View Replies !
View Related
Xml-based Slideshow - Trouble Pushing Code Into An Array
Hi,
I’m trying to create an xml-based slideshow in flash and am having trouble pushing some code into an array.
The following is an extract showing how my xml file is structured:
Code:
<slideshow>
<garment url="formal01.jpg">
<title>Classic Design Formal Suit</title>
<style>5993</style>
<description>Olorperat illaor sim dio od dolore velit atie modiatem adio et ipit praesectem erit, vel ipsuscip er sit velit ipisciduis nulla.</description>
<price>$???</price>
<colours>Black</colours>
<sizes>87cm to 152cm</sizes>
</garment>
<garment url="formal02.jpg">
<title>Another title goes here</title>
<style>5994</style>
<description>Olorperat illaor sim dio od dolore velit atie modiatem adio et ipit praesectem erit, vel ipsuscip er sit velit ipisciduis nulla.</description>
<price>$???</price>
<colours>Black, White</colours>
<sizes>87cm to 137cm</sizes>
</garment>
</slideshow>
The urls are stored as attributes within the garment tag and the rest of the caption is stored with separate tags nested within the garment tags:
In my .fla file I have the following code:
Code:
var ssx:XML = new XML();
ssx.ignoreWhite = true;
var currentIndex:Number = 0;
var captions:Array = new Array();
var urls:Array = new Array();
ssx.onLoad = function(success) {
if (success) {
var ss:Array = ssx.firstChild.childNodes; //stores pictures as separate elements
for (i=0;i<ss.length;i++) {
urls.push("images/" + ss[i].attributes.url);
captions.push(ss[i].childNodes[0].firstChild.nodeValue);
}
frame_mc.images_mc.loadMovie(urls[currentIndex]);
captions_txt.htmlText = captions[currentIndex];
}
else
{
trace("XML file failed to load.");
}
}
ssx.load("formalwear.xml");
With the for loop I'm trying cycle through the ss array, pull out the url attributes as well as the rest of the caption, and assign the values to the arrays called "captions" and "urls".
Since my url was stored as an attribute, the following line of code works to push the url into the urls array:
urls.push("images/" + ss[i].attributes.url);
...however, the captions line entered as follows doesn’t push the captions into the captions array:
captions.push(ss[i].childNodes[0].firstChild.nodeValue);
It only outputs the information contained in the <title> tag, ie. Classic Design Formal Suit
Since the caption isn't stored as an attribute, I assume I need the following code to be pushed into the captions array, but I don’t know how to do it.
Code:
var caption:String = ""
caption += "<b>"
caption += ss[0].childNodes[0].firstChild.nodeValue;
caption += "
</b>";
caption += "<b>Style Number</b>
"
caption += ss[0].childNodes[1].firstChild.nodeValue;
caption += "
";
caption += "<b>Description</b>
"
caption += ss[0].childNodes[2].firstChild.nodeValue;
caption += "
";
caption += "<b>Price</b>
"
caption += ss[0].childNodes[3].firstChild.nodeValue;
caption += "
";
caption += "<b>Colours</b>
"
caption += ss[0].childNodes[4].firstChild.nodeValue;
caption += "
";
caption += "<b>Sizes</b>
"
caption += ss[0].childNodes[5].firstChild.nodeValue;
Can someone tell me how I can fix the code?
Appreciate any help offered.
View Replies !
View Related
Display Array Values In Dynamic Text Boxes
Hello,
I use Flash Studio Pro to pull and send info to an Access db. My question is more of a Flash question not a Flash studio question. My code is as follows:
FRAME 1
var db = "myDB.mdb";
var passdb = "mypass";
fscommand("flashstudio.connecttodb", "db,passdb");
FRAME 2
var select = "SELECT * from myTable";
fscommand("flashstudio.selectfromdb", "select");
FRAME 3
fieldDelimiter = ",";
rowDelimiter = ";";
fscommand("flashstudio.getdelfromdb", "myList,fieldDelimiter,rowDelimiter");
FRAME 4
listArray = new Array();
listArray = myList.split(rowDelimiter);
<b>How do I display the values that were pulled into the array into the dynamic text boxes?</b>
Thanks
View Replies !
View Related
[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.
View Replies !
View Related
Add Text Field To Array Of Mc's?
trying to update some old code i found to have a couple text fields in each mc (section_i).
the code-
PHP Code:
section = new Array(10);
max = _root.section.length;
itemDepth = 1;
_root.createEmptyMovieClip("holder_mc", 1);
_root.holder_mc.createEmptyMovieClip("content_mc", 1);
for(i=0; i<max; i++){
_root.holder_mc.content_mc.attachMovie("section", "section_"+i, itemDepth);
curItem = holder_mc.content_mc["section_"+i];
_root.section[i] = curItem;
if(i == 0){
curItem._x = 0;
}else{
curItem._x =holder_mc.content_mc._width;
}
itemDepth ++;
}
lv=new LoadVars();
lv.load("mytxtfile.html");
lv.onLoad=function(success){
if(success){
_root.section[0].createTextField("txtfield", 1, 155, 10, 1, 30);
_root.section[0].txtfield.html=true;
_root.section[0].txtfield.htmlText = this.rules;
_root.section[0].txtfield.autoSize="left";
_root.section[0].txtfield.border=true;
}
}
i know i could type everything out in the if(success){}, but that would be tedious. any ideas?
View Replies !
View Related
Pushing Array Into Array
lets say I have
var myAr:Array = new Array(value, value2, value3);
var holdAr:Array = new Array();
holdAr.push(myAr);
when I trace out holdAr: value, value2, value3
however, if I trace out holdAr[0], I get the same as tracing holdAr.... how can I push an array into a new array and keep the indexes?
View Replies !
View Related
Re: Getting The Commas Out Of An Array In A Text Field?
Hi all,
I am trying to display an array of string elements in a dynamic text box with one element per line. The problem is occuring that each element has a comma before it, making it read wrong. I want to get rid of the comma. Below is the script
others = new Array();
for(i=0;i<_parent._parent.mcStore.answers[_parent._parent._parent.r].length; i++) {
if(_parent._parent.mcStore.answers[_parent._parent._parent.r][i] != "") {
others.push(_parent._parent.mcStore.answers[_parent._parent._parent.r][i]);
others[i] = others[i]+newline;
}
}
I have tried using others.join(" "); to trick flash into adding a (space) instead of the comma but it doesn't work.
Is it the push function that is adding these commas? How could I get rid of them? Any ideas would be really helpful as I have time working against me at the moment. thanks.
s
View Replies !
View Related
Array Info Into Text Field
i have an array inside array
This works:
a=_root.dat[3].M1;
inside the var of text field: _root.a
why does not this work
inside the var of text field: =_root.dat[3].M1
I believe it is another sintax inside the text field var to acces the array of arrays. I just cant figure it out what it is.
_root.dat.3.M1 doesnt work either
View Replies !
View Related
How To Load Array To The Text Field?
Someth. do I wrong
I tested it simply with this code and the textfield aslo displays only the last index c even if the array has content a,b,c and trace() outputs abc
Code:
var a:Array = new Array ();
var myArray:Array = new Array ("a", "b", "c");
for (i = 0; i < myArray.length; i++)
{
a[i] = myArray[i];
// output abc
trace (a[i]);
// fill only c
entries.text = a[i]
}
How can we fill it?
View Replies !
View Related
How To Load Array To The Text Field?
Someth. do I wrong :rolleyes:
I tested it simply with this code and the textfield aslo displays only the last index c even if the array has content a,b,c and trace() outputs abc :confused:
Code:
var a:Array = new Array ();
var myArray:Array = new Array ("a", "b", "c");
for (i = 0; i < myArray.length; i++)
{
a[i] = myArray[i];
// output abc
trace (a[i]);
// fill only c
entries.text = a[i]
}
How can we fill it?
View Replies !
View Related
Each Char In A Text Field Stored In An Array (MX)
how can i get the contents of a text field stored into an array so i can parse it letter by letter (so i can URL encode it).
i have absolutely no idea how to. im quite new to action script, but very familiar with other languages, so i can pick up on it quick.
thanks in advance, and any help would be much appreciated.
View Replies !
View Related
[F8] Assigning A Dynamic Text Field Using An Array
I have a script that places dots on a map via XML coordinates. The script below places a dot on the map and places the property name above the dot:
myVilla = new XML();
myVilla.ignoreWhite = true;
myVilla.onLoad = function(success) {
numimages = this.firstChild.childNodes[0].childNodes.length;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[0].childNodes[i];
this.thumbHolder = image_tn.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._x = this.picHolder.attributes.cx;
this.thumbHolder._y = this.picHolder.attributes.cy;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_i mage", 0);
this.thumbLoader.attachMovie("Dot", "Dot"+i, this.getNextHighestDepth());
this.thumbLoader.createTextField ("nametext", i+10,-35,-30,100,20);
this.thumbLoader.nametext.text = this.picHolder.attributes.villaname;
};
};
myVilla.load("myxml.xml");
The XML file looks something like this:
<img cx="50" cy="50" villaname="Villa Taz"/>
Where cx and cy are the coordinates and villaname is...well... the villa name.
Now rather than have the villa names appear through "createTextField" I want them to appear in a dynamic text box so that when you rollover the dot the name appears above it in a white box.
What works: The dots and names appear correctly on the map, and the rollover action shows a pop-up white box above the dot.
What doesn't work: When I rollover the dot, the white box appears but the villa name that is supposed to be in the "villaname_dt" field (located on the Dot clip) says "undefined". I'm using:
villaname_dt.text = this.picHolder.attributes.villaname;
To make a long story short, what value do I assign to villaname_dt.text=?????? that pulls from the villaname XML data from the array?
THANKS!
View Replies !
View Related
How To Deal With An Array To Handel Text Field?
hi all
i have this simple text creator in as3
Code:
var myText1:TextField = new TextField();
myText1.text = "my text is written here";
myText1.autoSize = TextFieldAutoSize.LEFT;
addChild(myText1);
how can i make AS3 have each word in its own field ...
myText1.text="my";
myText2.text="text";
myText3.text="is";
myText4.text="written";
myText5.text="here";
but i need those to be in array ..
and then how do i change each element in array , like myText1.x = 10; ...
thanks in advanced
View Replies !
View Related
How To Change Text In A Field Stored In Array
I'm dynamically creating some text overlays on top of other things. I am using the _root.createTextField to make them. I am storing them in an object array so I can reference them later to change the text if I need to. For the adding/changing text overlays, I have the following code:
Code:
// Array to store txt overlay info
var myOverlays = new Array();
// Add/update overlay text
addOverlay("o1", "Initial Text");
updateOverlay("o1", "Text has been changed");
// Add an overlay
function addOverlay(idx, txt)
{
var tmpObj = {};
var tmpTF = _root.createTextField("tmp", 100+myOverlays.length, 0, 0, 0, 0);
tmpTF.embedFonts = true;
tmpTF.autoSize = true;
tmpTF._alpha = 80;
tmpTF.text = txt;
tmpObj.idx = idx;
tmpObj.txtField = tmpTF;
myOverlays[myOverlays.length] = tmpObj;
}
function updateOverlay(idx, txt)
{
for(var i in myOverlays)
{
if(myOverlays[i].idx == idx)
{
myOverlays[i].txtField.text = txt;
}
}
}
The addOverlay() works and creates the text as I need it, but the updateOverlay() doesn't work. The text doesn't change and it even disappears. Anyone know why the update function isn't working?
View Replies !
View Related
Dynamic Text Field Array Problem
I am trying to generate three text fields using data from an array of text. The only text that is displaying is the content of the last array item. I have attached my code. Any ideas why three text fields are not being created with the proper array text in it?
Thanks!
- Aaron
Attach Code
_global.ticker = this;
var holder:MovieClip = ticker.createEmptyMovieClip("holder", ticker.getNextHighestDepth());
holder._x = 0;
holder._y = 0;
var newsArray:Array = new Array();
newsArray[0] = "Today is a great day";
newsArray[1] = "Tomorrow will be a better day if it rains";
newsArray[2] = "This whole week could be bad if we had a tornado...";
for (i=0; i<newsArray.length; i++) {
var textHolder:TextField = holder.createTextField("news"+i, this.getNextHighestDepth(), 0, 0, 300, 100);
trace(textHolder);
textHolder.text = newsArray[i];
this._y = i*10;
var format:TextFormat = new TextFormat();
format.color = 0xFFFFFF;
}
View Replies !
View Related
Populate Dynamic Text Field With PHP Array
I would like to be able to dynamically populate a dynamic text field (assuming that's the best component to use) with an array of data from PHP.
I have attached my PHP code and my Flash Code.
The PHP code is working fine and generating the array.
The first part of the AS code is working as I can see the pop-up window with the PHP array in it. However, I can't figure out how to get the array to display in the dynamic text box.
I have created a dynamic text box in flash with nothing in the 'instance name' box and 'events' in the var box.
What am I missing? Any help would be greatly appreciated!!!
Attach Code
PHP CODE:
$eventsQuery = "SELECT * FROM events_tb ORDER BY eventID DESC LIMIT 5";
$eventsResult = mysql_query($eventsQuery);
$i= 0;
while ($eventsRow = mysql_fetch_array($eventsResult))
{
echo "event$i=<a href='content.php?fcn=events&pieceid=".$eventsRow['eventID']."'>".$eventsRow['eventName']."</a>,";
$i++;
}
AS CODE:
myData = new LoadVars()
myData.ref = this
myData.load("flIndexEvents.php")
getURL("flIndexEvents.php", "_new")
myData.onLoad = function(succes){
if(succes){
for(var i=0; i<this.events; i++){
this.ref["events"+i].text = this["events"+i]
}
} else trace("Error loading data")
}
View Replies !
View Related
Output Array To Dynamic Text Field
Is there a better way to write this code? In a 'for loop' of some sort?
I want each item in the array to be displayed in a seperate textbox
Code:
slot0.text = inventory[0]
slot1.text = inventory[1]
slot2.text = inventory[2]
slot3.text = inventory[3]
slot4.text = inventory[4]
slot5.text = inventory[5]
slot6.text = inventory[6]
slot7.text = inventory[7]
slot8.text = inventory[8]
slot9.text = inventory[9]
View Replies !
View Related
Array Meets Dynamic Text Field
So an array walks into a dynamic text field and says.. oh wait..
I have an array that I am trying to output into a dynamic text field via this function:
ActionScript Code:
Barcelona = ["Barcelona:", "Apple", "25 - ", "2"];Output_Array = function(array_name){ for(i=0; i<array_name.length; i++) { output_txt.text += array_name[i] output_txt.text += " " }}
It outputs the array just fine, but what I want to do is add in a line break here and there to make it more beautiful. In the dynamic text field properties there is an option for "Render text as HTML". With the option checked I tried adding in <br> and/or <p> HTML tags but all it does is prints out the "<br>" instead of making a new line. (I also have the text field set to Multiline.)
Is there anyway to get it to have a line break?
View Replies !
View Related
[help] Dynamic Text Field Size With Array
I am trying to build a navigation using an array that populates a dynamic text field button MC. Right now the array is populating the dynamic text field in my button MC but it will not wrap if the text is longer than the width of the text field.
I tried selecting the field to be multiline with no luck. I also added the following lines into my code at the suggestion of another post I read.
ActionScript Code:
currentButton.buttonText.multiline = true;
currentButton.buttonText.wordWrap = true;
Neither of these attempts worked. I was wondering if anyone had any suggestions, maybe I am missing something from my code.
ActionScript Code:
var linkArray = [{name:"Message from the Chairman of the Board", linkType:"url", linkTarget:"http://www.google.com"},
{name:"Message from the President and CEO", linkType:"frame", linkTarget:"741"},
{name:"Government Affairs", linkType:"clip", linkTarget:"http://www.cnn.com"},
{name:"Professional Education", linkType:"clip", linkTarget:"http://www.cnn.com"},
{name:"Community Involvement", linkType:"clip", linkTarget:"http://www.cnn.com"},
{name:"Industry News", linkType:"clip", linkTarget:"http://www.cnn.com"},
{name:"Multiple Listing Service (MLS) Tools", linkType:"clip", linkTarget:"http://www.cnn.com"},
{name:"Financials", linkType:"clip", linkTarget:"http://www.cnn.com"},
{name:"2005 Board of Directors", linkType:"clip", linkTarget:"http://www.cnn.com"}];
for (i=0; i<linkArray.length; i++) {
newButtonName="button"+i;
attachMovie("button", newButtonName, i);
currentButton=eval(newButtonName);
currentButton._x=50;
currentButton._y=20+(20*i);
currentButton.buttonText=linkArray[i].name;
currentButton.buttonText.multiline = true; //This didn't work
currentButton.buttonText.wordWrap = true; //This didn't work
currentButton.goSomewhere=linkArray[i].linkTarget;
switch(linkArray[i].linkType) {
case 'frame':
currentButton.onRelease=currentButton.frameRelease;
break;
case 'clip':
currentButton.onRelease=currentButton.clipRelease;
break;
default:
currentButton.onRelease=currentButton.linkRelease;
break;
}
}
View Replies !
View Related
|