ActionScript 3.0 :: Use Textfield Variable Name In Another Function?
Nov 25, 2009I have 3 textfields, and an eventlistener for each textfield which looks like this:
[Code]...
I have 3 textfields, and an eventlistener for each textfield which looks like this:
[Code]...
Some might know by know that I am working on a school project.But my knowledge of AS3 is not so big.My game is doing what it is supposed to do (for now).But the place where I declare (or something.It now looks like this:
Code:
public class game extends MovieClip
{
[code]......
I have a public variable and I am trying to set it, then read it from a different function:
public var str:String;
public function DailyVerse()
{
function create() {
[Code]....
My trace results says null. Why does it not give me "hello"?
how you would target a function's local variable through a concatenated variable string.For example:
var txt = "Hello World";
function testing(msg) {
var test1 = msg;[code].........
I'd expect the trace to be "Hello World" but rather is given "undefined". So if variables created outside functions are created on the main timeline, where are local function variables created and how would you access them?
I'm trying to combine PHP/SQL and Flash. I've got a problem now. I want to load a variable that contains an url to an image. so the variable is like this: [URL] Now I want flash to load the image, not the text. The variable is called 'img1' but the loadmovie function doesn't work when I put it in.
View 2 RepliesI want to monitor a variable. Whenever the variable value changes I want to call a function. In actionscript 2 I can use "watch" but in as3 what can do ?
View 1 RepliesI have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc. Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. 1120: Access of undefined property theAnswer. I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
[Code]...
is it possible to declare function this way
ActionScript Code:
function startShake(e:MouseEvent, num1, num2):void
what i mean is it possible to send to the function not only en event but also a variable and a second question how can i access
ActionScript Code:
function stopShake(e:MouseEvent):Array
this array that function return.
I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).
ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",
[code].....
I want to create a vector, then call a function that populates that vector with arrays. Fine. The only catch is the function itself will declare new array variables to put into the vector, but are these new array variables private to the function only?e.g. something like this
ActionScript Code:
public var vec:Vector.<Array> = new Vector.<Array>();
private function populateVec():void {
[code]....
Is this "kosher"? a was declared in the private function but added to something outside the function..?
I'm currently having a fair amount of trouble doing something that in it's concept is quite simple but appears to be hard to make happen.I am hoping to check a textfield, whatever is in that text field is then used as a variable to set another textfield, for example:
ActionScript Code:
var Na = 23
var C = 12
[code]......
I want to display some variables(cat1, cat2 and cat3) in a textfield(content_txt).I'm using a external AS-file.
I now have this:
code: //vars instellen
//titels
[code]....
I'm using createTextField to create a textfield. I have also created a input textfield with a variable called textline1 (I don't create the inputfield with as).I want to display the letters in the created textfiled that I'm typing in the input field. So this in my AS coed:
_root.createTextField("text1",1,100,100,300,100);
text1.variable = textline1;
format1 = new TextFormat();
[code]........
I simply want to do is display a variable via a Textfield. This was easily done in AS2 by making a var; "var1", then making a textfield with a var; "var2", and having code that var2 = var1...
But of course this can't be done now.. =(
I have a found a tutorial where you create a textfield version fot he variable.. this being the coding..
ActionScript Code:
var myText:TextField = new TextField();
myText.text = "Hello!";
myText.x = 200
myText.y = 200
addChild(myText);
But from my experience of AS in the past (AS2) Any Textfield which utilises "text here" is not possible to show coding such as
ActionScript Code:
myText = myText+=1;
Which is all I want to do. I want a variable. Editable with easy, simple coding such as the one just above. Which is displayed in a textfield. Which will constantly update it's display of the variable as the variable changes.
Just like what was easily done in AS2...
I have tried to find out tutorials etc, after finding out about the one above, I foudn one which was meant to be able to update the textfield. But ti utilised event lsiteners, of which I know nothign about, and the tutorials I've found didn't ..tutorial very well.. didn't even say what was with all the "package" stuff..
I've seen many times the following procedure to assign a variable name to a text field:
- We create a generic movieclip which contains a dynamic text field called "tittle" (for example)
- We add 4 instances of this movieclip to frame 1 in our main time line.
- We give them a different name (testMC1, testMC2, testMC3 and testMC4)
- We also add this little AS into frame 1:
testMC1.tittle = "Hello";
testMC2.tittle = "How";
testMC3.tittle = "are";
testMC4.tittle = "you";
If we run the fla we'll have the 4 movieclips on screen "Hello How are you". So far, it's ok, no problem and everything's understood. However I'm trying to implement a variation for this method which I need to use, but I'm not succeeding. I'd like to assign the variable values from a plain text file instead.
Hence, I create a plain text file called "Exampletext.txt". Inside this file I put the following variable values:
&variable1=Hello
&variable2=How
&variable3=are
&variable4=you
I add this piece of AS lo load the variables from the text file:
this.loadVariables ("Exampletext.txt");
And finally, I modify this bit too:
testMC1.tittle = variable1;
testMC2.tittle = variable2;
testMC3.tittle = variable3;
testMC4.tittle = variable4;
And well, it does not work at all!
I'm trying to get a variable that I get from a PHP-script to be a link in a textfield.
Right now I'm using an html tag to make a link to the information I want to display...
This works but I think its not good enough... I want to get a "rollOver" function on the Headline instead of a new line that says click me.
The following code displays in the textfield "content":
News
Headline <--Headline from the database
Teaser <-- Text from the database
Click me <-- Html link that displays the full text in a textfeild called "info"
[Code]....
I have taken variable in one function and want to use that value in another function.
View 2 Replieshow to get variable value from a function to a text box here is the code :
import fl.controls.ComboBox;
import flash.events.Event;
import flash.events.MouseEvent;
TxtAnswer = Array();
[code]....
.. i want that variable "sk1" to next scene text box ..i putted the code like this :
q1.text = sk1;
but it is not working..
I am having a bit of a headache with regards to this problem
Code:
class A {
private var tf:TextField;
private var canvas:MovieClip
[code]....
Why is it that the above code does not work? I need reference to the textfield so i can apply different TextFormats depending on the state of target_mc.Why does flash complain that Void is found where textField is expected?
I want to do something like this, is it possible to set a variable in a textfield?Pop this in a new Flash file and you'll get an error.
Code:
var blah_txt:TextField = new TextField;
stage.addChild(blah_txt);
I'm using the following code to try and change the font size of a textfield dynamically using a varaible but I can't get size to use the variable as a value however all the other variables I combine with the string works as intended just not size ....
PHP Code:
var chSize = 50;
trace(msg);
insID.htmlText += "<font size="+chSize.toString(16)+" fontFamily='Tahoma' color="#"+newColor.toString(16)+"">"+msg+"</font>";
[Code].....
Comparison of number or string is understandable. But how come when in flash AS3.0, we do :
var a:TextField = new TextField();
var b:TextField = new TextField() ;
[Code]....
Is their some Application-wide ID, that flash gives to each component instance. Or is it compairson of the strings ( comparing the whole path of each component )
I'm testing the equality of an input textfield and a string variable. For some reason, it's always resolves to false even when the values it traces out are the same.[code]
View 1 Replieshow to display a variable from within a class in a textfield on the stage? I've been trying for ages and can't figure it out...
View 4 RepliesI'm keeping score in a game. I have a text field with an instance name "finalScore". The score is a Number.
Code:
trace ("score = "+score);
finalScore.text = String(score);
trace ("finalScore = "+finalScore);
The output looks like this:
score = 10
finalScore = [object TextField]
The text field comes up with "1" not 10.
How can i make a dyn textfield with fixed height but variable with width?
ps what is the difference between
Code:
var pageContent:TextField;
vs
var pageContent:TextArea;
I am building a project where I got XML text displayed on a textfield. How can I change a specific word's color through actionscript 3 instead of doing it on XML? I though of creating a String variable for my word and then using that variable in my textfield.text, it works but is it possible to set a color for that variable?
View 3 Repliesi'm creating a completely dynamic form. i want to assign a variable name to a textfield and then pass that variable with a LoadVars() object.
here's a small piece of code i can't get working:
//create movieclip (used like a form)
_root.createEmptyMovieClip( 'dialog_body', 0 );
//create textfield input
[Code].....
bottomline: if i create a textfield using the traditional method and assign the 'var' it works fine. if i create a textfield dynamically at run time, and use the *.variable property, the variable is NOT sent..
I am currently creating a calculator in AS3. Since i need to create a lot of buttons, i need to make a function, so i dont have to write everything into the variable again and again.
View 2 Repliesme how I can use the variable from one function in another function?
For example:
function init():void {
var test:Number = 1;
}
[Code].....