I'm trying to get this line to work, and it just won't do it. Can't figure it out.
pumpkinPage.this ["textBox" + i] = currentGuess;
That doesn't work, but if I do it like this
pumpkinPage.textBox0 = currentGuess;
it works fine. How do I get the first line to work?
What error are you getting?
Assuming pumkinPage is a dynamic object (Object, MovieClip etc), pumpkinPage["textBox" + i] = currentGuess; should work.
Related
Sorry ahead of time for french in my code or badly translated errors (idk what they are in english so Google translate). I'm working on a program at school to add all numbers, all even numbers or all odd numbers (different buttons) from an array (seperate file, called U2A2_Elements.as) and I'm getting multiple errors, I'm getting :
1061: Call for indexOf method might not be defined via the static int type reference at entier = (entier.indexOf(entierSaisi));
1119: Access to the length property can not be defined via the reference type static int" at for (var i=entier; i entier.length; i++).
1061: Call for pop method might not be defined via the reference type static int" at entier.pop();.
Any help would be greatly appreciated as I have no idea what to do with the code nor does the teacher or anyone else.
EDIT: Forgot to put the link to the code http://pastebin.com/5nyf3z7g
In your supprimerFunction() function, you forgot that your array is mesEntiers ( and not entier which is an int object ), so I think that you should write :
function supprimerFunction(event:MouseEvent):void {
var entierSaisi:String;
var entier:int;
entierSaisi = (txtEntier.text);
entier = int(entierSaisi);
entier = mesEntiers.indexOf(entier);
if (entier != -1) {
for (var i = entier; i < mesEntiers.length; i++) {
entier[i] = entier[i + 1];
}
mesEntiers.pop();
}
}
Of course, I try just to remove errors mentioned in your question, and not improve your function.
Hope that can help.
Hi I'm trying to make a powers calculator that displays every line calculated by the while loop in my actionscript3 code. When I run the program, the flash file only displays the last loop, can anyone help to make it work without using trace? I need it to display in the flash program. Here is my code:
private function evalue(event:MouseEvent = null):void
{
maMiseEnForme.font="Arial";
maMiseEnForme.size=14;
maMiseEnForme.bold=true;
maMiseEnForme.color=0x000000;
monMessage.x=270;
monMessage.y=375;
monMessage.autoSize=TextFieldAutoSiz...
monMessage.border=true;
monMessage.defaultTextFormat=maMiseE...
var base:uint;
var reponse:uint;
var puissanceCount:int=1;
var puissance:uint;
var reponseText:String;
base = uint(boiteBase.text);
puissance = uint(boitePuissance.text);
while (puissanceCount <= puissance)
{
reponse = Math.pow(base,puissanceCount);
reponseText=(base + "^" + puissanceCount + "=" + reponse + "\n");
monMessage.text=reponseText;
addChild(monMessage);
puissanceCount++
}
}
}
}
I have attached a picture of what appears in the .swf window:
P.S: I'm a newbie to flash.
Thanks in advance.
You can use "+=" parameter instead of "=" parameter to update a string variable by "adding string to it" instead of "refreshing it everytime", then you can show text after your while loop finished. You don't need to addChild(nonMessage) in everyloop, just move it after your while{} loop. SO: You just need "monMessage.text+=reponseText;" instead of "monMessage.text=reponseText;" and move your "addChild()" to next to your while loop.
First time poster here for Google Script related services, hopefully I put it in the right place! I'm encountering an error and I can't seem to find the right terminology to look up a solution. Below is the function. Within it I have a variable, string1, that I apply the split to. If I hard-code the value of the string (in the line commented out in the string), then it works and I receive the correct output. If, on the other hand, I try to pass that string into the function from another function, I receive the following error:
"TypeError: Cannot find function split in object Wed Oct 30 2013 09:00:26 GMT-0400 (EDT),danno,ticket,netid,request,mac,Error - Invalid Mac / Mac Not Found."
Note: My call to the function looks like this - formatEmailRow(completeEmailArray[i])
function formatEmailRow(rowToFormat) {
var formattedString = "";
var array1 = [];
var string1 = "";
///////////////////////
string1 = rowToFormat;
//string1 ="10/30/2013 9:00:26,danno,ticket,netid,request,mac,Error - Invalid Mac / Mac Not Found ";
///////////////////////
array1 = string1.split(",| ,|, ");
if (array1 != ""){
for (var i = 0; i < array1.length; i++) {
formattedString = formattedString + " " +(array1[i]);
}}
return formattedString;
}
Please help!
Thanks ahead of time, any advice is appreciated!
-Danno
You're getting that error because .split() isn't a method contained in the type of object you've passed in. Since you're new to this, it's worth a pause to read up on Objects and Methods - this is a quick overview.
You want to receive a String, but it seems that you're not. The problem will be with the code that's calling formatEmailRow().
My guess is that you're passing an array - probably all the cells in a row - but here's how you can check.
Add this line as the first line in your function:
Logger.log("rowToFormat = " + JSON.stringify(rowToFormat));
... then run, with your error. Check the logs - you want to see that you are getting a simple string. If you're getting an array, then you know what you need to fix. (Maybe you want to get the array after all!)
I get error code 1009 when I run this code...
for(var aObj:int = 1; aObj < 50; aObj++){
this["elementsSb.netDev"+aObj].addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
this["elementsSb.netDev"+aObj].addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
}
But when I run basically in this way...
elementsSb.netDev1.addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
elementsSb.netDev1.addEventListener(MouseEvent.MOUSE_UP, dragObject);
It works. Though, I don't want to make it this way because it's a bit messy, and I have 49 netDev objects.
Any proper way to deal with this guys. Thanks in advance.
When you use the fences to access to the properties of any objects the dot . withing the string identifier doesn't work.
The correct path must be:
this["elementsSb"]["netDev"+aObj]
I want to generate villagers for my game and then organize them into a list but I'm having a bit of difficulty, here is what it's supposed to look like and here is what it actually looks like. The code for generating kinsmen is:
var k = new kinsmen ;
menuArea.kinsmenDivider.addChild(k);
totalKinsmen++;
totalKinsmenAlive++;
k.name = "kinsmen" + totalKinsmen;
The code used for sorting them is:
for (var i:int = 1; i < (totalKinsmen+1); i++) {
if (menuArea.kinsmenDivider.getChildByName("kinsmen"+i) !=null) {
menuArea.kinsmenDivider["kinsmen" + i].y = menuItemCount * 107.5;
menuItemCount++;}}
That should look through the ID's of every kinsmen that's ever existed and when it finds the ID of one that's alive it should give it a place in the menu and continue going through the other IDs.
trace ("kinsmen" + totalKinsmen);
trace (menuArea.kinsmenDivider.getChildByName("kinsmen"+i));
Both always have the same values in my tests. The debugger posts the following error during runtime:
TypeError: Error #1010: A term is undefined and has no properties.
When I remove ["kinsmen" + i] it stops giving errors and the entire menu moves down each time a new kinsmen is generated so I know that's the part causing the issue but I don't know why or how to fix it and would appreciate help, all the above code is in my document class. I only started coding AS3 a few days ago so I'm still a bit shaky. Cheers for reading.
You access the clip correctly everywhere except
menuArea.kinsmenDivider["kinsmen" + i].y
shouldn't it be :
menuArea.kinsmenDivider.getChildByName("kinsmen" + i).y