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
FlashKit > Flash Help > Flash MX
Posted on: 05-04-2003, 01:34 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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.
Check Object Type
Is there a way to check the type of an object. For example if it's a MovieClip or Dynamic Text?
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?
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?
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
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?
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
What Data Type Would This Be? & Tracing The Index Of An Object On Stage.
okay i know this is lame, but i tried assigning different data types to it but it gives an error. i just wanna strict data type my stuff
i have a addEventListener(MouseEvent.MOUSE_CLICK, myFunc) added to one of my MovieClips on stage. Everytime id want to refernce that object that as been clicked. i would reference it by "event.target" is that correct?
what data type is "event.target"?
lets say i do
Code:
var target = event.target;
i traced that using
Code:
trace(typeof(target)); // and it returns "object"
however when i try to data type the variable as an object
Code:
var target:Object = event.target;
i get an error..
what i am actaully aiming to do is to get the Index of the object. when i tried
Code:
getChildIndex(event.target);
i get an error... it only works when i did this
Code:
var target = event.target;
trace(getChildIndex(target));
so what datatype is "event.target"?
or is there a better way to get the Index of the Child?
im still a noob at AS3.0 and would like to seek advice.
thank you so much whoever who helps me with this in advance...
and sorry for this stupid question
Check For The End Of A Sound Object
I have a number of wav files that I would like to have played one after the other. Is there any way of testing for the end of a sound object (say sound1) so I can have the script attachSound and start the next one (say sound2).
Regards Geoff Walden
Check If An Object Is On The Stage
Hey,
i need to check if the object is on the stage. I need to do something like this:
Code:
for (var i in this) {
if (this[i] instanceof TextField) {
this[i].text = "show this text";
}
}
Thanks
[F8] Check For Shared Object
I am currently using shared objects in my flash preloader so that if the flash has already been loaded, it will skip the preloader. I can get the shared object to be created but does anyone know any code to check if it has been created.
Thank you
James
How To Check If Object Is Of A Certain Class.
Hi..
Maybe this is a newbish question, but..
Lets say i have a window.
And i dynamically add "Label" objects to this window.
At some point, I want to remove all Label objects from this window.
So, what i tried is to use the "getChildAt()" method to access each child the window has.
I tried to check if the object was of the "Label" class using the "isPrototypeOf()" method.
But it doesnt work, it always returns false.
How can i check whether a child is of a certain class or not?
HELP
Check If Object Exists?
Hi everyone,
Let's say i have a menu comprised of several movie clips which are defined as buttons. Each of these MC contains a dynamic TextFields. The TextFields' text is set from an array this way:
Code:
total = arrId.length;
for (i=0; i<total; i++) {
root["mc_"+arrId[i]]["txt_"+arrId[i]].text = arrTitles[i];
}
}
So for example, this will set mc_aboutus.txt_aboutus.text = "About Us", mc_contact.txt_contact.text = "Contact", and so on. Now, the problem i have is that the MCs are created on the stage beforehand, but the array is built from an XML file, so i need to check if the MCs exist before i set their text property. I'd need to do something like:
Code:
if (root["mc_"+arrId[i]]["txt_"+arrId[i]] exists)
{
root["mc_"+arrId[i]]["txt_"+arrId[i]].text = arrTitles[i];
}
else
{
// do nothing
}
How do i check that each MC exists?
Thanks for any input!
Draggable Object, Please Check Script...
hey guys, i have searched this forum and a few others but i have come up blank. i have a set of 4 buttons and i have an arrow underneath them, so when the user scrolls over the button, the arrow eases underneath BUT i only want the arrow to move when the cursor is near the buttons, so when the mouse is all over the screen, the arrow will not move continuously all over the place. simple enough, should be the problem that i am having is that when i add my script ( that has easing AS in it) to the arrow, it moves all over the screen. i tried the hit test and constraining it and that works but the arrow will not "ease" into place. i know there's a ton of posts but i cant seem to add them together. here is the script on my button thus far:
onClipEvent (load) {
_x = 460;
_y = 530;
speed = 3.5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse = 530;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
this eases my button fine and on the y axis, but how can i get it to only ease within a certain width of the x axis?
im not asking for a script, jsut guidance on where im going wrong with this
thanks for the help
Tracy
Check If Shared Object Exists, Then...
Hi there,
I need to check whether a shared object exists or not. If it exists then the user is taken to another frame.
I'm using this at the moment
ActionScript:
ActionScript Code:
if(user_so.data.fromCountry !=null );
{
trace("SO"+user_so.data.fromCountry)
gotoAndPlay(2);
}
When the movie starts up the user selects there country which is a value ie. 1,2,3... which is written into the shared object.
When they restart the movie,they should go straight to frame 2
for some reason the movie just displays nothing.. the components are all gone(on frame 2)
When I trace the shared object in flash I get the value but as soon as its browser based.. its a no go...
Any ideas?
Thanx
[MX] Check If Sound Object Exists
Hello!
I am loading sounds dynamically in my file. How on Earth can I check if the dynamic name I generate corresponds to a valid sound file in the library?
The code is somewhat similar to this:
mySound = new Sound();
mySound.attachSound(mp3prefix + ".mp3");
But well, attachSound returns nothing, so I can't put it inside an if statement to check if it was executed correctly. Even worse, when it's unsuccessful, it doesn't empty the mySound object but leaves its contents there, so object size checking doesn't do either. Can you recommend me a solution?
Thanks,
Peter
How To Check If An Object Exist On Stage.
once and for all someone give me an answer, for AS3.
people thi is how you rock:
ActionScript Code:
if (neslide.map) {
//var maptween:Map = new Map(this,origwidth,origheight);
getChildByName("neslide").nextFrame();
}
not like this:
ActionScript Code:
//if (ApplicationDomain.currentDomain.hasDefinition(getChildByName("neslide").map)) {
//var maptween:Map = new Map(this,origwidth,origheight);
getChildByName("neslide").nextFrame();
//}
Check If Object Is/isn't Present In The Movie
I'm pretty new to Flash, animation, and games, and now I've started my first game, something similar to Breakout. I got pretty far, made a paddle, got scoring to work, ball to bounce etc. My question is what should I put into the Actionscript, that checks if all bricks are gone? If they are gone, go to next scene/frame. How would you do something like this? Thanks for help.
Check If Shared Object Exists, Then...
Hi there,
I need to check whether a shared object exists or not. If it exists then the user is taken to another frame.
I'm using this at the moment
ActionScript:
ActionScript Code:
if(user_so.data.fromCountry !=null );
{
trace("SO"+user_so.data.fromCountry)
gotoAndPlay(2);
}
When the movie starts up the user selects there country which is a value ie. 1,2,3... which is written into the shared object.
When they restart the movie,they should go straight to frame 2
for some reason the movie just displays nothing.. the components are all gone(on frame 2)
When I trace the shared object in flash I get the value but as soon as its browser based.. its a no go...
Any ideas?
Thanx
[How-to] Check If A Key/value Pair Exists In Object
For beginners, sometimes an easy thing is the hardest thing to look for in tutorials/documentation. They're just too simple that most documentation will not cover it, or searching on google will give you bunch of rubbish results...
Anyway, I'll cut the crap, here's my question
How to check if a key/value pair exists in associate array (Object) in AS3? In PHP you can do something like
if (isset($foo['bar'])) echo "exist";
Suggestions/ideas: Creating 360-degree QTVR-type Object Rotation
I need to build a 360-degree rotatable object, similar to Quicktime VR, but I'd rather do it in Flash. I'm seeking advice on a good way to do this.
The source material is coming from Maya-generated renderings. There is no up/down movement, we're just spinning the object around. Control will probably come from mousing over the left or right side of the image (or clicking/dragging) to cause the image to rotate.
I have a couple of ideas but I'm sure some of you have better ones...
1. Do as series of still frames. Render 1 still image every 5 degrees (for example). String them together as Flash frames, and use mouse-over or click-drag to move forward or backward through the frames.
2. Do as FLV, and use mouse-over or click-drag to move forward and backward through the video.
My thinking is, of these options, the first option will provide for better quality images and more precise control.
But there may be entirely different ways of doing this that make more sense. Anyone have a suggestion?
Using An Object To Check Progress Of Movies Loading
Hey there, thanks for checking this. I am publishing a movie to flash player 6 so i cant use the movieclip loadeer class.
I am tryinng to load a bunch of movies using an associative array that holds the name of the object the external swf is to load into and the name of the swf like this:
(this code is on the root)
ActionScript Code:
var loadMovies:Object = new Object();
loadMovies.mainHolder = "main.swf";
loadMovies.sound = "sound.swf";
loadMovies.images = "picturews.swf";
function loadSWFs() {
with (_root) {
for (var k in loadMovies) {
trace(k+": "+loadMovies[k]);
this[k].loadMovie(loadMovies[k]);
}
}
}
loadSWFs();
My problem is that when I try and check if all of the movies have loaded. I have a 3 frame MC that should check and has this code on frame 2:
ActionScript Code:
function checkLoaded(target:MovieClip):Boolean {
var tmpBoo:Boolean = false;
if (target.getBytesLoaded()>=target.getBytesTotal()) {
tmpBoo = true;
}
return tmpBoo;
}
function checkMovies() {
var tmpBoo:Boolean = true;
for (var k in _root.loadMovies) {
if (!checkLoaded(k)) {
tmpBoo = false;
}
}
if (tmpBoo) {
gotoAndStop(3);
} else {
gotoAndPlay(1);
}
}
checkMovies();
I keep getting the error when I check the code that there is a type mismatch on the line with if (checkLoaded(k)) on. I am guessing this is because k is the wrong data type.
If anyone could help me to pass this variable to the checkLoaded() function that would really make my friday
Thanks!
Schm
Radio/check Button And Shared Object Save
Hello
I've got a monster offline exe application with multiple menu items.
Challenge: Custom Personal Quick Menu
Create a menu page where users can 'check' off the menu links that they most frequently use. These checked links will be 'remembered' via a cookie or shared object and dynamically be called and displayed in a "quick menu". Does that make sense?
If anyone has any suggestions that'd be great. I'm at an absolute loss on where to start and if it's even possible. My actionscripting skill is somewhere down the road from a beginner, but not far
|