ActionScript 3 :: How To Detect Data Parameter Type
Apr 1, 2010
I'd like to make a call to a function and send either a string or an integer...
function getImage(val:*):void{
if(val == String){
switch(val){
case'next':
loadNext();
[Code[ .....
and vary my function accordingly...
View 2 Replies
Similar Posts:
Sep 3, 2009
I would like to know if is possible to pass a var type as parameter to a function. I have several sounds in library, and I would like to do something like that:
Code:
function PlayMe(soundname:String)
{
var snd:this[soundname] = new this[soundname];
snd.play();
}
View 4 Replies
Aug 16, 2010
Code:
<mx:Script>
public function dtFunc(hd:HitData):String {
return hd.item.Month + ":<B>$" +
hd.item.Profit + "</B>";
}
</mx:Script>
[Code]...
My dataTipFunction does not define what data type to pass in. How does flex automatically know it's a HitData type? Is there any other possible data type that actionscript accepts?
View 1 Replies
Sep 22, 2010
I'm trying to convert some C# code I have and one problem I can't find a solution for is to have a function take parameters of unknown types.
C# code:
PHP Code:
public T Maximum<T>(T v1, T v2){ return v1 > v2 != null ? v1 : v2;}
A straight translation to AS3 would look something like this, for making it easier to understand for people that might be confused by C# syntax.
[Code]...
This way you can send in anything as the parameters (notice the <T>), be different classes for example, depending on what situation you want to use it, instead of writing a lot of duplicate functions for every possible parameter type.
Is there a way to do this in AS3? Edit: Seems like I managed to find a solution right after I wrote this. Seems like one can use "*" as parameter type.
View 1 Replies
Oct 26, 2009
TypeError: Error #2007: Parameter type must be non-null.
at flash.events::EventDispatcher/addEventListener()
at INDEXnew_fla::Symbol31_120/go()
stop();
[code]......
View 3 Replies
Apr 14, 2008
It's monday morning and somehow my brain won't comprehend why this error is happening...... could anyone take a look and shed some light on this please?
TypeError: Error #2007: Parameter type must be non-null.
at flash.events::EventDispatcher/addEventListener()
at pages::MyProfile/initListeners()
at pages::MyProfile()
[Code]...
View 7 Replies
Oct 20, 2011
TypeError: Error #2007: Parameter type must be non-null. at flash.events::EventDispatcher/addEventListener()
at com.Objects.Maps::Map()[C:UsersJoshuaDesktopRTS Game ClassesMischief Map EditorcomObjectsMapsMap.as:59]
at com.Data.Managers::MapManager/GenerateMap()[C:UsersJoshuaDesktopRTS Game ClassesMischief Map EditorcomDataManagersMapManager.as:15] at MischiefMapEditor_fla::N
[Code]....
I've looked up the error code, and it could mean alot of things.
View 1 Replies
Feb 19, 2010
I want to know the type and version the browser that the user is running from within my Flex 4 application. I know I can get that information by using ExternalInterface to call Javascript. I know I can get that information from the server. I'm looking for a way to get that information directly from actionscript. I mean, isn't there a global variable or something that keeps this information?
View 1 Replies
Feb 22, 2011
It goes like this, we need to detect if the display is a Projector (or if the system is connected to a Projetor).the catch is this should be done from within the browser.so is it possible to do so by using anFlashActiveX (this does constrains to a single browser, so not an option)searching so far only reaveals display resolution. expecting if there is something still out there.
View 2 Replies
Jul 28, 2011
I need to send a byte array of data (its an image source) along with a bunch of other vars to a service.If I send the byte array using something like the following
var request:URLRequest = new URLRequest ( 'http://www.mydomain.com/upload.php' );
var loader: URLLoader = new URLLoader();
request.contentType = 'application/octet-stream';
[code].....
View 1 Replies
Nov 22, 2009
Is there a way to detect the type of a DisplayObject with a switch case statement?I noticed that you can check if the displayobject compared to the type returns true or false.
Trace(mydisplayObj is Sprite); //return true or false
Trace(mydisplayObj is MovieClip); //return true or false
But isn't there an option to get the type of the displayObject directly?
like,
switch (typeof(mydisplayObj)) {
case Sprite:
break;
[code]....
View 2 Replies
Jun 4, 2009
i load in AS3 data into flash and mantain their data type? Like receiving an array and even with arrays in it and recognizing that is an array instead of a standard string.
And if this is possible is it more reliable then using XML?
View 1 Replies
Feb 2, 2010
I've written the following method (in actionscript 3, it's a flash application) which returns what transformation type is required for the current mouse position in relation to a given element position.
An element can be moved, scaled and rotated. This method returns if any of these transformations are applicable with the given coordinates[code]...
View 2 Replies
Feb 2, 2010
I'm working on an accordion component and I was thinking that it'd be cool if I could write a very basic one and then set it up so that it would be possible to pass in any kind of container class and child class so long as they subclassed a particular parent or implemented an interface (haven't really gotten that far yet).
What I've noticed though is that I can't setup a default class for my constructor parameter. For example I'd like to do this:
Code:
public function DropDownList(containerClass:Class = ContainerSprite, childClass:Class = ChildSprite)
However it gives me the following error:
1047: Parameter initializer unknown or is not a compile-time constant.
[Code]....
View 4 Replies
Nov 5, 2007
is it possible to pass a parameter to flash from html together with the call of the .swf file? In the .swf I play different slide shows. The paramter I need, to know which slide show to start. I know that I can load parameters from xml or text files, but not how to pass a parameter directly wiht the call of the .swf.
View 3 Replies
Jun 21, 2007
I have a DataGrid bound to an XMLConnector and XMLDataSet. The XML data loads fine into the components. However, I cannot get the value of the selected index using: my_datagrid.selectedIndex
The call works fine if you use addItem to populate the grid.
Is there an issue being that the datagrid.selectedIndex parameter is bound to the XML components?
View 1 Replies
Aug 22, 2010
I have a main mxml file (flex4) and want to pass a parameter (user_name) to a component in a directory called components. When I run the program, the user_name is NOT being sent from the main to the component file. (Interestingly, if you make the component visible, you can see the parameter has been passed).
I have hacked much larger files down to get the following two files:
Main
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
[Code] .....
View 1 Replies
May 23, 2009
In my code there's a function that shows an image on the screen (or loads the image and shows a progress bar). This function is called by clicking on a thumbnail, and it uses a parameter [e.target.name] refering to the property "name" of the thumbnail clicked, which is an integer (or I believe so). The thumbnails are placed inside the cointaner_mc MovieClip.
Code:
container_mc.addEventListener(MouseEvent.CLICK, clickThumb);
function clickThumb(e:MouseEvent):void{
if (my_full_images[e.target.name] == undefined){[code]...
but I want to call this function by clicking on a button, which would need to pass another type of parameter, in this case, a variable which refers to the number of the image displayed on the screen plus one.I tried this:
Code:
clickThumb(image_num + 1);
But it doesn't work, I get the following error:
1067: Implicit coercion of a value of type Number to an unrelated type flash.events:MouseEvent.
How could I call the function clickThumb and make it use "image_num + 1" instead of "e.target.name" ?
Could I dispatch the event (MouseEvent.CLICK, clickThumb), passing this value "image_num + 1" ?
View 2 Replies
Mar 7, 2004
i've been struggling with the following:
i am creating a list of buttons with an attachMovie. the AS is :
//as
var i = -1;
while(++i<userlist.length){
var user = userlist[i];
[Code].....
okay the problem is this: then i assign an on click function to every button right in the while loop that uses the data parameter of the "ob" object and when i play the movie the data parameter is always the parameter of the last object created for all the buttons. I know why this is happening- it overWrites the old "ob" with the new with every itteration of the loop.
But how would i go differently about creating an individual "ob" for each button created and still be able to have a function with a data parameter like this.onRelease.userClicked(data)?
View 9 Replies
Aug 1, 2011
I have a situation where I have a List showing a queue of Upload Objects:
[Code]...
I would like to create three different views of the List: One showing All uploads in the queue Another showing only the Upload items with Upload.type == "Update" and another showing only the items with Upload.type == "Create". Another example of this would be on an email inbox, where we could filter "All, unread, or read". I realise I could just create three different lists, one for each view of the list (maybe I'm just being picky) but I was wondering: Is there is any easy way to conditionally select the items to display from a DataProvider based on a parameter (for example type =="Upload") so I don't have to juggle three separate ArrayCollections about?
View 2 Replies
Jul 14, 2011
when uing netsream.seek(), how can i make a new request to the server if the seconds parameter specifies a time outside of the currently buffered video data. I want to seek unloaded time
View 3 Replies
Nov 28, 2004
I need my script to somehow detect when the data in a datagrid has been updated [not by the user, like on(Change) but like onData or something]
View 1 Replies
Sep 16, 2004
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.
View 4 Replies
Dec 14, 2010
Can we skip an optional parameter and assign value to the parameter after the skipped one?
For example I have a function:
public function Dialog(message:String,title:String="Note",dialogsize:int=99):void
{
}
I can easily call the function with a message and a title:
Dialog("HELLO","Intro");
Is there a way to skip the title and just pass in the dialogsize? I've tried it but can't make it work:
Dialog("HELLO",,dialogsize);
Is it possible to skip some optional parameters without using (rest) parameter?
View 3 Replies
Aug 17, 2009
Below is basic structure of LetterClip class which extends WMovieClipwhich inreturns extends Movieclip Class.
public class LetterClip extends WMovieClip
{
public function LetterClip(char:String):void
[code]...
Error occurs at the push statement.It throws the given below error only when the same activity is executedsecond time in a sequece.
TypeError: Error #1034: Type Coercion failed: cannot convertorg.waterford.activity.erp.erp1.r1lt08.clipclass::LetterClip@282e9281 to org.waterford.activity.erp.erp1.r1lt08.clipclass.LetterClip.#Operating System: Windows XPBrowser: Microsoft IE
View 1 Replies
Nov 27, 2009
I have intercepted x-amf data being posted to a website from my computer by a flash application. I have the collected POST data in hex form. While some of it has translated directly to text, the rest is showing wierd symbols which probably means they're flash objects. How do I parse this data to get meaningful output outta it?
Basically, I need a script/program/anything that will take in amf data in the hex form, and output text and flash objects...
View 1 Replies
Oct 27, 2010
I know I can attach audio and video to a NetStream. Apparently, I can also attach text messages although I haven't seen an example (if you know of one, please let me know). I also know that I can record a stream via Flash Media Server. I'm wondering what other types of data - if anything - else I can attach to a NetStream and record?
View 1 Replies
Dec 29, 2011
I have a class with a contstructor that should only change the source of an image.
[Bindable]
[Embed(source='../pictures/test.jpg')]
private var _picture:Class;
[code]....
(the image is not an image, but a class)The problem is that when I call the constructor, let's say:
var test:Test = new Test(pictureAtStage.source);
Flashbuilder will give an error, becouse I can't tell the compiler what data type "newSource" at the constructor will have...
*edit:When i use _picture.source, the embedded source does not seem to be changed...?
View 3 Replies
Jan 15, 2006
I'm trying to do something such as:
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
View 3 Replies
May 1, 2008
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 3 Replies