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








Data Type Problem


I have a movie clip's name stored in a string variable called 'str'. How can I make this code work:
Code:

str = "MC";
str.onPress = function() {
    // Some code here
}

Basically, I want to make the movie clip clickable and perform some actions when it is clicked but I need to keep its name in a string variable.




Actionscript 3.0
Posted on: Thu Dec 11, 2008 8:13 pm


View Complete Forum Thread with Replies

Sponsored Links:

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

View Replies !    View Related
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;


View Replies !    View Related
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;
}

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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.

View Replies !    View Related
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 ?

View Replies !    View Related
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 + "%";
            }
        };
    }
}

View Replies !    View Related
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

View Replies !    View Related
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

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

View Replies !    View Related
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!

View Replies !    View Related
Data Type Conversion
hi,

does anyone knows how to convert integer type to bytes?

some please enlighten me !

Thanks

View Replies !    View Related
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

View Replies !    View Related
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!

View Replies !    View Related
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

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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.

View Replies !    View Related
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);    }}

View Replies !    View Related
AS2 Data Type Issue
Greetings all,

I am having an issue with an AS2 function I created. The two variables below (blah & blah2) have the same value in the output window, although only "blah2" triggers the Tween. Anyone have any ideas what I am doing wrong here?


Code:
answerBtn.onPress = function() {

blah = "_level0.step_mc" + this.thatID + ".graph_mc"+this.thisID; // this doesn't work
blah2 = _level0.step_mc0.graph_mc1; // this works

var horiTween:Tween = new Tween(blah2, "_width", Strong.easeOut, 0, this.data*50, 1, true);

}

View Replies !    View Related
Getting Data Type Of A Variable
Hey there, well I have an issue. I have two numbers that I am trying to compare, but I am pretty sure its not comparing them correclty. So what I want to do is try to figure ot the actual return type of the variable.

What is the function that I need to use to get the actual return type, for example i wnat to know if the two variables are either returning a number, or a string, or something else. This would help me thanks a lot.

View Replies !    View Related
Variable Data Type Headache
I'm trying to add (the values of) two variables, both of which I've initialised as number data types (I think), but they simply concatenate when I do

answer = variable1+variable2

answer is also defined as a number data type. I can multiply, divide or subtract them but try and add them, and they just string together into a long number.
What the mufugger am I missing

View Replies !    View Related
Matrix Data Type Construction
Hi there

I was wondering if anybody knows how to construct a 2d Array or matrix in action script.

I am trying to make a sim city/ command and conconcer style game and this data type would be ideal to act as the board objects are set to.

I understand how to create 1d arrays but I don't understand how to set my own index type. I know what to do in a stricter language but as you can see from my posts action script is new to me.

Any help would be grand.

View Replies !    View Related
Data Type Of Loaded XML Information?
Just an interesting point i noticed recently when developing a dynamic menu building SWF that is instructed ONLY by an XML file. (Actually quite pleased with the outcome - my swf is created totally dynamically, button types, button separation, menu orientation, sub menu heirachy etc..... anyway thats another story..)

No the point was that when i "Walked the Tree" of the XML file i loaded, i noticed that if i wanted to make some of the text I had loaded in scrollable, in a dynamic text field, i had to add the toString() method to the end of the variable name i associated with the block of text.

so i loaded in the XML etc etc looped through lots of nodes, elements etc....

myVar=......myArray.firstchild

but then to make the text in myVar scrollable, i had to add the toString() method to the end of the variable name as i asociated it with the dynanmic textfield set up to scroll

just a point for those who may be interested.

gilesb

View Replies !    View Related
Converting Some Type Of Data To String
Hello,

I have a problem, it goes as follows:

i = _root.movieClip.valueOf();
trace(i) // returns in the output window _level0.movieClip

the datatype of the i variable is not a string, what is it exactly and is there a way to convert it to a string??

with regards,
Hidde van der Lijn
[Edited by 7u on 07-22-2002 at 03:44 AM]

View Replies !    View Related
Data Type Messes Up With Prototype
I am using AS 2.0 and trying to create a string utilities class for extra methods.

Here is my utilities class.
class Utilities{

function Utilities(){}
static function improveClasses(){
/**************************************/
String.prototype.rTrim2 = function():String{
var size = this.length;
for(var i = size-1; i >= 0; i--){
if(this.charCodeAt(i) != 32){
return this.substring(0, i + 1);
}
}
return "";
}
}


this works fine but when I code this in my main movie


var casey = " casey ";

Utilities.improveClasses();

trace(":" + casey + ":");
casey = casey.rTrim2();
trace(":" + casey + ":");




the problem is I can not datatype the lien var casey:String. if I do then it does not recognize the rTrim2 function i created.

ANy ideas on how to extend a class and keep code hinting while datatyping in flash mx 2004?

View Replies !    View Related
Data Type Coverstion From AS1.0 To Database
I have a mulitdimensional array (three levels) that needs to be saved into a mysql database through a php page. I was wondering if anyone knew of a way to convert an array easily. I was thinking of creating a function that would convert the array into one big string and separate each different level with an exclamation mark, but that isn't working so well with a three level array. Is there a way to store the array as an array in the mysql database?

View Replies !    View Related
Strict Data Type Function
how would you call this variable??


Code:
var myFunct:Function = function():Void
{
trace("function called");
}

View Replies !    View Related
Another Strict Data Type Question
Do i only use strict data typing for variables?
Because if i try to use it with the following code I get an error

Code:
btn.onPress:Button = function(){

}
Please give me an example of how to use strict data typing using the :Button data type.

View Replies !    View Related
[F8] *Boggle* .. Data Type Confusion
Ok.. I must be missing something.

Can somebody please tell me why the second line is an object and not a string?


Code:
var n:String = "abc";
trace(typeof (n)); // outputs STRING

var n:String = new String("abc");
trace(typeof (n)); // outputs OBJECT

View Replies !    View Related
Data Type Problems In RSS Reader
Hello all,

I'm a AS3 newbie and wonder if someone can help me work out a data type problem I've got.

I've modified a bit of code from Senocular.com (see below) which reads an RSS feed and outputs the headlines to a textfield, mxnaText. I've tried to write some code which then fades out the headlines, but gives out the following error when I try to run it:

1119: Access of possibly undefined property _alpha through a reference with static type flash.text:TextField.

Can anyone give me a push in the right direction?

Cheers

My code


// Set up variables
var mxnaURL:String = "http://digg.com/rss/containertechnology.xml";
var mxnaRequest:URLRequest = new URLRequest(mxnaURL);
var mxnaLoader:URLLoader = new URLLoader();
var myTimer:Timer = new Timer(2000);//set up timer
myTimer.addEventListener(TimerEvent.TIMER, fadeout);


// Assign listeners for downloading feed
mxnaLoader.addEventListener(Event.COMPLETE, feedDownloadedHandler);
// Error listeners
mxnaLoader.addEventListener(IOErrorEvent.IO_ERROR, feedDownloadError);
mxnaLoader.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, feedDownloadError);

// Event handlers
// Called when feed has completely downloaded
function feedDownloadedHandler(event:Event):void {

// use a try-catch block in case
// xml parsing fails
try {

// convert the loaded text into XML
var mxnaXML:XML = XML(mxnaLoader.data);

// if XML succeeded (no error)
// show it in the text field
renderFeedXML(mxnaXML);

}catch(error:Error){
trace("Error parsing XML: "+error);
}

}
// Called if feed download fails
function feedDownloadError(event:Event):void {
trace("Error during download: "+event);
}


// Functions
// Writes each feed item to the screen
function renderFeedXML(feed:XML):void {

// get default namespace for feed
var defaultNs:Namespace = new Namespace("http://purl.org/rss/1.0/");
// set default namespace to make referencing easier
default xml namespace = defaultNs;

// clear screen text
mxnaText.text = "";

// write each Feed item to the screen
// looping through the XMLList with for each
var items:XMLList = feed.item;
for each (var item:XML in items){
renderFeedItem(item); //call in feed item

myTimer.start();


}
}

// Writes a single feed item to the screen
function renderFeedItem(item:XML):void {

// namespaces
var rdf:Namespace = new Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
var dc:Namespace = new Namespace("http://purl.org/dc/elements/1.1/");
var defaultNs:Namespace = new Namespace("http://purl.org/rss/1.0/");

// set default namespace to make referencing easier

default xml namespace = new Namespace("http://purl.org/rss/1.0/");

// parse date string [YYYY-MM-DD]
var date:String = item.dc::date.text().substring(0, 10);

// write other feed content to text using HTML
mxnaText.htmlText += "<u><b><a href=""+item.@rdf::about+"">"+item.title+"</a></b></u><br />";
//scroll text


}

// Download XML feed. Once loaded, the
// parsing and displaying process will start
try {
mxnaLoader.load(mxnaRequest);
mxnaText.text = "Loading...";
}catch(error:Error){
trace("Error during load: "+error);
}


function fadeout() {
this.onEnterFrame = function(event:Event):void {
if (mxnaText._alpha>=0) {
mxnaText._alpha -= 5;
} else {
return
}
}
}

View Replies !    View Related
MC Name As Variable - Data Type Issue?
I'm having a problem referencing a movie clip in my Flash project, and I think it's a data type issue.

For example, say my MC instance name is circle1, and I want to get the X coordinate. If I do:

trace(circle1._x);

this works fine. However, in the project I'm making, I'm getting the name of the movie clip I want to reference from another variable name. So, a simplified version of what I'm trying to do looks like this:

myClip = circle1;
trace(myClip._x);

This also works okay. However, if "circle1" is inside quotation marks (i.e. it is a string), my trace returns "undefined".

So, in my actual project, I am getting the variable from an XML file, like so:

myClip=myXML.firstChild.childNodes[i].attributes["name"];

where the "name" attribute in the XML is the same name as a MC instance on the stage. Here I have the same "undefined" problem. Is there any way to get this variable into the proper data format so that I can use it in this way?

Thanks for your help!

View Replies !    View Related
Data Type Of Loaded Files Such As Swf/xml?
I'm building a preloader function. I want to be able to pass it the name of any file, e.g. a swf or an xml file.

What data type can I use to do this? I tried object, but that didn't work.
I need to use the getBytesLoaded method, so need a movieclip name?

Any suggestions?

Thanks

View Replies !    View Related
Help Me Fix This Script? Might Be A Data Type Problem...
I assume this is due to some kind of data type issue. It works fine with numbers, but I cannot get it to work with letters. The odd thing is, they are all in string form, so I don't get why it would matter.

This works fine:


ActionScript Code:
switch(vt_0.text){
case String(1): //action if text = 1
//whatever actions
break;
case String(2): //action if text = 2
//whatever actions
break;
}


This Does not:


ActionScript Code:
switch(vt_0.text){
case String(A): //action if text = A
//whatever actions
break;
case String(B): //action if text = B
//whatever actions
break;
}

Anyone see the problem here? I don't think it matters, but the text in question was brought in using ".htmlText" from an xml doc.

View Replies !    View Related
Data Type Question: Sets
I am trying to make a program that has a random mathematical question, 7 different random answers, one of which is correct.

I am used to using classes in Java and the Java libaray.

Is there an inbuilt class in actionscript that fulfills these properties:
No duplicates
Easy insert of integers
Easy poping of first item.
Easy length return.

Basically a set.. The only thing I found on the net was a DataSet, but I tried one and it gave me all sorts of strange errors.

I will use this class to fill it with my 'random' answers to the question, which are actually the correct answer but offset by a random number. I need to build up the set so that no answer is duplicated and that one of them is indeed the correct answer. Which I will then have all asigned to a,b,c,d,e,f,g.

If you are interested the code I have at the moment is:

Code:
function sub() {
lev = l*10+50;
X = Math.round(lev*Math.random());
Y = Math.round(lev*Math.random());
x.text = X;
y.text = Y;
an = (X-Y);
while (answers.getLength()<7) {
a = an+lev*5*Math.ceil(Math.random()*2-1);
if (Math.random()>0.86) {
a = an;
}
if (!answers.find(a)) {
answers.addItem(a);
}
}
if (!answers.find(an)) {
answers.addItem(an);
} else {
while (answers.getLength()<8) {
a = an+lev*5*Math.ceil(Math.random()*2-1);
if (!answers.find(a)) {
answers.addItem(a);
}
}
}
answers.first();
a.text = answers.currentItem();
answers.next();
b.text = answers.currentItem();
answers.next();
c.text = answers.currentItem();
answers.next();
d.text = answers.currentItem();
answers.next();
e.text = answers.currentItem();
answers.next();
f.text = answers.currentItem();
answers.next();
g.text = answers.currentItem();
}
which gives an error of:
Operation not applicable when no sort has been defined. Error for iterator '__default__'.

a-g are dynamic text
l is the current level of question (higher level means larger numbers in the question and smaller deviations of wrong answers to the correct answer)

View Replies !    View Related
Type Coercion Failed With XML Data
Hi,

I'm trying to pass some XML data from a PHP script to a data grid via the data grid dataProvider. I'm doing the following steps;

// myXML holds the XML

myXMLList = new XMLList(myXML);
myXMLListCollection = new XMLListCollection(myXMLList);
dataGrid.dataProvider = myXMLListCollection;

When i run the program i'm getting;

Type Coercion failed: cannot convert XMLList@e3e19a1 to mx.collections.XMLListCollection

Can anyone help?

Thanks in advance

-as3hacker

View Replies !    View Related
Variable Data Type Troubles
Hoping someone can help me with this, I'm sure it's something simple but I'm stumped!

Basically, I've got a map where each country is it's own Movieclip. I'm changing the tint on each country based on an attribute from the XML file which is called "status". I'm storing the status in a variable. The status is either "red" "green" or "yellow".

I was hoping I could then just use that variable value in the color change class, I've got variables of the same name there. The tint change works when I type in the variable red green or yellow but if I instead replace it with my countryColor variable which stores the value of status from the XML, it fails due to data type.

Basically, no matter what I try, I can't seem to get the color change class to recognize the string format. I tried changing the variable to type Color but that returns a null result.

Any help is greatly appreciated. Here is my non-working code!


ActionScript Code:
// Change color class //
import fl.motion.Color;
import flash.geom.ColorTransform;

//load xml//
var myXML:XML = new XML();
var XML_URL:String = "data.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

//define Countries
var austriaColor:String;

// change the status colors
function xmlLoaded(event:Event):void
{
    myXML = XML(event.target.data);
    trace("Data loaded.");
    trace("Num countries is " + myXML.country.length());
    trace("country #2 is " + myXML.country[1].@name);
    austriaColor = myXML.country[1].@status;
    trace(myXML.country[1].@name + " = " + austriaColor);
}


/* red */
var red:Color = new Color();
red.setTint(0xFF0000, 0.9);
/* yellow */
var yellow:Color = new Color();
yellow.setTint(0xFFFF00, 0.9);
/* green */
var green:Color = new Color();
green.setTint(0x00CC00, 0.9);

mcAustria.transform.colorTransform = austriaColor;

View Replies !    View Related
XML Question About Data Type Of NodeValue
Hello

I'm using an XML file for a simple flash wordgame I'm creating. I just have a question about the nodeValue property. Here's my XML doc:


Code:
<wordgame>

<item>
<scrambled>icoant</scrambled>
<unscrambled>action</unscrambled>
</item>

<item>
<scrambled>lsoybm</scrambled>
<unscrambled>symbol</unscrambled>
</item>

<item>
<scrambled>itgsrn</scrambled>
<unscrambled>string</unscrambled>
</item>

<item>
<scrambled>nduso</scrambled>
<unscrambled>sound</unscrambled>
</item>

<item>
<scrambled>yarar</scrambled>
<unscrambled>array</unscrambled>
</item>

</wordgame>
My XML object's name inside the Flash document is xmlWords. I'm able to parse through it properly. I just have a question about data types. Both these lines of code output the same thing:


ActionScript Code:
trace(xmlWords.firstChild.childNodes[0].firstChild.firstChild.nodeValue);
trace(xmlWords.firstChild.childNodes[0].firstChild.firstChild);

They both output:
Code:
icoant
I would like to know what are the data types of those data being retrieved. Is the nodeValue a string?

What about:
ActionScript Code:
xmlWords.firstChild.childNodes[0].firstChild.firstChild
What is its data type?

View Replies !    View Related
Variable Data Type Error.
I have a fast question. I am setting up a variable with a data type of Number, when I declare the variable it has a default value.

I am trying to pass data to the variable from a input text box but I am getting an error when I run the Movie. I have tried both a input text box and a Dynamic Text box, but they both produce the same error.

If I remove the data typing from the variable declaration the Movie runs and it updates the variable data but from all that I have read this is not a good practice.

I have attached the code, could someone Please help me out. I do not remember having these types of problems with ActionScript 2.

Thanks for the help.

Code:

var rectangle:Shape;

var thick :Number = 2; // line thickness
var color:Number= 0x000000; // Holds the color value

myButton_btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void
{
color = colorField_txt.text; (Line 11)
thick = lineThick_txt.text; (Line 12)
rectangle = new Shape();
rectangle.graphics.lineStyle(thick, color, .5);
rectangle.graphics.drawRect(10, 10, 100, 150);
addChild(rectangle);
}

myButton_btn.buttonMode = true;


ERROR MESSAGE:

1067: Implicit coercion of a value of type String to an unrelated type Number. (Refers to line 11)
1067: Implicit coercion of a value of type String to an unrelated type Number. (Refers to line 12)

Thanks again for any help.

Mike

View Replies !    View Related
Converting Data Type Problem
So I'm importing this file called tbox.txt and in that file it has a variable, num, which equals 3. Now when I run the debug window, it comes back as num = "3". So its a string. so I do num=num-0 to make it a number instead of a string. And it doesn't work so I do a trace on num and it comes back as undefined.... which is what I dont understand, how can it be "3" and undefined at the same time.... please help...

View Replies !    View Related
XML/XPath Data Type Issue...
ok this is starting to bug me...

Basically, I'm loading my XML data into flash then parsing it using XPath so I can easily access node based on the their name etc.

structure is like this:

<doc>
<section1>
<info></info>
<info></info>
</section1>
<section2>
<info></info>
<info></info>
</section2>
<section3>
<info></info>
<info></info>
</section3>
etc.. etc..
</doc>


I loop through and create arrays for all the sections attributes and info values sorta like so:

tempNumExtraImagesArray[x] = XPath.selectNodes(this,"/string/cell"+x+"/num_extra_photos/text()");

this succeeds in grabbing the values but when I go to evaluate this array later in the loop, like this:

if(tempNumExtraImagesArray[x] > 0){
trace("somethingorother");
}

it chokes!

I've tried forcing the array values to numbers like so:

tempNumExtraImagesArray[x] = Number(XPath.selectNodes(this,"/string/cell"+x+"/num_extra_photos/text()"));

and when I trace the array it pumps out NaN. Maybe I've been staring at the screen too long but it's driving me nuts. If anyone could shed some light it would help save what little hair I already have.

Thanks!

View Replies !    View Related
[AS 2.0] Type Checking Data In Array
Hi everyone,
I'm trying to do something such as:

ActionScript Code:
var n:Node = openList.shift();

I know that all of the data contained inside openList is a type of Node object, but Flash returns an error. I don't know how to typecast such as placing (in another language)...
Code:
(Node) openList.shift();
...to tell Flash that the data returned will be a Node object.

Better yet, is there a way to specify, while declaring the array, the type of the data that will be placed in it?

I could just take the :Node tag out from my variable declaration, but this might be in a tutorial, so I should at least act like I believe half the stuff about proper coding I write about

Thanks,
Kirupa

View Replies !    View Related
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?

View Replies !    View Related
Passing A Hexadecimal - Data Type?
I'm trying to pass a hexadecimal number into a function so that it can be used to format a text field. Does anyone know the correct syntax/data type to use here?


Code:
package {
public function process(answerSprites:DisplayObjectContainer,hexCode:uint):void {
txtfield.setTextFormat(hexCode);
// 1067: Implicit coercion of a value of type uint to an unrelated type flash.text:TextFormat.
}


// Another line of code calls process()...
process(answerSprites,0x85BB3D);
}

View Replies !    View Related
Converting Data Type Problem
So I'm importing this file called tbox.txt and in that file it has a variable, num, which equals 3. Now when I run the debug window, it comes back as num = "3". So its a string. so I do num=num-0 to make it a number instead of a string. And it doesn't work so I do a trace on num and it comes back as undefined.... which is what I dont understand, how can it be "3" and undefined at the same time.... please help...

View Replies !    View Related
VOID Data Type Query?
Hey guys.

Quick question.

What is the purpose of the "Void" data type?

Came across it in a tutorial. I have never used it before! Just couldn't quite see how it applied to the codes function in the tutorial?

Thanks

View Replies !    View Related
Array.splice Data Type Problem
hello all. I'm working on a small function that draws (as in a lottery) six balls from a total of 48. Of the 48 sixteen are Blue, 16 Red and 16 are Yellow.......

My problem is that I'm trying to get the total of the balls values to be displayed when the balls are drawn and keep getting NaN. I think I've narrowed the problem down to the splice. When its there the transfered variable is turned into a string, when its not it remains in its original form, a number. I've tried working out if I've made a mistake and can't spot it, and I don't seem to be able to turn the string back to a number by using Number(). Can anyone help?

(my code may get cut , or only partially appear, if it does I'll paste the rest of the message in another post. If not then its all here).

Thanks
db

[code]function makeDraw(){
dRs = new Array(); for ( var i=1; i<=16; i++ ) { dRs[i-1] = (i*3)-2; }
dYs = new Array(); for ( var i=1; i<=16; i++ ) { dYs[i-1] = (i*3)-1; }
dBs = new Array(); for ( var i=1; i<=16; i++ ) { dBs[i-1] = i*3; }
var bT = 0;
for ( var i=1; i<7; i++ ) {
var r = random(3);
var n = eval("bigBall"+i);
n.gotoAndStop (r+1);
if (r==0){
n.num = dRs.splice( random(dYs.length) , 1);
} else if (r==1){
//n.num = dYs.splice( random(dYs.length) , 1); //FAILS
n.num = dYs[5]; //WORKS
trace (n.num + 5);
} else {
n.num = dBs.splice( random(dBs.length), 1);
}
bT += n.num
}
_root.ballTotal = bT
}
[Edited by digital biscuit on 02-18-2002 at 01:06 PM]

View Replies !    View Related
Formatting Data In A Table Type View....
Ok so connecting flash mx to a cfc, I have a recordset that is returned, but I am having problems getting it formatted in a "table" like view, anyone have any suggestions?

View Replies !    View Related
Check An Input Menu For Data Type
Does anybody know an easy way to check if the an input is a number?

The way i was thinking of doing it was, beaking the input apart and chcking every character if it is equal to 1,2,3 .. 0 . (In an Array, obviously)

View Replies !    View Related
Poll For Pros: Strict Data Type?
If you're a pro, do you use strict data typing? (please keep it short)

If you've been programming for years the error-checking isn't a benefit so please don't factor that in. Is there any new reason to do it in 8? I'm seeing both ways everywhere and want to get a consensus.

I personally haven't run into any use for it so I've stopped doing it - just extra characters.

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved