Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Problems With Number Data Type In Text Fields



Hiya!

I'm working on a mathematical application but I have a questions I can't answer myself.

I have numbers in different textfields but when I perform addition on them to put the result in another textfield the numbers are just concatenated. Ex:

tres = uno_txt.text + dos_txt.text;
tres_txt.text = tres;

gives 9090 if uno and dos have 90, 90

played around with the var whatever:Number = alot on all the variables but to no avail. Also trid referring to the textfield data both as textfield variables and as the textfields text properties.

What can I do?



FlashKit > Flash Help > Flash ActionScript
Posted on: 06-05-2004, 11:17 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Additions Of The Number Data Type
I'm trying to get the sum of two number values in an XML file, so I'm doing this:


PHP Code:



    _root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
    _root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'

    _root.bar_y= _root.gallery_height+_root.spacing;
    trace(_root.bar_y); //outputs 20020 




The answer is supposed to be 220, but it comes out at as 20020 because the interpreter treats then as strings.

I can fix the problem by casting the type using the Number() method this way:


PHP Code:



    _root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
    _root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'

    _root.bar_y= Number(_root.gallery_height)+Number(_root.spacing);
    trace(_root.bar_y); //outputs 220 




This works fine, but is it *the right* way of doing it? Why is Flash treating my numbers as strings?

Unable To Convert XML String To Number Data Type
Hi all;
I wonder if someone has seen this problem. I am reading a number of text values from an XML file, including one which I would like to identify as the point value (it's a multiple choice game). When I read the childnode value, it is recognized okay in Flash;

ActionScript Code:
pointValue = xmlData.firstChild.firstChild.childNodes[nextCount].childNodes[1].firstChild.nodeValue;
trace window indicates "100" for pointValue (but this is a text string)

When I try to convert the data type to a number;

ActionScript Code:
pointValue:Number = Number(xmlData.firstChild.firstChild.childNodes[nextCount].childNodes[1].firstChild.nodeValue);
This statement (above) gives syntax errors.

If I try something like this;

ActionScript Code:
pointValue = xmlData.firstChild.firstChild.childNodes[nextCount].childNodes[1].firstChild.nodeValue;
pointValue_n = Number(pointValue);
trace window indicates "100" for pointValue
trace window indicates "NaN" for pointValue_n

This seems like it should be an easy step, but I can't figure out why it won't work??
Thanks in advance for any help.
- jim

Dividing Number X (30, 25, 13, Etc..) Amongst Text Fields (1-100 Fields)
Sorry about the title of this post, but I didn't find it easy to make a descriptive title.

What I'm trying to do, isn't a huge project, and I don't believe it's infinitely complicated. I just can't seem to wrap my head around it at the moment.

Hard enough to explain what I want...

Try to picture this:

Flash file opens up.
There are 6 text fields on the screen.
You enter the number 30 into a text field located near the top and press a button.
The 5 remaining text fields suddenly have numbers in them:Field 1: 30
Field 2:8
Field 3:9
Field 4:3
Field 5:5
Field 6:5

The idea is that I need a piece of code that will divide a variable amount of 'points' between a variable number of text fields. But not only does it have to be divided it has to be randomly and often unevenly divided.

So X = Number of text fields X / 30
Won't bring about the desired results.

I think I can (but haven't tried) divide 30 evenly easy enough, but since thats not what I'm after...

Any suggestions?

Seems to me that the final code will be one of those 'Wonder why I didn't see that' sort of things. But I can't get it.

Thanks for your help.

-Lem

[F8] Strict Type And Dynamic Text Fields
Hi
I was wondering what the best way is of doing this:

Say I am using a dynamic text field to display a message. If I create the text field on my stage and give it an instance name in the properties panel should I declare that variable in the script as well? If I am trying to stick to the strickt data typing way of doing things?

I mean, say the instance name of my text field is message_txt, should I create an action on the frame -

var message_txt:String;

or is this overkill?

XML Data To Text Fields
Hi,

I'm trying to display a single record out of an XML database into dynamic fields in my MovieClip. I need to be able return a single record based on the current time. Attached is a sample of my XML data.

I was wondering if this could be acheived with a DataSet filterFunction? If it is possible, what code would I need to include?

Finally, do I need to pass my full DataSet to an array or do I need to filter first & then pass to an array?

Thankyou.

Elton Bernardson.










Attach Code

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gigs>
<gig>
<date>23/06/2007</date>
<title>IBM Dealers Conference</title>
<displayStart>09:00</displayStart>
<displayFinish>13:00</displayFinish>
<displayTimes>10:00 am - 12:30 pm</displayTimes>
<logoPath>D:
oot_pathlogosibm_01.jpg</logoPath>
</gig>
</gigs>

Filter XML Data For Text Fields.
Hi,

I'm trying to display a single record out of an XML database into dynamic fields in my MovieClip. I need to be able return a single record based on the current time. Attached is a sample of my XML data.

I was wondering if this could be acheived with a DataSet filterFunction? If it is possible, what code would I need to include?

Finally, do I need to pass my full DataSet to an array or do I need to filter first & then pass to an array?

Thankyou.

Elton Bernardson.










Attach Code

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gigs>
<gig>
<date>23/06/2007</date>
<title>IBM Dealers Conference</title>
<displayStart>09:00</displayStart>
<displayFinish>13:00</displayFinish>
<displayTimes>10:00 am - 12:30 pm</displayTimes>
<logoPath>D:
oot_pathlogosibm_01.jpg</logoPath>
</gig>
</gigs>

Filter XML Data For Text Fields.
Hi,

I'm trying to display a single record out of an XML database into dynamic fields in my MovieClip. I need to be able return a single record based on the current time. Attached is a sample of my XML data.

I was wondering if this could be acheived with a DataSet filterFunction? If it is possible, what code would I need to include?

Finally, do I need to pass my full DataSet to an array or do I need to filter first & then pass to an array?

Thankyou.

Elton Bernardson.









Attach Code

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gigs>
<gig>
<date>23/06/2007</date>
<title>IBM Dealers Conference</title>
<displayStart>09:00</displayStart>
<displayFinish>13:00</displayFinish>
<displayTimes>10:00 am - 12:30 pm</displayTimes>
<logoPath>D:
oot_pathlogosibm_01.jpg</logoPath>
</gig>
</gigs>

Loading Different XML Data Into Different Text Fields.
I'm new in XML, and i would really appreciate your help on my problem.

So, basically main idea is to load different information, e.g: Name, E-mail, Duties of a team members next to the visual "tables" where are they seated from one XML file. I've mannaged to load information for one member, but can't do it for all the others, only sollution that I found is to make different XML file for each person , but I'm 100% sure there is a possibiltiy to load it via one XML for each member. Maybe I can give an ID to each "table"? Please help!
Here is my XML code:
Code:

<?xml version="1.0"?>

<tables>
   <table>
      <name>Jhon La la</name>
      <comment>qwertyqwertyqwertyqwertyqwerty</comment>
   </table>
   <table>
      <name>Xml bot</name>
      <comment>qwertyqwertyqwertyqwertyqwertyqwerty</comment>
   </table>
</tables>

And here is my AS code:
Code:

function loadXML(loaded) {
if (loaded) {
_root.name = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.comments = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
name_txt.text = _root.name;
comment_txt.text = _root.comments;
} else {
  trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("tables.xml");

Making A String Type Into A Number Type
The title is probably misleading and because I’m new to flash and coding this is probably a very simple problem. What I am trying to do is make a function in which I give the name of an instance, it adds the ._alpha and then have the function take the instance and have the instance go from being visible to invisible.

The following is the code that I have developed.



function dealpha(dename:Number):Void{
dealpha = (dename) ++ (._alpha);
for(i=0;i<100;i++){
dealpha -=1;};
};
dealpha(mc_mc);

The error that I get when I compile the file is this

Syntax error.
dealpha = (dename) ++ (._alpha);

Total ActionScript Errors: 1 Reported Errors: 1


I appreciate any help that I can get with this code.

Dynamic Text, Data Type, Variable Problem
I am trying to load one of 80 text fields into a dynamic text box. I have an Array that is filled with all 80 field labels in random order. My concept is that I should be able to pop the last field out of the array, set it equal to a variable, and use that variable in the statement defining the text of the text box. But it doesn't work. It returns undefined.

Example:


ActionScript Code:
nextQuestion = myList2.pop();myTextField_txt.text = externalData.nextQuestion;


The second line of the statement works if I hard code the text field name.

Example:


ActionScript Code:
myTextField_txt.text=externalData.question37;


But it does not work if I use a variable set to question37.

I think this may have to do with the data type of the variable. It is a string. Any ideas or suggestions?

Dynamic Text, Data Type, Variable Problem
I am trying to load one of 80 text fields into a dynamic text box. I have an Array that is filled with all 80 field labels in random order. My concept is that I should be able to pop the last field out of the array, set it equal to a variable, and use that variable in the statement defining the text of the text box. But it doesn't work. It returns undefined.

Example:


ActionScript Code:
nextQuestion = myList2.pop();myTextField_txt.text = externalData.nextQuestion;


The second line of the statement works if I hard code the text field name.

Example:


ActionScript Code:
myTextField_txt.text=externalData.question37;


But it does not work if I use a variable set to question37.

I think this may have to do with the data type of the variable. It is a string. Any ideas or suggestions?

[F8] Loading XML Data In Dynamic Text Fields?
Hi all,

I have tried everything possible to get an XML file to load data into dynamic textfields on my site. However, NOTHING has worked and, trust me, I have been at this for a long time. Can anyone suggest any good tutorials for this? Preferably one that discusses both the creation of the XML file and the AS in the .fla? I'm desperate! Thanks

Displaying XML Data In Dynamic Text Fields With AS3
Hi Everyone,

I am trying to display XML data into dynamic text fields on my timeline.

So I am working on my personal site, justinbrinkerhoff.info (the swf on there is old, and I'm updating it now). I am working the fla file, and am reading data from an xml file. The problem is, the syntax I am using is not showing the values inside the dynamic text field, and upon exporting the swf.

So here is what I have.

The fla/swf are both named jbDOTinfo
I am working within a keyframe of which I created to show my portfolio; Flash, *ML, PHP, Rails, etc... Well I am working in frame 27, which I created to house the "page" so to speak for my PHP portfolio page.

Within frame 27, I have the main content on one layer, and the embedded actionscript on another layer. Now, on the main layer, the dynamic text field instance name is phpInput. My XML filename is php.xml, located in a child directory named xml (xml/php.xml).

Here is my AS3 syntax:


Code:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadPHPxml);
xmlLoader.load(new URLRequest("xml/php.xml"));
function LoadPHPxml(e:Event):void {
xmlData = new XML(e.target.data);
parsePortfolioPHP(xmlData);
}

function parsePortfolioPHP(portfolioPhpInput:XML):void
{
trace(portfolioPhpInput.item);

var title = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
// url = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
phpInput.text = title;

}
I can find my way around fairly well with ActionScript, but this is hurting my head. When I export the SWF file, and I navigate my way to frame 27 through the SWF, I get this output:


Code:
TypeError: Error #1010: A term is undefined and has no properties.
at jbDOTinfo_fla::MainTimeline/parsePortfolioPHP()
at jbDOTinfo_fla::MainTimeline/LoadPHPxml()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
I know its something simple, I just cant think what it is. Everything I've tried so far gets me the same or similar results.

If anyone could help clear this up for me, it'd be greatly appreciated.

MX - Dynamic Text Fields Using External File Data
I am new to Flash MX ActionScript. I understand how to create dynamic text fields.
Code:
_root.createTextField("myTextField",0,200,200,200,30);
with (myTextField) {
text = "Dynamic Text";
background = true;
backgroundColor = 0xCCCCCC;
}

myTextFormat = new TextFormat();
with (myTextFormat) {
font = "Arial";
size = "20";
color = 0x000000;
}

myTextField.setTextFormat(myTextFormat);
I also understand the process to load external text from a text file into a text field with a name assigned to the Var: field.
Code:
loadVariablesNum("text.txt",0);
I have been unable to combine the two processes to load external text into a dynamically created text field. I appreciate any assistance.

Sincerely,

LoNeRaVeR

Emailing Data Found In Input Text Fields
Hi,
I have a simple form that users fill in various "input" text fields like "Name", "Email", etc... now all I want is when the click on the "send" button, it should automatically send an e-mail to "info@...".

I got it to enter the proper recipient email address and subject but there's not content. What am I missing?

Thanks,
Phalconheart









Attach Code

var url:String = "mailto:info@myclients.com";
var request:URLRequest = new URLRequest (url);
var variables:URLVariables = new URLVariables();
variables.subject = "Booking Request";
variables.recipient = "info@myclients.com";

function sendForm(event:MouseEvent):void{
variables.item = itemChoice.text;
variables.citychoice = var_cityChoice.text;
variables.appt_time = var_timeChoice.text;
variables.client_name = var_clientName.text;
variables.address = var_clientCity.text;
variables.cellphone = var_clientCellPhone.text;
variables.email = var_clientEmail.text;
variables.ref1 = var_clientRef01.text;
variables.ref2 = var_clientRef02.text;
variables.handle = var_clientHandle.text;
variables.findUs = var_clientFoundUs.text;
variables.comments = var_clientComment.text;
url = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request);
}

this.btn_sendInfo.addEventListener(MouseEvent.CLICK, sendForm);

Dynamic Text Fields Are Blank After Loading Data
This is really bugging me...

In my AS I load XML data into an array for titles which will be used later in dynamic text fields. I trace this, all of the titles load fine into the array. I use a for loop to attach a movie which has a dynamic text field inside of it. The movie attaches just fine, in a verticle menu just like I want it. The dynamic text field has the right instance name inside of it. I set the text field instance name to the array, but it didn't show anything in the text field. I knew it was there since it was Selectable and the selection cursor pops up whenever I hover over where it should be. So I create a string variable like so to try and go around whatever is messing it up:


Code:
var item_mc = t_thumbs_mc.attachMovie("theatreThumb","t"+k, t_thumbs_mc.getNextHighestDepth());
item_mc._y = 110 * k;
item_mc._x = 0;
var play_name:String = t_titles[k];
item_mc.play_txt.text = play_name;
trace(item_mc.play_txt.text);
that's a bit taken out of context (it's based on the Squirrels XML tutorial) but it works fine when I trace the t_titles[k] and play_name and everything. when the trace in that code runs, it gives me a list of all the names that are SUPPOSED to be there, but they don't show up when I actually look at the movie. The dynamic field is named properly, not animated in any way, not anti-aliased, using Arial as its font, the color doesn't match the background, all of that stuff I've checked. Would it be easier for me to just dynamically generate the text field itself too instead of having one in the attached movie? I didn't think I would have to since having the dynamic field in the attached movie clip works in the Squirrels XML tutorial.

I'd upload the full FLA but it has a dozen other things in it which are working fine.

Loading MySQL Data Into Flash Text Fields
Hey, I'm trying to load two fields from a MySQL database into one dynamic text field in Flash.

I use a PHP script to move the data from MySQL to Flash and Flash uses the PHP to load the data.

Heres the PHP script...

<?PHP
//Connects to the database
$link = connNBT();

//Get the stories from the mysql database
$query = "SELECT story, UNIX_TIMESTAMP(date) FROM newsTable ORDER BY date ASC ";
$result = mysql_query ($query)
or die ("Query failed - $query");

$i = 0;
$returnData = "";
while( $myrow = mysql_fetch_row($result) ) {

$story = $myrow[0];
$date = date("F j, Y", $myrow[1]);

$returnData .= "&story" . $i . "=" . $story . "&date" . $i . "=" . $date . "&";
$i++;
}

mysql_close ($link);

$data = "num=$i&" . $returnData;
echo $data;

//Function to connect to database
function connNBT() {
$link = mysql_connect ("localhost", "username", "password")
or die ("Could not connect");

mysql_select_db ("databasename")
or die ("Could not select database");

return $link;
}
?>



...and heres the actionscript I have in the first frame of my Flash movie...


function getStory() {
var myStories = new LoadVars();

myStories.onLoad= setStories;
myStories.load("storyEngine.php",myStories,"POST");
}
function setStories() {
if( this.num != "" ) {
for(var i=0; i<this.num; i++) {

displayNews.htmlText = this["story"+i];


}
}
}



____

Can somebody tell me why Flash isn't loading the MySQL data??

Cafe Townsend // Using External Text Data To Fill Fields
Hey guys,

I am new to Flash and I have started to play around with text parsing and I have run into a problem. I am trying to using the Cafe Towsend sample then include an external text file to fill the description information. I keep getting a Undefined message. Any assistance would be greatly appreciated. EDIT: I just realized that if I apply one of the variables from the loaded text file to this section


Quote:




menu_mc.title_txt.text = this._parent["image"+currImage+"title"];
menu_mc.description_txt.text = this._parent["image"+currImage+"desc"];




that particular variable works. So I guess the real question is How do I cycle through all the variables depending on what image is being view?

Heres my actionscript code

Code:
//Load Text File
loadText = new LoadVars();
loadText.load("description.txt");
loadText.onLoad = function() {
image0T = this.image0T;
image0D = this.image0D;
image1T = this.image1T;
image1D = this.image1D;
image2T = this.image2T;
image2D = this.image2D;
image3T = this.image3T;
image3D = this.image3D;
};
//the following 4 sections contain the data
//for each menu item
/* 0 */
var image0title:String = image0T;
var image0desc:String = image0D;
var image0uri:String = "image0.jpg";
/* 1 */
var image1title:String = image1T;
var image1desc:String = image1D;
var image1uri:String = "image1.jpg";
/* 2 */
var image2title:String = image2T;
var image2desc:String = image2D;
var image2uri:String = "image2.jpg";
/* 3 */
var image3title:String = image3T;
var image3desc:String = image3D;
var image3uri:String = "image3.jpg";

var currImage:Number = 0;
var totalImages:Number = 4;

menu_mc.title_txt.text = this["image"+currImage+"title"];
menu_mc.description_txt.text = this["image"+currImage+"desc"];

for (var i:Number = 0; i<totalImages; i++) {
slideShow_mc.slides_mc["holder"+i].loadMovie(this["image"+(i)+"uri"], slideShow_mc.slides_mc.getNextHighestDepth());
}

slideShow_mc.slides_mc["holder4"].loadMovie(this["image0uri"], slideShow_mc.slides_mc.getNextHighestDepth());

// function for the Next button
function nextMenuItem(eventObj:Object) {
slideShow_mc.gotoAndPlay("slide"+(currImage));
if ((currImage+1)>=totalImages) {
currImage = 0;
} else {
currImage++;
}
menu_mc.title_txt.text = this._parent["image"+currImage+"title"];
menu_mc.description_txt.text = this._parent["image"+currImage+"desc"];
}

// add the event listener for the Next button
next_btn.addEventListener("click", nextMenuItem);
and finally heres what my text file looks like

Code:
&image0T=this is the title for 1&
&image0D=this is the description for 1&
&image1T=this is the title for 2&
&image1D=this is the description for 2&
&image2T=this is the title for 3&
&image2D=this is the description for 3&
&image3T=this is the title for 4&
&image3D=this is the description for 4&

Displaying Data From A Text Field As A Number
Hi,
I'm trying to create a (supposedly!) simple page, whereby a user enters their body weight into an input text field, clicks a submit button, and then gets a number returned (which is the weight in kg's divided by 30). (This is to calculate how many glasses of water a person should drink a day).

So I've created an input text field, with the instance name: weight_txt
and a dynamic text field, with the instance name: bottles_txt
and a submit button, with the instance name: submit_btn

I've put this ActionsScript code on the main timeline:
Code:

var weight:String;

submit_btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void
{
   weight = weight_txt.text;
   bottles_txt.text = parseInt(weight):Number/30;
   addChild(bottles_txt);
}



The error that keeps coming up when I test the code is this:
1078: Label must be a simple identifier

Please help!

Displaying Tablular Data, Scrolling Multiple Dynamic Text Fields
Hi guys,

I'm trying to figure out the best way to do this, and am not entirely sure so would like your input on what you reckon is the best method to use.

Flash system is for a publishers site, with simple ASP backend used with loadVars etc to load in text. What is wanted is a display of all the titles with release date, author name and range in a scrollable table.

Initially I had thought of doing the following. Create the text fields, apply text, attach scrollbars with 3 invisible, set all scrollbars to have the same scrollPosition. However this seems to be a bit of overkill, and on some of the office macs it seems to use an excessive amount of processor power and slows everything down.

Anyone have any better ideas?

R

XML Data Displayer, Help Adding Multiple Data Fields Relating To XML
I recently used the Displaying XML Data tutorial, but cant seem to figure out how to add more dynamic text fields and populate them with more <person> and <comment> attributes.

Here is my code:

function loadXML(loaded) {
if (loaded) {
_root.inventor = this.firstChild.childNodes[2].childNodes[0].firstChild.nodeValue;
_root.comments = this.firstChild.childNodes[2].childNodes[1].firstChild.nodeValue;
name_txt.text = _root.inventor;
comment_txt.text = _root.comments;
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("inventors.xml");

and xml:

<?xml version="1.0"?>

<inventors>
<person>
<name>Thomas Edison</name>
<comment>Inventor of many things such as the incandescent lightbulb.</comment>
</person>
<person>
<name>Doug Engelbart</name>
<comment>Invented the mouse at the Stanford Research Institute</comment>
</person>
<name>Patrick</name>
<comment>did this xml file</comment>

</person>
</inventors>

I am trying to display Patrick - and did this xml file.

Could you please help me figure out what I am doing wrong here?

"text" Data Type? Please Help
hello, im kinda stumped on this one and know it's probably dumb obvious but please help.

in most of the FlASHtyper .fla files you can download the text that it displays is set like this:

-------------------------------------------
text = "<text goes here>";
i = 1;
max = length(text);
kerning = "10";
size = "10";
setProperty ("char", _visible, "0");
-------------------------------------------

im confounded as to how to have more than just one line of text be displayed. ive found that the "text" variable is not a normal variable cuz if i change it to text1 then it stops working.

could someone 1) explain to me what kind of variable "text" is (is it an array?) and 2) maybe tell me how to have more than one line of text placed into that "text" variable.

yes i have tried + newline + and "
" and "
" and even concating strings with those at the end and none work. what am i doing wrong?

thanks in advance,

-Oly

Help: Casting String Gotten From Xml To A Number Type
Hi all,

I have a major problem, I have parsed the data from an xml doc to global vars in flash and need to use a few of them as numbers for things the position of "nodes" on the screen. However I can not cast the data stored as a var to a number or int value.

For example in the code below when the set Node button is pressed it traces the "Node's" current X value, then the value in the global var gotten from the xml, which contains the x position of where to place the Node.

Next it creates a new var of Number Type and assigns it the Number value of the string in global var.

It then traces the new value of SNtopLeftX and sets the x pos of the Node's movie clip to the value of SNtopLeftX

However the Node doesn't move and this is the output I get from the traces

Start Node is at x = -734.5
nod_topLeftX is 16
TopLeftX = 16
SN TopLeftX = NaN

I do not understand why I am getting NaN when the string of nod_topLefX is 16, any ides?
-------------------------------------------------------------------------------------------------------------------







Attach Code

butNodeSet.onRelease = function() {

trace ("Start Node is at x = " + mcStartNode._x);
trace ("nod_topLeftX is " + nod_topLeftX);

var SNtopLeftX:Number = Number(nod_TopLeftX);
trace ("StartNode TopLeftX = " + SNtopLeftX);
mcStartNode._x = SNtopLeftX;
}

Help: Casting String Gotten From Xml To A Number Type
Hi all,

I have a major problem, I have parsed the data from an xml doc to global vars in flash and need to use a few of them as numbers for things the position of "nodes" on the screen. However I can not cast the data stored as a var to a number or int value.

For example in the code below when the set Node button is pressed it traces the "Node's" current X value, then the value in the global var gotten from the xml, which contains the x position of where to place the Node.

Next it creates a new var of Number Type and assigns it the Number value of the string in global var.

It then traces the new value of SNtopLeftX and sets the x pos of the Node's movie clip to the value of SNtopLeftX

However the Node doesn't move and this is the output I get from the traces

Start Node is at x = -734.5
nod_topLeftX is 16
TopLeftX = 16
SN TopLeftX = NaN

I do not understand why I am getting NaN when the string of nod_topLefX is 16, any ideas?


------------------------------------------------------------------------------------------------------------------- This is my Code
butNodeSet.onRelease = function() {

trace ("Start Node is at x = " + mcStartNode._x);
trace ("nod_topLeftX is " + nod_topLeftX);

var SNtopLeftX:Number = Number(nod_TopLeftX);
trace ("StartNode TopLeftX = " + SNtopLeftX);
mcStartNode._x = SNtopLeftX;
}

How Do You Set The Type(:Number, :Boolean, Etc) Of An Array?
i know, it's a simple question, but i've been looking around for a good ten minutes and all i can found about arrays is how to make them, via "var arraynamehere:Array=new Array()", and none of them are typed. can you even specify a type for an array? TIA ^^

Scrolling Number Fields
Hey,
can anyone tell me how the easiest way to create 3 or 4 scrolling number fields. My goal here is to move them across the screen similar to the intro on After shock.com.
Please help me out

Need URGENT Help Re: Required Telephone & Enquiry Type Fields In Contact Form.
Hi all

Thank you in advance. Help needed urgently. I need to complete the contact form I'm working on at work by the end of today if possible. I'm stuck and can not find the solution anywhere.

I need the AS to make users type only numbers in the 'Telephone Field' and users to only have the option of typing 'general' OR 'sales' in the Enquiry Field.

This is what I have currently in the 'Email Field'. I need something similar.

Attached is an image of the contact form I'm working on.


Code:
TextField.prototype.isEmail = function() {
if (this.text.indexOf("@") == -1 || this.text.indexOf(".") == -1) {
return false;
} else {
return true;
}
};
Kindest regards
Ben

Dynamically Setting Number Of Form Fields
I’m trying to make an entry form on a web page that the number of lines can be set by the user. What it’s going to be is basic book information broken into separate fields for title, author, etc. with a new line for each book. The results will then be e-mailed to me using php or cgi script.

The problem I’m having is one person might enter just one book, and another might have 20, with each entry is going on a separate line. The problem is making a form that generates the correct number of lines with all the necessary fields. My first, and only thought was having a small text entry box at the top where the user types in the number of books they want to enter, then click a button. Then the form would generate the correct number of lines needed. I know that I could just set up a simple multi line text entry box, but I want to control the entry of all the information.
I don’t know if I just need another cup of coffee, or three, but nothing seems to be working. Any ideas?

Flash MX - How Do I Make It Correct If They Type A Special Number... (PASSWORD)
1)I got a box in a room its a button when u click it i want it to goto like another screen that has the box zoomed up and u can type numbers in it.......
WHAT I NEED:
Stopping it so it doesnt goto next frame auto
When you click it it gos to another frame (zoomed up text box)
How u make it so they can type in box....
How i make it so when they type 45 it gos to another screen saying GJ
- i cud prolly do this if it wasnt in spanish =-
Gimme english OR if u know spanish OR hot keys ... OR the root text and how to do it


THIS IS SPANISH VER SO IF U KNOW A HOT KEY OR SPANISH TELL ME ill figure it out!!!

When Do I Need To Data-type
hello;

I have on frame 1 of the main timeline:

ActionScript Code:
var mcvo = new Object();

mcvo.pvo_lc:LocalConnection = new LocalConnection() ;

but I get : "1078: Label must be a simple identifier."

according to http://curtismorley.com/2007/06/19/f...s3-error-1078/
my approach is
Quote:




really bad code




any thoughts??

thanks
dsdsdsdsd

Help Me Out With Data Type
I have a function that accepts the Class name of a clip in the library as a parameter. What should the data type be?

The function works fine without a data type. I also do not want to set type to the Class name, which I assume would work, but would limit the usefulness of the function.

Second question, the function returns a reference to the newly created clip. I set the type here to MovieClip which works. But, in some cases I set the Base Class of clips add via the function. Which doesn't cause any trouble. But brings up the question, can you set the data type to a class that is inherited?


PHP Code:



public function add_content( id ):MovieClip {
    if ( current_content != null ) {
        Tweener.addTween( current_content, close_tween ); 
        old_content.push( current_content );
    }
            
    current_content = new id();
            
    for ( var p in starting_values ) {
        current_content[ p ] = starting_values[ p ];
    }
        
    Tweener.addTween( current_content, open_tween );
    host_mc.addChild( current_content );
    return current_content;


Data Type From XML
I've pulled in some data into an array but it seems to have pulled everything in as strings. I need to be able to do calculations with some of the data so one element in the array should be a number data type not a string.

Is there a way to assign the data type without using components or to convert the data type?

XML
<account>
<name>Cash at bank</name>
<number>10</number>
<value>108000</value> <-- Should be a number
<type>debit</type>
display>true</display>
</account>

Actionscript
for (var stringNode:XMLNode = childNode.firstChild; stringNode != null; stringNode = stringNode.nextSibling, j++){
accountArray[i][j] = stringNode.firstChild.nodeValue;
}

What Data Type To Use?
I'm making a project that will include a index class "main document class" that will makes a catalog from a catalog class that will hold a group of items from a items class. Each item that the catalog class makes will have a number of properties such as "name, ID, color, type, date and so ... ". The catalog class will show as a list of thumbnails on the stage, each thumbnail will have properties of that item in the catalog with events.

Simply put if you don't already know I'm making a catalog but, what data type should I use for the items that will be visible on stage with a image and a lot of properties? Sprite, movieClip or may even just a plain old object?

I really want to make this a stricter OOP project so that I may utilize AS3's stronger points. That and I 'm really new to this so I think I better learn it now.

Data Type Q
Wondering what the data type should be for a a variable when you want to make it's value a color. (Color.... duh) but... Here's what happens.


ActionScript Code:
var buttonBorderColor:Color = "0xc21F0C";


I get the compile error of found string where color is required. - Obviously because I'm setting the value to a string.

Now..


ActionScript Code:
var buttonBorderColor:Color = 0xc21F0C;


I get the compile error of found Number where color is required.

Of course I can just remove the data type and make this work but just for my own knowledge I'd like to know what the correct data type should be.

Thanks guys

New Data Type
Hello;
I've created a class that handles colors. I'm posting it here in case someone's interested.
But that's not the purpose of my thread;
My question is: is there any way to create a new data type?
Here is the behavior I'm looking for:

ActionScript Code:
var color:yColor = new yColor()color = 0xFF0000;


Basically, I want the = to act like a getter setter function.
Like the string, number, etc data type. Is there a way to do this?
I'd also like the yColor class, when used, to behave like a uint. Currently, you would have to do this:

ActionScript Code:
someFunctionThatRequiresColor(color.color)

I want to be able to do simply this:

ActionScript Code:
someFunctionThatRequiresColor(color)


I tried extending the uint class, but it's a final class.
So...any thoughs?

A bit off-subject, but might be handy some day, you'll find attached our classes to handle color. They aren't finished though. I plan to add a function to change the hue dynamically (animate it), as well as a few other ideas.

How To Use MovieClip Data Type In AS 2 ?
var mc:MovieClip;

mc.onEnterFrame = function(){
trace("i'm workin'");
}


the function associated with mc.onEnterFrame is not working.
so .. the question is: what is MovieClip data type for?

is it possible to change snippet of code above to invoke the function
without using _root.createEmptyMovieClip ?

What Data Type Is A _level?
Hi all -
I am playing again..
so I have a AS2 class that I am passing a String containing a movieclip to load using loadMovieNum() and a Number to use as the _level to load it into. There is no problems with the loading, but I am also doing some preloading, so I need to be able to use the GetBytesLoaded, and GetBytesTotal method of the "_level" to be loaded.

I am having a hard time trying to understand how I should reference the _level in question once I pass it to the Class.


//usage (preloader_mc, loadTarget, loadLevel)
var myPreloader = new scripts.CustomPreloader(preloader, "cme_heavyLoad.swf" , 1);


PHP Code:



class scripts.CustomPreloader {
    public var loadTarget:String;
    private var loader_mc:MovieClip;
    private var loadLevel:MovieClip;
    function CustomPreloader(preLoader_mc:MovieClip, whatToLoad:String, whereToLoad:MovieClip) {
        this.loader_mc = preLoader_mc;
        this.loadTarget = whatToLoad;
        this.loadLevel = whereToLoad;
        init();
    }
    private function init() {
        loadMovieNum(loadTarget, loadLevel);
        var initialized = null;
        var preloaded = null;
        //returns "undefined"
        trace(loadLevel);
        loader_mc.onEnterFrame = function() {
            if (initialized == null) {
                initialized = 1;
                // get original x and y coordinates
                trace(this.preBar._width);
                var the_x = this.preBar._x;
                var the_y = this.preBar._y;
                // get the leftmost x of bar
                var left_x = the_x-((this.preBar._width)/2);
                // start out with a scale of 0
                this.preBar._xscale = 0;
            }
            // if we're still preloading
            if (preloaded == null) {
                // set xscale of bar equal to ratio of gBL over gBT
                //
                //THIS IS A BIG PROBLEM AREA _ WHERE IS MY _LEVEL HANDLE?
                this.preBar._xscale = Math.floor((loadLevel.getBytesLoaded()/loadLevel.getBytesTotal())*100);
                // adjust x position so that bar is always left-aligned
                this.preBar._x = left_x+(this.preBar._width/2);
                // display percentage in text field
                //_parent.text.percent = preBar._xscale + "%";
            }
        };
    }
}

Data Type For Hex Values
what is the proper data type for hex values in 0x000000 format? I tried string, but I get a type mismatch error whe I try a setRGB() call.

thanks

AS 2.0 Data Type Problems:(
Hi all

I've created a flash based gallery which is finished and working initially using static data from an array inside the movie with a view to later replacing this with dynamic data from a text file as i normally do. However this is my first venture into a wholly AS 2.0 site and i've hit problems when using the read data. My normal scripting works fine and reads the data and i can access it as expected later in the movie, however the movie certainly doesnt do what is expected with this data even though its the exact same data as when working from static arrays, which leads me to beleive it may be a data type problem? You can download the .fla for those brave enough to take a look from http://www.kre8webdesign.com/gallery2.fla and the data file in question from http://www.kre8webdesign.com/data.txt (if you actually test this you may need to later path to datafile in .fla) but ill briefly explain the as and problem below...

The following works using static arrays in the movie

// load data here and set var to say loaded which preloader will test
function imageCache(tmpURL:String, tmpThumb:String, tmpSx:Number, tmpSy:Number, tmpLx:Number, tmpLy:Number, tmpTog:String) {
this.image_url = tmpURL;
this.thumb_url = tmpThumb;
this.smallX = tmpSx;
this.smallY = tmpSy;
this.largeX = tmpLx;
this.largeY = tmpLy;
this.togName = tmpTog;
}
// TEMPS vars for use in debugging and testing
//
if (_global.galleryToLoad == undefined) {
_global.galleryToLoad = 1;
}
if (_global.galleryPage == undefined) {
_global.galleryPage = 1;
}
allImages = [];
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.allImages.push(new imageCache("01.jpg", "01.jpg", 87, 130, 283, 425, 'Bob Photog'));
_root.dataLoaded = true;
stop();

However if i attempt to use "dyanamic" data from a static text file as follows, nothing behaves as expected although the data does appear to be loaded...

// load data here and set var to say loaded which preloader will test
function imageCache(tmpURL:String, tmpThumb:String, tmpSx:Number, tmpSy:Number, tmpLx:Number, tmpLy:Number, tmpTog:String) {
this.image_url = tmpURL;
this.thumb_url = tmpThumb;
this.smallX = tmpSx;
this.smallY = tmpSy;
this.largeX = tmpLx;
this.largeY = tmpLy;
this.togName = tmpTog;
}
// TEMPS vars for use in debugging
//
if (_global.galleryToLoad == undefined) {
_global.galleryToLoad = 1;
}
if (_global.galleryPage == undefined) {
_global.galleryPage = 1;
}
allImages = [];
_root.dataLoaded = false;
cacheDataProducts = new LoadVars();
//cacheDataProducts.load("./media/gallerys/"+_global.galleryToLoad+"/data.txt?r="+random(999));
cacheDataProducts.load("./media/gallerys/"+_global.galleryToLoad+"/data.txt");
cacheDataProducts.onLoad = function(sucess) {
if (sucess) {
if (this.uqidloaded == 'true') {
for (i in this) {
if (i.indexOf('entry') != -1) {
row = this[i].split('|');
_root.allImages.push(new imageCache(row[0], row[1], row[2], row[3], row[4], row[5], row[6]));
}
}
//allImages.reverse();
trace("loaded data - length is = "+_root.allImages.length);
traceData();
_root.dataLoaded = true;
}
} else {
trace("load error");
}
};
function traceData() {
for (i=0; i<_root.allImages.length; i++) {
trace("image - "+i);
trace(_root.allImages[i].image_url);
trace(_root.allImages[i].thumb_url);
trace(_root.allImages[i].smallX);
trace(_root.allImages[i].smallY);
trace(_root.allImages[i].largeX);
trace(_root.allImages[i].largeY);
trace(_root.allImages[i].togName);
}
}
stop();

The result of the traceData() function above after data is loaded is as follows, which would suggest the data has loaded, therefore im at a loss and would greatly appreciate any tips or pointers?

PS. i originally posted this in the scripting and backend forums, if pos

Thankyou in advance

trace results ---

image - 0
01.jpg
01.jpg
87
130
283
425
Bob Photog
image - 1
01.jpg
01.jpg
87
130
283
425
Bob Photog
image - 2
01.jpg
01.jpg
87
130
283
425
Bob Photog

What Is The Data Type Of A SetInterval Var?
what is the data type of a var that holds a setInterval ?

How To Declare A New Data Type?
I have a new Data type ( fxn ) declared in delphi, and i would like to convert the code to actionscript

Code:
type fxn=procedure(t:extended;x:array of extended;var f:array of extended);
.....
procedure fp(t:extended;x:array of extended;var f:array of extended);
begin
f[0]:=x[1];
f[1]:=-sin(x[0])*(g/ll);
end;
....

procedure r_kutta6(eps,t0:extended;x0:array of extended;fnx:fxn;
var t:extended;var x:array of extended);
begin
...
fnx(t0,x0,f); //means fp(t0,x0,f); - when applying the procedure.
...
end;

...
r_kutta6(0.0001,t0,xx0,fp,t,xx);
how can i declare in actionscript such a new data type, and after - to use as i do in delphi
thanks!

Data Type Conversion
hi,

does anyone knows how to convert integer type to bytes?

some please enlighten me !

Thanks

Change Data Type
problem: I need to get around strict object typing and change a clip on the stage from type MovieClip to type Highlight (Highlight is my own custom class). Is there a way to do this with actionScript.

The following will not work for this situation:
- edit the clips linkage property in the library.
- create the clip from scratch via actionScript and declare it type Highlight.
- place actionScript on or inside the clip. The actionScript needs to be on the timeline.

Detailed discription of what I'm doing:
I'm quickly creating movie clips on the stage. Because this process happens over 300 times, I'm not going to link the clips to a class at this point. These items are of type MovieClip with names of "instance1", "instance2", instance3, etc. With actionScript on the main timeline I want to change instance1 from type MovieClip to type Highlight (this is my custom class).

Thanks in advance,
Craig

How To Declare A New Data Type?
I have a new Data type ( fxn ) declared in delphi, and i would like to convert the code to actionscript

Code:
type fxn=procedure(t:extended;x:array of extended;var f:array of extended);
.....
procedure fp(t:extended;x:array of extended;var f:array of extended);
begin
f[0]:=x[1];
f[1]:=-sin(x[0])*(g/ll);
end;
....

procedure r_kutta6(eps,t0:extended;x0:array of extended;fnx:fxn;
var t:extended;var x:array of extended);
begin
...
fnx(t0,x0,f); //means fp(t0,x0,f); - when applying the procedure.
...
end;

...
r_kutta6(0.0001,t0,xx0,fp,t,xx);
how can i declare in actionscript such a new data type, and after - to use as i do in delphi
thanks!

What Kind Of Data Type Is This?
hi,

I have a column of movieclips with names like cs_tgt0, cs_tgt1, cs_tgt2, etc etc, and assuming there are no syntax errors etc, from what I can tell each movieclip should take on the 'putFunctionsOnButtons()' function but it doesnt work. Only when I declase 'public var cs_tgt0', etc then the buttons work (basic rollovers). My question is, what sort of declaration of data type would 'cs_tgt' be?


Code:
public function putFunctionsOnButtons(){

public var bgBtn:MovieClip;
public var cs_tgt: __what-goes-here-for-this-to-work___;


for(var i=0; i<7; i++)
{

var cs_tgt = "cs_tgt" + i;
trace(cs_tgt);


cs_tgt.bgBtn.onRollOver = function(){ show something};
cs_tgt.bgBtn.onRollOut = cs_tgt.bgBtn.onDragOut = function(){ hide something };
cs_tgt.bgBtn.onRelease = cs_tgt.bgBtn.onReleaseOutside = function(){
do stuff...
}
};
Apologies if i offend anyone with the shocking code and cheers in advanced!

Regards

Mike

Help Me Find The Right Data Type
I made a class that uses a MovieClip as a host clip. It then adds and removes clips from the display list of the host clip.

The host clip is passed to the constructor of the class. But I can't think of the right data type to use.

MovieClip works. But it is also possible to use a Sprite. If I set it to Sprite then MovieClip throws an error. Any Class that extended MovieClip or Sprite would also work as long as the class has addChild() and removeChild().

Nothing works great of course. But feels like a hack.

I had guessed, wrongly, that Sprite would work for both MovieClip and Sprite, since MovieClip extends Sprite.

Object Data Type
I ve created a variable that contains an array. Each array element is a generic object that further contains an array n that array again contains a generic object whith .x and .y properties.. Now i wanted this to pass to the asp. the problem is that i cant extract the .x and .y values frm the variable passed in asp.. Please tell me what to do so that i can get the values ....thnx in advance

Data Type = <empty>
Hi All,

In developing the bindings to access my MS Access database, I am trying to the data type for one of my fields to <empty> (as per the example I am following) but this option is not available in the dropdown box which lets you select the data type for the field in question.

How then do go about setting the data type to <empty>?

This is very confusing because if you can set a data type to <empty>, you would assume it would be a selectable option in the data type dropdown box!? Anyway, some advice here would be much appreciated, as always!

Thanks.

Please Help With My Boolean Data Type.
Feel like an idiot right now...why is my boolean not work?

ActionScript Code:
showHideBG_mc.text_mc.onRelease = function(){    var _click:Boolean = true;    //_click = true;    if(_click)    {        trace("hit");        showHideBG_mc.gotoAndPlay(2);    }    else    {        trace("hitMe")        showHideBG_mc.gotoAndPlay(11);    }}

Copyright © 2005-08 www.BigResource.com, All rights reserved