Access of undefined property (dynamic text box)
Hi guys,
I have a movie clip working as a button that is disabled after click. I need to add a scoring option, so that on click it also adds to the score. When I add the scoreGame function, it says the text box is undefined. Ideas?
Here's the code:
package
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class DisablingButtons extends MovieClip
var labels:Array;
var thisParent:*;
var score:Number = 0;
var goalScore:Number = 8;
public function DisablingButtons()
trace("it's working!");
labels = this.currentLabels;
this.addEventListener(MouseEvent.CLICK, scoreGame);
this.addEventListener(MouseEvent.CLICK, disableButton);
this.addEventListener(MouseEvent.ROLL_OVER, over);
this.addEventListener(MouseEvent.ROLL_OUT, out);
function scoreGame(myEvent:MouseEvent):void
score++;
score1.text = String(score);
if (score == goalScore)
gotoAndStop(201);
function disableButton(event:MouseEvent):void
for (var i:int = 0; i < labels.length; i++)
if (labels[i].name == "disable")
this.gotoAndPlay("disable");
this.removeEventListener(MouseEvent.CLICK, disableButton);
this.removeEventListener(MouseEvent.ROLL_OVER, over);
this.removeEventListener(MouseEvent.ROLL_OUT, out);
function over(event:MouseEvent):void
for (var j:int = 0; j < labels.length; j++)
if (labels[j].name == "over")
this.gotoAndPlay("over");
function out(event:MouseEvent):void
for (var k:int = 0; k < labels.length; k++)
if (labels[k].name == "out")
this.gotoAndPlay("out");
When you instantiate the class in your fla, you would pass the textfield to the class...
import DisablingButtons;
var btn:DisablingButtons = new DisablingButtons(score1);
addChild(btn);
And in your class file you would need to adjust it to accept the textfield such as what I show below. Just realize that I have manipulated the naming to preserve your score1 name at both ends of your code by naming the argument that the class sees differently (txt). Otherwise I would have normally used a differewnt variable name within the class than score1
package
import flash.text.TextField;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class DisablingButtons extends MovieClip
var labels:Array;
var thisParent:*;
var score:Number = 0;
var goalScore:Number = 8;
var score1:TextField;
public function DisablingButtons(txt:TextField)
trace("it's working!");
score1 = txt;
labels = this.currentLabels;
this.addEventListener(MouseEvent.CLICK, scoreGame);
this.addEventListener(MouseEvent.CLICK, disableButton);
this.addEventListener(MouseEvent.ROLL_OVER, over);
this.addEventListener(MouseEvent.ROLL_OUT, out);
etc...
Similar Messages
-
Printing a movie clip with dynamic text boxes
I've got a certificate inside a movie clip, and i want the
dynamic text box to dispay the user name, but for some reason it is
coming up undefined, even though i have the dynamic text box set to
finalname = _root.inputname, but it comes up as undefined on the
screen. :( Can anyone tell me where i am going wrong?
Is there a way to print just a specific movie clip on the
screen? I can only print all the frames in the movie and without
the dynamic text box... any help would be greatly
appreciated.assign the mouseChildren property of your movieclip to false.
-
Scene 1, Layer 'actions', Frame 1, Line 47, Column 2
1120: Access of undefined property instrument_txt.
this is my problem. any ideas. thanksI did try this and nothing happened, same error codes. The code works fine from CS5 and CS6 Flash versions. The animation runs well, the text displays where it should in the instrument_txt frame. It is when I try this in Flash CC that it creates the code error. here was an error that came up regarding text problems, something with FLT text converted to another text (I am not sure of the name of the text-type and the "FLT" I am not sure of either).
thanks -
Can I put Chinese and English characters in the same dynamic text box?
I'm translating a game into several different languages, one of which is Chinese. I've noticed that in a dynamic text box where English characters are included also, they aren't displayed when the .swf is exported. The font is embedded in the document with all characters selected. It seems like whatever language-character is first displayed in the text box, the other language cannot be. For instance, if there are Chinese characters first, then English, the English will not display, and vice-versa. Any work around on this? I am using Flash CS5 and Actionscript 2.0. Thanks!
Kglad - I'm not sure I follow your instructions for the fix. I assume you want me to set the _visible property to false via Actionscript ( textInvisible._visible = false; ). What is the purpose of this second text field - does it need any specific content in it to function? It doesn't seem to work to fix the problem but maybe I'm misunderstanding.
-
Hi,
At the moment im using the variable option of a dynamic text
box to load text. The variable is loaded into the swf via an
external htm file that has multiple variables in it (i dunno if
that makes sense but you know how you can load in a set of
variables from an html like eg. down below):
Anyway, now i want to have 10 different movie clips that act
as buttons, so that when they are clicked, they change the variable
of the dynamic text box soo it loads a different section of text
from the html file. I have tried the .variable property of the text
box but still no luck. I looked at another thread else where but i
dont understand exactly how they are changing it there. I'll copy
in the link anyway just incase it helps or someone can explain what
they are doing. Can anyone help me with this??
Thanks in advance for your help
Cheers
Damienhaha Oops. Heres the link to that other thread. My bad.
http://www.flashmove.com/forum/showthread.php?t=11070 -
Error, please help? 1120: Access of undefined property event
I have ActionScript 3 in two frames of my piece. In this 2nd frame, I get an error: "1120: Access of undefined property event" for "myXML=XML(event.target.data);" Can anyone help? I am not sure how to fix this.
var myloader:URLLoader=new URLLoader();
myloader.dataFormat=URLLoaderDataFormat.VARIABLES;
myloader.addEventListener(Event.COMPLETE, guestBookWriteFunc);
function guestBookWriteFunc(e:Event):void{
var loader:URLLoader=URLLoader(e.target);
var vars:URLVariables=new URLVariables(loader.data);
var url:String="makexml.asp";
var sendloader:URLLoader=new URLLoader();
var request:URLRequest=new URLRequest(url);
trace("xml page created");
var urlRequest:URLRequest=new URLRequest("makexml.asp");
var urlLoader:URLLoader=new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, fileLoaded);
urlLoader.load(urlRequest);
//Setting up the XML
var myXML:XML=new XML();
myXML.ignoreWhitespace=true;
var xmlList:XMLList;
//Setting up the data holder Arrays
var theUserName:Array=new Array();
var theUserEmail:Array=new Array();
var theUserComment:Array=new Array();
function fileLoaded(e:Event):void{
myXML=XML(event.target.data);
xmlList=myXML.children();
for (var i:int=0; i<xmlList.length(); i++){
var xmlName:String=xmlList[i].username;
var xmlEmail:String=xmlList[i].useremail;
var xmlComment:String=xmlList[i].usercomment;
theUserName.push(xmlName);
theUserEmail.push(xmlEmail);
theUserComment.push(xmlComment);
if(i==xmlList.length()-1){
updateText();
//Populating the text field to display messages
var maximumMessages:Number=5;
var currentMessages:Number=0;
function updateText(){
guestText.htmlText="";
for (var i=currentMessages; i<maximumMessages; i++){
guestText.htmlText+=("<b><u>Name:</u></b>" + theUserName[i]);
guestText.htmlText+=("<b><u>Email:</u></b>" + theUserEmail[i]);
guestText.htmlText+=("<b><u>Comment:</u></b>" + theUserComment[i]);
guestText.htmlText+=(".................................");
currentMessages=i;
myScroller.scrollTarget=guestText;You are more likely to get a reply if you ask in the Flash or ActionScript forum.
-
HTTPService error: Access of undefined property ...
For some reason, I get the error message "Access of undefined
property" for each element in the request ... and I only get the
error messages if the HTTPService is placed in an MXML Component
that is referenced from the main application. I don't get the error
messages, however, if the service is placed in the main
application.
What am i missing?
Here's my httpservice code:
<mx:HTTPService id="userRequest" url="
http://www.pixeldose.com/guestbook/comments.php"
useProxy="false" method="POST">
<mx:request xmlns="">
<username>{username.text}</username>
<emailaddress>{emailaddress.text}</emailaddress>
<website>{website.text}</website>
<comments>{comments.text}</comments>
</mx:request>
</mx:HTTPService>
Thanks in advance.
pixelflipI'm guessing that username, emailaddress, website and
comments are all variables in your application - so they won't be
in scope when you're in your MXML component.
You could
a) make all of these properties in your component and bind
them in your applciation.
b) make a single object with all these properties, make that
object a public property in your component and bind the object from
your application.
c) make a bindable variable in your component called
myApplication = Application.application as Application, and add
that to the front of your bindings.
d) make an public XML property in your component and define
the XML literal in your application.
e) put the HTTPService in your application.
Tim -
Displaying the result of a calculation in a dynamic text box
Hi folks,
I'm having a very minor issue here (operator error, I'm sure ). With the help of some folks here, I've created a series of calculations, and I've got that part down. Now, I just need it to show up in the movie.
I've created the dynamic text box in Flash (CS3), but when I hit test, it won't show up.
After all the calculations, I should have a figure that I call totalmoney. My dynamic text box is called total. The user doesn't need to hit anything for it to appear. It just appears as part of the movie.
Here's my code:
stop();
var startDate:Date = new Date(2010,0,12); // use your startyear, startmonth, startdate in the new Date() parameters.
var currentDate:Date = new Date(); // assuming user's clock is correct and in your timezone. else use server date/time.
var numberOfSeconds:Number = (currentDate.getTime()-startDate.getTime())/1000;
var interest:Number = (numberOfSeconds*0.74356);
var totalmoney:Number = (interest+15,000,000);
function displaytotal(evt:TextEvent):void {
total.text = "totalmoney";
Any thoughts?
Thanks!
NapoYou didn't have to bury any of the calculations in the function--leaving it as you had it is better. They could remain where they a=werew, and you'll probably find you want them outside it if you have other plans for using them. If left inside, they only have scope inside. In the programming world, it's good to think of functions as things that do one thing and one thing only (though it isn't often practiced that way)--it's called modular design.
When you place an event as an argument for a function, it typically means that there is an event listener that initiates the call to the function. If you work with buttons you'll see what I mean. But if the plan is to create your own call to a function when you desire it as such, not have it driven by an event listener, then you don't need to pass any event to it, though you may pass some other type of variable to it if need be.
For instance, what you have now will call the function without an argument because the function has the value built into its code....
displaytotal();
But you could also make the function a little more generic and set it up to recieve the value instead as an argument...
function displaytotal(amt:Number):void {
total.text = String(amt); // an earlier error of mine
displaytotal(totalmoney);
That would make your function a little more useful. Now it could be used to display other Number variables as well.
// my earlier error was that a textfield displays text, so you need to convert the Number value to s String.
Hope I'm not confusing you. -
Hi,
I would like to know whether FLASH AS3 has some option to get all the files names from a folder specified and show it in a dynamic text box? Whenever some new files added to this folder it should update the list accordingly.
Thanks for any information in this regard.Not particularly experienced in this field myself, but I've found its just easier to implement an XML file which lists the contents of the folder. It just means that when you upload a new file you have to add it to the list in the xml file also. No real hardship once you figure out the mechanics of it
-
How can I load a .TXT file into a dynamic text box?
I am sure that many people know how to load a .txt file into
a dynamic text box. But I do not. I want to be able to reference a
txt file from the server into the text box. So that when I change
the text file it changes in the flash movie without even editing
the flash file itself. Thank you.http://www.oman3d.com/tutorials/flash/loading_external_text_bc/
I think this is the simplest way to go :) -
Accessing the value of a text box input
how do i access the value of a text box on a jsp page..
eg:if the page name is Test.jsp and it has a text box named text.....You're mixing JSP and JavaScript. If you're staying within the same page, e.g. no get/post to another JSP, and you need to update values of a text field within a form, use pure JavaScript, such as:
<form name="fred">
<input type="text" name="USERID" size="15" onBlur="document.fred.PASS.value=document.fred.USERID.value;"><br>
<input type="text" name="PASS" size="15"><br>
</form>
This will change the value of the PASS field to the same as the USERID field, which is what I think you were trying to do.
Not to be rude, but in the interest of keeping the Java forum pure, I would look towards a JavaScipt forum if you wish to use pure JavaScript (http://freewarejava.com/cgi-bin/forumdisplay.cgi?action=topics&number=1&SUBMIT=Go)
bRi -
Access of undefined property _btn (problems with all my buttons)
I keep getting this error:
Scene 1, Layer 'actionscript', Frame 1, Line 1
1120: Access of undefined property tennis1_btn.
Scene 1, Layer 'actionscript', Frame 1, Line 7
1120: Access of undefined property tennis2_btn.
Scene 1, Layer 'actionscript', Frame 1, Line 13
1120: Access of undefined property tennis3_btn.
Scene 1, Layer 'actionscript', Frame 1, Line 19
1120: Access of undefined property tennis4_btn.
Scene 1, Layer 'actionscript', Frame 1, Line 25
1120: Access of undefined property tennis5_btn.
Scene 1, Layer 'actionscript', Frame 1, Line 31
1120: Access of undefined property tennis6_btn.
Here is a screen print of my code
I'll also paste below:
tennis1_btn.addEventListener(MouseEvent.CLICK, gotennis1);
function gotennis1(event:MouseEvent):void {
var gotennis1url:URLRequest= new URLRequest ("juniortennis.php");
navigateToURL(gotennis1url,"_parent");
tennis2_btn.addEventListener(MouseEvent.CLICK, gotennis2);
function gotennis2(event:MouseEvent):void {
var gotennis2url:URLRequest= new URLRequest ("adulttennis.php");
navigateToURL(gotennis2url,"_parent");
tennis3_btn.addEventListener(MouseEvent.CLICK, gotennis3);
function gotennis3(event:MouseEvent):void {
var gotennis3url:URLRequest= new URLRequest ("http://abbottsports.com/membership/memberships.php#tennis");
navigateToURL(gotennis3url,"_parent");
tennis4_btn.addEventListener(MouseEvent.CLICK, gotennis4);
function gotennis4(event:MouseEvent):void {
var gotennis4url:URLRequest= new URLRequest ("staff.php");
navigateToURL(gotennis4url,"_parent");
tennis5_btn.addEventListener(MouseEvent.CLICK, gotennis5);
function gotennis5(event:MouseEvent):void {
var gotennis5url:URLRequest= new URLRequest ("calendar.php");
navigateToURL(gotennis5url,"_parent");
tennis6_btn.addEventListener(MouseEvent.CLICK, gotennis6);
function gotennis6(event:MouseEvent):void {
var gotennis6url:URLRequest= new URLRequest ("tenniscourts.php");
navigateToURL(gotennis6url,"_parent");
Please help: i have a couple of them types of menus but this is the only one that is giving me problems. Here is the website I'm using them on:
www.abbottsports.com Working
http://abbottsports.com/football/football.php Working
http://abbottsports.com/motocross/motocross.php working
I was adding another on to our tennis page. I just copied the flash files to my tennis folders and renamed everything tennis instead of football including the buttons like you can see on the right side of the page in the photo.
I'm pretty sure it has something to do with me renaming the button, because I never changed anything in the code except replacing the word football to tennis in every spot. and renamed my buttons to tennis instead of football.
Thanks for any assistance.yeah they are all named right.
tennis1_btn
tennis2_btn
tennis3_btn
tennis4_btn
tennis5_btn
tennis6_btn
I uploaded it here:
http://abbottsports.com/tennis/flash/tennismenu.swf
http://abbottsports.com/tennis/flash/tennismenu.fla
http://abbottsports.com/tennis/flash/tennismenu.html -
Targeting Dynamic Text Box inside moviecip with variable
Hi,
How does one target a dynamic text box to change the border
color inside of a movie clip? Example below which does not work
theName = ("answerPrint" + arryCount);
boxName = ("box" + (arryCount+1));
_root.pagePrintPartA[theName][boxName].border = true;
_root.pagePrintPartA[theName][boxName].borderColor =
0x00cc66;Thanks for the reinforcement, but I should of indicated what
was what:
theName = ("answerPrint" + arryCount);// Name of Variable
inside Dynamic Text Box Inside MovieClip
boxName = ("box" + (arryCount+1));// Instance Name of Actual
Dynamic Text Box Inside MovieClip
_root.pagePrintPartA[theName][boxName].border = true;
_root.pagePrintPartA[theName][boxName].borderColor =
0xFF0000;
By certifying this script you showed me wher I went wron (not
seeing the forest from the trees). The last two lines should be:
_root.pagePrintPartA[boxName].border = true;
_root.pagePrintPartA[boxName].borderColor = 0xFF0000;
I was targeting backwards. Thanks alot DazFaz. -
How can i set the dynamic text box to show variable value?
In AS2, I can make a dynamic text box set a var name, when i
use button set/change the var value, this textbox can show the
value also.
but In AS3, dynamic text box can't add var name. than how can
i do it now?Set an instance name for the dynamic textfield. Then, to
populate the textfield with the value of a variable, use:
textFieldInstanceName.text = variableName -
Linking Dynamic text boxes?
Hi there,
This might be straight forward, but I would like to know how could one link dynamic text boxes so that the information would flow? In a way, the information would flow from:
(XML) Input A into BOXA00, BOXA01, BOXA02, BOXA03, etc.
(XML) Input B into BOXB00, BOXB01, BOXB02, BOXB03, etc.
(XML) Input C into BOXC00, BOXC01, BOXC02, , BOXC03, etc.
Any takers?Hi i recently have made a function that can calculate the amount of text that will fit into a specified text box. See my attached file. Notice that the box will only accommodate the text in red since that is the maximum it can display.
"This here one is a very very very long long long text that cannot really fit completely into this box so we will have to cut it at some index point"
My function getTextExtent will return an object with properties
nIndex -> which determines the index at which the text will be delimited
fExceeded -> is true if the text is longer than the allocated height of the text field.
Maybe you are looking for
-
How to convert Report Model to Report Designer DataSet
To all, I have a two part question. One is I am experiencing the error at the end of this question when migrating SQL Server 2005 SSRS Native Reports, the report uses a Report Model, to SQL Server 2008 SSRS Native. I bring the Report and Report Model
-
Hi Experts ! I have created an application using Tree UIBB to display the list output along with personalization property. The user can save the settings of the output table such as shuffling of column position and hiding / display of columns in the
-
Moving Song folder to external Hard drive
I'm new to Logic Express, and just starting my initial setup. What's the smartest way to move all my song folders to an external hard drive. I tried just dragging and dropping it which moved the folder, but when I try to save any new work it doesn't
-
Account assignment tab is missing in PR(item details)
Hi When we create PR,we select 'K' in the Account assignment in the item overview details,which will allow us to fill the details for G/L account and cost center in the item details,but to surprise account assignment tab is missing ,even we checked t
-
Hi, We are moving into the SAP ECC enviroment and need to understand the difference between the 2 Support Packs Release 600, Level 11 (support pack SAPKGPAD11) vs Release 604, Level 03 (support pack SAPK-60403INEAAPPL). Can anyone give us an indicati