AS2 - Casting An Object To A Different Type
Hi all, I'm trying to convert a String to Slide (mx.screens.Slide). Everytime I'm getting null.
ActionScript Code: var slide = "slide_11"_root.presentation.gotoSlide(slide);
I need to do this but it doesn't work. I have a string because slide_11 was in a xml file.
Any idea?
Ultrashock Forums > Flash > ActionScript
Posted on: 2008-02-08
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Type Casting
I have an input box where I want to put a number value that begins with zero. "016" I then put this value into an array and it drops the zero. I want the number value to be treated like a string. I have tried using the myText.toString() function, and the String(myText) constructor, but it still takes off the zero at the begining. does anyone have any ideas, or has anyone experienced this before?
Type Casting
Is there any way to convert String to Number? Flash doesn't convert it automaticly in my code. I used .valueOf but I didn't work.
Type Casting Problem
Hello gurus,
I have a problem:
while loading a number from a variable in a text file, into a script, i found that the number is not really a number but a string or a character. But i need it as a number to perform some operation. Can you please help me on how to convert that??
Type Casting To A Class Name
I'm trying to type cast an item in an array (inventoryList) to a Class, so I can addChild the movieClip to the stage. The items in the inventory 'carrotIcon and passportIcon' - I also have movieClips of the same name in the library with their own classes.
It works when I just change the line to 'addIconName = new carrotIcon()' for example. Maybe the answer is that I should use something else than 'Class' as the type cast. I've tried MovieClip to no avail.
var itemName:*;
var inventoryList:Array = new Array();
inventoryList.push("carrotIcon");
inventoryList.push("passportIcon");
for (var i:int = 0; i < (inventoryList.length); i++)
{
itemName = Class(inventoryList[i]); //this is the line I'm having problems.
addIconName = new itemName();
addChild(addIconName);
}
Thanks for looking!
Joe
Type Casting Problems
Quick Rundown of What I am doing so you can understand the logic is:
Building multipage Form In first Frame I hove no movies just initialized a bunch of Variables to store Data filled in from Forms on various Pages (frames 2 thru 7)
Page/Frame 2 is First Page which asks for Basic Details like Name Phone #s etc
I have a function that checks (when next page button is clicked) that checks Page form inputs are all filled correctly and if so updates the Variables (from frame 1) with the entered Data. Then on Return to the Page I prefill fields from the stored Variables.
Now the Problem:
For 4 different Phone numbers on the Page I have 3 inputs each (AreaCode, Prefix, Suffix)
When I go to store the entered values to 1 Variable each (Frame one/ Variable of type int/ to store the 10 digit number before sending to php serverside script) I concat the 3 input fields for each number and cast to int then on reenter page to preload the values again I cast the 10 digit int back to string and do a substr to divide them up and put them in the inputs as text.
However weird things happen Company Phone and Personal phone seem to usually work fine but Cell Phone and Fax get all muffed up the first time I renter (after leaving and returning they stay the same as first muffed up appearance)
Here is the portions relating to the Events please advise if you have any ideas how I can stop this behaviour. Thanks
Setting the Variable before leaving page
PHP Code:
cphone = int(CompanyPhoneAC.text + CompanyPhonePF.text + CompanyPhoneSF.text);
cfax= int(CompanyFaxAC.text + CompanyFaxPF.text + CompanyFaxSF.text);
pphone = int(PersPhoneAC.text + PersPhonePF.text + PersPhoneSF.text);
pcell = int(PersCellAC.text + PersCellPF.text + PersCellSF.text);
Setting the Inputs when Returning to Page
PHP Code:
var PersCAC:String = String(pcell);
PersCAC = PersCAC.substr(0,3);
if(PersCAC.length<3){
PersCAC = "" ;}
PersCellAC.text = PersCAC;
var PersCPF:String = String(pcell);
PersCPF = PersCPF.substr(3,3);
if(PersCPF.length<3){
PersCPF = "";}
PersCellPF.text = PersCPF;
var PersCSF:String = String(pcell);
PersCSF = PersCSF.substr(6,4);
if(PersCSF.length<4){
PersCSF = "";}
PersCellSF.text = PersCSF;
var PersPAC:String = String(pphone);
PersPAC = PersPAC.substr(0,3);
if(PersPAC.length<3){
PersPAC = "";}
PersPhoneAC.text = PersPAC;
var PersPPF:String = String(pphone);
PersPPF = PersPPF.substr(3,3);
if(PersPPF.length<3){
PersPPF = "";}
PersPhonePF.text = PersPPF;
var PersPSF:String = String(pphone);
PersPSF = PersPSF.substr(6,4);
if(PersPSF.length<4){
PersPSF = "";}
PersPhoneSF.text = PersPSF;
var CompanyPAC:String = String(cphone);
CompanyPAC = CompanyPAC.substr(0,3);
if(CompanyPAC.length<3){
CompanyPAC = "";}
CompanyPhoneAC.text = CompanyPAC;
var CompanyPPF:String = String(cphone);
CompanyPPF = CompanyPPF.substr(3,3);
if(CompanyPPF.length<3){
CompanyPPF = "";}
CompanyPhonePF.text = CompanyPPF;
var CompanyPSF:String = String(cphone);
CompanyPSF = CompanyPSF.substr(6,4);
if(CompanyPSF.length<4){
CompanyPSF = "";}
CompanyPhoneSF.text = CompanyPSF;
var CompanyFAC:String = String(cfax);
CompanyFAC = CompanyFAC.substr(0,3);
if(CompanyFAC.length<3){
CompanyFAC = "";}
CompanyFaxAC.text = CompanyFAC;
var CompanyFPF:String = String(cfax);
CompanyFPF = CompanyFPF.substr(3,3);
if(CompanyFPF.length<3){
CompanyFPF = "";}
CompanyFaxPF.text = CompanyFPF;
var CompanyFSF:String = String(cfax);
CompanyFSF = CompanyFSF.substr(6,4);
if(CompanyFSF.length<4){
CompanyFSF = "";}
CompanyFaxSF.text = CompanyFSF;
Dynamic Type Casting - Is It Possible?
Is there a way to do something like the following...?
Code:
var myClass:String = "blah";
var inst = new[myClass]();
I've invented the above syntax--though I'd be delighted if it turned out to work! For clarity, I would hope for something like the above code to be synonymous with the following:
Code:
var inst:blah = new blah();
...So is it possible to dynamically specify a class name when creating a new instance?
Type Casting Classes
Alright let's say I have a MovieClip in the library with the linkage set to TestClass and I have this code...
var string1:String = "Test";
var string2:String = "Class";
var testClass:* = new Class([string1 + string2])();
this.addChild(testClass);
so testClass should be an instance of TestClass, this works for me sometimes and sometimes it doesn't.
Does any one have any advice as a better way to do this, and what this tecnique is called ( root["string" + "1"])?
Thanks for all you guy's help!
Type Casting And Equality
TypeError: Error #1034: Type Coercion failed: cannot convert uk.co.andrewrea.brickwall::BrickWall@24b1191 to uk.co.andrewrea.brickwall.BrickWall.
Does anyone know why this would be. I create a variable of Type BrickWall and then assign it a variable of type BrickWall the event data of the loader i.e.
ActionScript Code:
wall = e.target.content.wall;
both wall and e.target.content.wall are of the same type of the same package, but seem to be handled as different types. Anyone know why this is?
Thanks,
Andrew
How Strong Is Type Casting
I have a variable saved in the first frame of my fla file
var question:Number = 0;
I want to make it possible for sombody to jump around in the exersice so I built kind of a jumper and saved it in its own mc. In the mc I have a button called jump with the following code.
_root.question = q.text;
Now that question will work but when I tried to add one to my question variable it did something weird. Say I want to jump to question 2. When it tries to add one to my question variable I get 21. It seems that by saving q.text to my question variable, it gets recasted to a String. Has anybody else bumped into this problem.
Side note: I did fix this with parseInt. I am just curious why this happened in the first place, is type casting really not that strong?
Dynamic Type Casting - Is It Possible?
Is there a way to dynamically typecast a new instance? Maybe something like the following...?
Code:
var myClass:String = "blah";
var inst = new[myClass]();
I've invented the above syntax--though I'd be delighted if it turned out to work! For clarity, I would hope for something like the above code to be synonymous with the following:
Code:
var inst:blah = new blah();
...So is it possible to dynamically specify a class name when creating a new instance?
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;
}
Instantiation/Type Casting Problem With GetChildAt
Alrighty so I'm kinda new with actionscript 3.0 and have been having a problem with getChildAt. I'm working on creating a dynamic menu have have found that when I addChildAt using a for loop it adds all the childs properly however when I go to use getChildAt on the MovieClip that I have created using "var newMC:MovieClip = mc_container.getChildAt(x)" it returns a problem saying "Implicit coercion of a value with static type flash.display:DisplayObject to a possible unrelated type flash.display:MovieClip"
Anyways I'm trying to get it to work however I found a work around that I'm not sure why works where I just do "var newMC = mc_container.getChildAt(x)" and that will let me access all of the variables and stuff however when I do a trace on the newMC it says type undefined... Anyways some help would be awsome, and heres my code btw, should be pretty easy to read.
import flash.display.MovieClip;
import flash.display.Shape;
var news_content_num = 1;
var news_padding = 0;
var news_padding_distance = 10;
var news_ymin = 0;
var news_full_width = 289;
var news_full_height = 154;
var news_compact_height = 61;
var news_shading_xval = 290;
var news_shading_yval = 255;
var news_bordersize = 1;
var news_shading_offset = 1;
var news_content:MovieClip = new MovieClip();
function drawBorder():Shape {
var border:Shape = new Shape();
border.name = "border_"+[x];
//Add the Left Line and then Top Line
border.graphics.lineStyle(news_bordersize, 0xCCCCCC, 1);
border.graphics.moveTo(0, news_ymin + news_full_height);
border.graphics.lineTo(0, news_ymin);
border.graphics.lineTo(news_full_width, news_ymin);
//Add the Right Side Drop Shadow
border.graphics.lineStyle(news_bordersize, 0X999999);
border.graphics.moveTo(news_full_width+1, news_ymin+2);
border.graphics.lineTo(news_full_width+1, news_full_height+news_shading_offset);
//Add the Bottom Side Drop Shadow
border.graphics.lineTo(2, news_full_height+news_shading_offset);
//this.addChild(border);
//Add the Right Side Border
border.graphics.lineStyle(news_bordersize, 0X000000);
border.graphics.moveTo(news_full_width,news_ymin);
border.graphics.lineTo(news_full_width, news_full_height);
//this.addChild(border);
//Add The Bottom Side Border
border.graphics.lineTo(0, news_full_height);
return border;
}
function drawNews_fullSize(x:Number) {
var mc = new MovieClip();
mc.name = "news_"+[x];
mc.y = news_padding;
mc.addChild(drawBorder());
news_content.addChildAt(mc, x);
}
function set_padding()
{
news_padding = news_padding + news_full_height + news_padding_distance;
}
for(x = 0; x < 4; x++){
drawNews_fullSize(x);
set_padding();
}
this.addChild(news_content);
//What I want it to run as...
//var news:MovieClip = news_content.getChildAt(0);
//What currently works...
//var news = news_content.getChildAt(0);
Casting A String To An Object
I'm having trouble passing an object parameter using a string concatenation in a for loop...
in the for loop, I duplicate movieClips, copying a movie called "glass" and try to register it's speeds with the register() function below.
for (i = 1; i <= numObjects; i++) {
duplicateMovieClip(glass,"glass" + i, i);
register("glass" + i,20,20,20);
}
function register(object, xspeed, yspeed, rspeed) {
objects.push(object);
object._xspeed = xspeed * (2 * Math.random() - 1);
object._yspeed = yspeed * (2 * Math.random() - 1);
object._rspeed = rspeed * (2 * Math.random() - 1);
}
unfortunately, when passing tmp as "glass" + i, register thinks its a string, not an object. The object appear on stage, but doesn't move. If I hard code register() passing in as register(glass2,20,20,20) it does move.
How do I cast the string I pass in as an object?
Flex Casting An Instance Object From An External Swf
Hi,
I have a custom class called GoalKeeper.as . In my external swf, i create an instance of this class like
Code:
var myGoalKeeper:GoalKeeper = new GoalKeeper()
And the from my main swf, i just make a reference to use myGoalKeeper.
Code:
var rootGoalKeeper:GoalKeeper = externalSwf.myGoalKeeper;
And when i run the main swf, i got the following error?
TypeError: Error #1034: Type Coercion failed: cannot convert game::GoalKeeper@35896381 to game.GoalKeeper.
myGoalKeeper is just an instance of GoalKeeper class, what is wrong?
Note:I develop classes in Adobe Flex and compile my projects in Adobe Flash CS3.
Converting (casting?) TextFormat Object From ComboBox
I've a textfield that can have different TextFormats applied to it - these formats are in a combo:
var comboProp:Array = [{label:"Body style 1", data:myFormat1}, {label:"Body Sytle 2", data:myFormat2}, ....etc
The listener function needs to set the TextFormat of the field to the chosen combo value:
field_txt.setTextFormat(ComboBox(evt.currentTarget ).selectedItem.data);
but I'm getting all sorts of errors - notably:
cannot convert "[object TextFormat]" to flash.text.TextFormat.
I've tried appending ....data.getTextFormat() to the end of the above but no joy. I guess this is a simple schoolboy error but if anyone can help I'd most appreciate it!
Cheers,
Pt
Flash MX Casting Problems: String Value To Object._name?
I am importing delimited from asp that I have split into an array.
I'm trying to tell a movie clip instances to play with the move clip name based off the [i] "numbers".
I can get setproperty to render the visibility property however I can seem to get the casting of the variable right in order to tell the movie to play.
Example of what I need to work.
Array [0] //Output: mc25 which is also the name of a mc instance.
newmc= Array[0];
newmc._play;
The above doesn't work and I know that is somehow related to newmc being a string value. How do I convert the sting back to a mc._name?
Also:
[-----Works---------------------------------------------------------]
chec=b25;
bog= chec;
group=bog;
setProperty(group,_currentframe,group.gotoAndPlay( group._currentframe+1));
displaytextbox=group;------------------------------------------------------------------------
[----Doesn’t-------------------------------------------------------]
chec=b25;
bog=String(chec);
group=bog;
setProperty(group,_currentframe,group.gotoAndPlay( group._currentframe+1));
displaytextbox=group; -----------------------------------------------------------------------
Any Ideas?
Compile Type Check For Object Type
I used Flex Builder 3 to compile my actionscript. I have a question regarding the compile type check for type Object. I have set my compiler to strict mode, but it does not seem to detect this compile type error:
var o:Object = new Object();
o.foo(); //this should generate compile type error because foo() is not method inside Object, but flex builder is just silent.
But if I try this
var s:String = new String();
s.foo(); //flex build flag this as error
flex builder correctly detects the reference error.
I can't understand the reason for the different behavior for the Object type versus the String type. Can anyone help to explain the reason for this?
Thanks.
Any Way To Check What Type Of Object The Object Is?
Hey, i was wondering if there is a command to check what type object a certain object is
ex:
function circle(radius){
this.radius = radius
}
functin squre(side){
this.side = side
}
shape1 = new circle(25);
shape2 = new square(10);
//====this is just an example of what i want happen =============
type = getType(shape1)
trace(type);
this will trace "circle"
is there a command that can do is? I thought i saw it somewhere, but i cant find it
Hot To Get The Type Of An Object
Hi,
There is a way to get the type of the object in Flash?
EG.: trace (getType(myobject));
will return MovieClip, Array, Number, String, etc...
Thanks.
Type Of The Object
Hi,
is there any way how to find out the type of the Object? If it's TextField or Sprite? Let's say I have a container with different objects during a time and I need to know if ChildAt(0) is TextField or not.
PHP Code:
var container:Sprite = new Sprite();
var object1:MovieClip = new MovieClip();
var object2:TextField = new TextField();
container.addChild(object1);
container.addChild(object2);
trace (container.getChildAt(0) == TextField); // ???
thanks
Object Type
Just wondering if there is a quick way to determine the type of all the objects within a certain MovieClip. I know I can do a for..in loop to return all of the objects and I know that if there are any flash pre-built components within the MC I can use the "className" property to determine what kind of component they are, but I'd also like to know which objects are text fields, buttons, and nested movie clips.
I know I can do checks for multiple properties on each object and narrow it down from that, but I was hoping there might be a more straight forward way to determine what all the objects are.
Thanks in advance,
--carriker
Get Object Type
Hello Guys
I am making an application that generating objects from different types of classes, I want to get the object type or the class name of that object in runtime,
I found typeof operator but it returns back a string representing 6 of basic types like string, number...
And sure this is not what I need,
Is there any way to do that?
Object Type
if an object comes back as [Object object] through trace -
is there a method to figure out what type of object it is? for example string, number, movieclip, etc?
Fancy Box Type Moving Graphic Type Cool Efect But Im To Dumb Type Thingy
i am tring to make a box thinky simaler to the one on www.starvingeyes.com but cant even work out how to start it. is there anyone who can point me in the right direction or to a tutorial ?
the box has a graphic inside a grided box the sections of the graphic fade in and out as the mouse goes over them and displays random sections when the user is not moving the mouse over the box
i did find java tutorials for this effect but would much preffer it to come from flash as java is a bugger to get working on some machines
Any way thanks in advance for any help
Steven Green one_mad_punk@yahoo.co.uk
Changing Object Type
In the properties pane, you can select and object and specify wheather you want it to be a graphic, movie clip or button. Is there any way of changing this property in with ActionScripting?
Thank you
Detect Object Type
How can I detect the object type of an object referenced by a variable? I would like write a function to pass in "myVar" and have it return "listbox."
Thanks,
Rachel
Determining Object Type
I have a bunch of input textfield, radio buttons and checkboxes on my stage. I'd like to run a function that will go through all the object on my stage and determine the type.
I can manage to loop on all objects my using the for...in loop, but I can't manage to get the type of object. I tried using instanceof but this didn't work.
This is what I tried:
code:
for(var prop in _root) {
if(prop instanceof TextField) {
trace(prop + " is a TextField");
}
else if(prop instanceof CheckBox) {
trace(prop + " is a CheckBox");
}
}
Can anyone please tell me where I am going wrong.
Thanks in advance for any help.
Object Type Issue (maybe?)
hello all and thanks for reading.
I am developing a flash FLV player that sends stats back to our server on quarterly intervals to monitor our clients bandwidth. I break the totalBytes of the movie into quarters by dividing by 4 and if the amount loaded is over x percent, the SWF reports back to the server the amount of bytes that have loaded. I can't go into why I am doing it this way, other than we use a network to host our FLV files that does NOT provide detailed bandwidth reports, so every time a player is loaded, the player reports back to us the amount loaded. Here's the issue:
I am assigning a simple number to LoadVars and for some reason - even though when I trace the number comes up as it should: 276188.5 it is sent to the server as -0.25.
Pretty sure this is something obvious, but it's been one of those days. Hell its one of those Projects!
in the code below I am only working with the first 25% - Ill do the rest when I get this figured out.
Any help is much appreciated!!
Code:
// file load progress
percentBar.onEnterFrame = function() {
loaded = this._parent.ns.bytesLoaded;
//trace('loaded: ' + loaded)
total = this._parent.ns.bytesTotal;
//trace('total: ' + total);
//send quarterly stats back to the server:
quarterLoad = total/4;
//trace('quarterLoad: ' + quarterLoad);
totalLoaded = 1;
//trace('totalLoaded: ' + totalLoaded)
if(loaded > totalLoaded*quarterLoad){
//divide the total amount by four and divide the total by the 25% increments to see the percentage of total loaded movie.
loadPercentage = Math.floor((loaded/quarterLoad)*25);
//trace('loadPercentage: ' + loadPercentage);
if(loadPercentage == "100"){
trace("100% loaded");
} else if(loadPercentage >= 75){
trace("100% loaded");
} else if(loadPercentage >= 50){
trace("75% loaded");
} else if(loadPercentage >= 25){
trace("50% loaded");
} else if(loadPercentage >= 0){
if(!_root.oneLoaded){
//create a connection to send the data to the server
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
trace("result = " + result_lv.result);
trace("quarterload =" + quarterLoad) ;
//result_ta.text = result_lv.referrer;
//confrimMessage._visible = true;
} else {
trace("Error connecting to server.");
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.mid = _root.file;
send_lv.referURL = _root.thisURL;
send_lv.bytes = quarterLoad;
send_lv.userID = 000000;
trace ("quarterLoad");
send_lv.sendAndLoad("http://vstats.tv/stats.jetpac.tv/stat.php", result_lv, "POST");
trace("25% loaded - data SENT-------------------------------------------");
_root.oneLoaded = true;
}
}
}
Object To XML Type Conversion?
I am using HTTPService for communication with php script which reads remote xml file and returns it to Flash. HTTPService in Flash recieves the file as Object type so i can't use E4X to parse it. I can set
Code:
HTTPService.resultFormat="e4x"
but i would like to know how can i in general convert that Object type to XML type without using that built in property? Because there are some occasions when i am not using HTTPService so that property isn't available.
thanks in advance
Determining Object Type
Lets say I have an object named BaseObject, then I have a few objects derived from that object. Like Ship, Asteroid, and Bullet. I have a list of BaseObjects, and run though all of them calling a collide function on all of them, such as:
a.collide(b);
// this is the definition
public function collide(obj:BaseObject) { /* do stuff */ }
once i get to the "do stuff", I need to know what kind of object obj is. Is there any function that returns what kind it is? Or do I just need to have a overridden get type function that returns an Id for the type?
Check Object Type
Is there a way to check the type of an object. For example if it's a MovieClip or Dynamic Text?
Shared Object Type
When i save an object from a class i made into a SharedObject, it disappears if i reload the SWF. Is it possible to store an object from a class I made in a SharedObject and keep it on the local machine? If not, is there any other way to save it (besides saving all the primitives in it)?
ex:
var sO:SharedObject = SharedObject.getLocal("Data0");
var someObj:SomeClassIMade = new SomeClassIMade();
sO.data.myObject(someObj);
//Then reload and have it still in there.
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
Unknown Object Type Tag?
Hi,
I'm working on an AS3/CFC project and am trying to pass an Indexed Array to a CFC Component. Here is the array being sent to my NetConnection instance:
var array:Array = new Array();
array[0] = "First";
array[1] = "Second";
array[2] = "Third";
cfc.call("cfc.saveData.addItems", responder, array);
and my Responder instance runs the fail function and I trace this error:
err.type =
err.description = Unknown object type tag (17)
err.level = error
err.details =
err.code = Client.Message.Encoding
I've narrowed the problem down to array's and objects, because when I change the type of the argument to number, boolean or anything else it works fine..
Here is the really simple CFC:
<cffunction name="addItems" access="remote" returntype="boolean" output="yes">
<cfargument name="itemArray" type="array" required="true">
<cfreturn true>
</cffunction>
Any ideas?? This error has been driving me crazy for the past two days, and I can't find any documentation....
THANKS!!!!!
Object To XML Type Conversion?
I am using HTTPService for communication with php script which reads remote xml file and returns it to Flash. HTTPService in Flash recieves the file as Object type so i can't use E4X to parse it. I can set
Code:
HTTPService.resultFormat="e4x"
but i would like to know how can i in general convert that Object type to XML type without using that built in property? Because there are some occasions when i am not using HTTPService so that property isn't available.
thanks in advance
Get The Class Type Of An Object
Say I created an object like this:
var p = new BasketBall();
I want to access a certain property of p, such that it would return "BasketBall" or anytihng to indicate for me the class type. Is that possible?
Thanks
Question About Using An Interface As Object Type
Hi all,
I am typing some of my objects to the Interface they implement. While this is helpful is many ways, I am finding myself needing to cast every time I wanted to access the object's properties such as x, y or invoke methods like addChild() and such.
I don't mid casting a few times, but it really getting to a point where there is to much casting involved. Any idea how to get around this problem?
Cheers
For In - No Longer Works Unless Object Type
So I find it impossible to iterate over the various properties and functions of a custom class...this is unfortunate, it was cool to set some random properties in step 1..
step 2 iterates over the whatever and pulls the properties we set in step 1. This was very useful, now how is the best way to do this in as3. Not even casting to Object works. It blanks the for ..in loop doesnt loop cant see my properties that exist in the class..
???thanks for aid in this matter..
Identifying The Object Type From An Instance Name...?
hi
im trying to document and understand some legacy code and im having trouble identifying an object / instance named palDesc.
it appears with a gotoAndStop(1) function in the code I', looking at, so im sure its a mc but for the life of me i cant find the instance any where within the stage...
ive tried using the movie explorer but it wasnt much help
has any one got any ideas of how i can search for an item within the context of a movie via the instance name???
many thanks
< Var Type Checking And _global Object Syntax.
Hi, I am a litttle bit confused about variable scope when using AS2 syntax and variable checking.. I can assign a variable as a boleean as below..
Code:
var firstTime:Boolean = true;
now how can I attach this to the _global object??
Code:
var _global.firstTime:Boolean = true;
gives errors.. Is any variable defined on the _root _global by default?? Can someone help me out on this??
Array Pop() Question ..returning Object Type
I have an Array
Code:
var someArray:Array = [1,2,3,4,5,6,7,8,9,0];
Now as you can clearly see the last element is of 'number' type. But when i do
Code:
var digit:Number = someArray.pop();
I get the error:
Code:
Type mismatch in assignment statement: found Object where Number is required.
var myNumber:Number = someArray.pop();
So clearly it appears that the pop() is returning an Object rather than a Number
Now the even stranger thing is if i do
Code:
trace(typeof someArray.pop()); // this traces out number
Does anyone know why this is happening? I mean i can fix this problem by doing:
Code:
var digit:Number = Number(someArray.pop());
But would like to know what is causing the problem in the first place? Thanks for the feedback!!
Array Pop() Question ..returning Object Type
I have an Array
Code:
var someArray:Array = [1,2,3,4,5,6,7,8,9,0];
Now as you can clearly see the last element is of 'number' type. But when i do
Code:
var digit:Number = someArray.pop();
I get the error:
Code:
Type mismatch in assignment statement: found Object where Number is required.
var myNumber:Number = someArray.pop();
So clearly it appears that the pop() is returning an Object rather than a Number
Now the even stranger thing is if i do
Code:
trace(typeof someArray.pop()); // this traces out number
Does anyone know why this is happening? I mean i can fix this problem by doing:
Code:
var digit:Number = Number(someArray.pop());
But would like to know what is causing the problem in the first place? Thanks for the feedback!!
Setting Data Type Of An Object At Run Time
This is something of an advanced problem, so I hope there's someone out there who can speak to this. I apologize for the length of the post, I'm just trying to be clear about a rather unclear conundrum. --
We all use arrays to hold collections of things. As you know, an array is its self a type (Array) and so there is no way to declare, for instance, an array of MovieClips or an array of Strings. Heres what happens: lets pretend that we have 3 movie clips clip1_mc, clip2_mc, and clip3_mc, and an Array called anArray. so we can legally do this. anArray.push( clip1_mc ); anArray.push( clip2_mc ); anArray.push( clip3_mc );. An array of size 3. Now the code: trace( typeof anArray[0] ); will output "object." This can be a problem. If you try this: var newClip:MovieClip = anArray[0]; you get a type mismatch from the compiler. "Found Object where MovieClip is required." It necessitates this: var newClip:MovieClip = MovieClip( anArray[0] ); Bummer no?
Ok. So fast forward. Lets assume a class List that uses an array to hold the items in the list. So the class uses the Array class in "composition." So you have methods like insert( ); and retrieve(). Retriece() returns an item from an index in the array. Because of the aforementioned problem, no matter what type the thing was going into the list it comes out with type Object because the retrieve function must return an item of some type, the only option is to declare the return type of the retrieve() function as Object. Lets say you know that this is a list of Strings. You could write the retrieve()'s code like: return String( returnItem ); And type the object "on the way out" .. but what if you want the list to work with any type object, you would have to have a variable to hold the desired type of objects in the list. And then as the objects are being returned, you'd cast them to the type stored in that variable. I guess that you'd pass the type to the constructor of the List: var aList:List = new List( "AddressCard" ); -- That should declare a List (Array) of AddressCards.
Is there a way to do this? have the type specified in casting be dynamic?
And the flip-side of that is detecting the name of the class of an object instance. The thing here would be to try to derive a String from the name of the constructor function. (which is always the class name) In actionscript 3 there is a service package-- mx.util -- I think, that has a function to return the qualified class name of an object. But is there a jimmy rig for this in AS2?
My actual project does not use an Array to implement List. ( or Stack ) It uses a structure called a "linked list" - which is a whole other topic, but same problem as with Arrays is also present in the linked list versions and so requires the same solution. If one is willing to type things explicitly when assigning an item in the list to a variable of some type, this thing is quite excellent. But I don't like it. I have the package with docs, code, sample fla's, diagrams and everything that I would encourage people to download, look at, try and whatever and then come back here with any thoughts on it. There is a component with Flash professional that is a list like structure, but it's so general that it crosses the line into bloat. Ie: if you are using a list as a stack, you only need getTop() and pop() and push() not all the other (12 or so) methods in the class. Mine are patterned after structures from the C++ standard template library. And the code style is C++, but I think it's actually easier to read that way.
the files: http://www.null.bz/ADL_Lib/ADT_Lib.zip
Thanks in advance, for your efforts! I really appreciate all of it, helpful or not.
How Would One Convert A Variable Of Type STRING To An OBJECT
Hi There,
I have an array of column names (ie strings) that i want to use to iterate through a dataProvider's label..
IOW
Code:
var columnList_ar:Array = new Array("jobID", "Customer", "Due_Date", "Status", "Quantity", "Media_Type", "Disc_Type", "Print_Colour", "Notes");
followed by...
Code:
for (var i:Number = 0; i < jobInfo_grd.dataProvider.length; i++){
for (var j:Number = 0; j < 9; j++){
trace (jobInfo_grd.dataProvider.getItemAt(0).columnList_ar[j]);
}
}
How do i convert the string called from the array, to a meaningful object that dataProvider command can understand?
Cheers,
joey!
Setting Data Type Of An Object At Run Time
This is something of an advanced problem, so I hope there's someone out there who can speak to this. I apologize for the length of the post, I'm just trying to be clear about a rather unclear conundrum. --
We all use arrays to hold collections of things. As you know, an array is its self a type (Array) and so there is no way to declare, for instance, an array of MovieClips or an array of Strings. Heres what happens: lets pretend that we have 3 movie clips clip1_mc, clip2_mc, and clip3_mc, and an Array called anArray. so we can legally do this. anArray.push( clip1_mc ); anArray.push( clip2_mc ); anArray.push( clip3_mc );. An array of size 3. Now the code: trace( typeof anArray[0] ); will output "object." This can be a problem. If you try this: var newClip:MovieClip = anArray[0]; you get a type mismatch from the compiler. "Found Object where MovieClip is required." It necessitates this: var newClip:MovieClip = MovieClip( anArray[0] ); Bummer no?
Ok. So fast forward. Lets assume a class List that uses an array to hold the items in the list. So the class uses the Array class in "composition." So you have methods like insert( ); and retrieve(). Retriece() returns an item from an index in the array. Because of the aforementioned problem, no matter what type the thing was going into the list it comes out with type Object because the retrieve function must return an item of some type, the only option is to declare the return type of the retrieve() function as Object. Lets say you know that this is a list of Strings. You could write the retrieve()'s code like: return String( returnItem ); And type the object "on the way out" .. but what if you want the list to work with any type object, you would have to have a variable to hold the desired type of objects in the list. And then as the objects are being returned, you'd cast them to the type stored in that variable. I guess that you'd pass the type to the constructor of the List: var aList:List = new List( "AddressCard" ); -- That should declare a List (Array) of AddressCards.
Is there a way to do this? have the type specified in casting be dynamic?
And the flip-side of that is detecting the name of the class of an object instance. The thing here would be to try to derive a String from the name of the constructor function. (which is always the class name) In actionscript 3 there is a service package-- mx.util -- I think, that has a function to return the qualified class name of an object. But is there a jimmy rig for this in AS2?
My actual project does not use an Array to implement List. ( or Stack ) It uses a structure called a "linked list" - which is a whole other topic, but same problem as with Arrays is also present in the linked list versions and so requires the same solution. If one is willing to type things explicitly when assigning an item in the list to a variable of some type, this thing is quite excellent. But I don't like it. I have the package with docs, code, sample fla's, diagrams and everything that I would encourage people to download, look at, try and whatever and then come back here with any thoughts on it. There is a component with Flash professional that is a list like structure, but it's so general that it crosses the line into bloat. Ie: if you are using a list as a stack, you only need getTop() and pop() and push() not all the other (12 or so) methods in the class. Mine are patterned after structures from the C++ standard template library. And the code style is C++, but I think it's actually easier to read that way.
the files: http://www.null.bz/ADL_Lib/ADT_Lib.zip
Thanks in advance, for your efforts! I really appreciate all of it, helpful or not.
Edited: 01/05/2007 at 11:35:37 AM by sl0beck
Setting A Property For A Specific Type Of Object
I have about 40 textinput components on stage and I want them all to have their enabled property set to false when my message box movie clip becomes visible.
Insted of typing 40 lines of the same code setting each instance of the textinput component to .enabled = false, could I just loop round each textinput component and set it to .enabled = false?
How would I do this?
I know in VB I can use a FOR EACH satement but how would I do it in flash?
persudo code>
if(msgbox._visible = true){
FOREACH (instance OF textinput) {
.enabled = false
}
}
Storing A Data Object In Native Type To MySQL
I have an object which stores data for a user-editable dictionary, the format for which is as follows:
var dictOb:Object = {word0: "Hello",
word0Value: 78,
word1: "World",
word1Value: 83,
etc...
I'd like to be able to send this straight to the database as one chunk of data without having to convert it all to a string (& then have to convert it back later) to store in just one field in the database on the same row as my other user data (username, password, etc). I've read that you can do this with the AMF format and I've looked into amfphp but I can't find any helpful examples of how I might achieve this.
Has anyone done this before? Could you give me a good old nudge in the direction I wanna be going?
Goowaaan
|