Actionscript :: Correctly Casting A Bitmap To A Class?

Nov 9, 2011

I have tree instance calling an iconFunction "getIconFromItem".

<mx:Tree dataProvider="{collection}" iconFunction="getIconFromItem" />

The getIconFromItem function is returning null even though the bitmap is not null.

public function getIconFromItem(item:Object):Class {
var result:Class = item.icon as Class ;
return result ;
}

Setting a break point on the return result line reveals that item.icon is a bitmap and result is null.

how to successfully cast a bitmap as class so that the bitmap is returned as an icon?

View 2 Replies


Similar Posts:


Actionscript 3 :: Implement Casting For Own Class?

Aug 16, 2011

I made a class in AS3 for representing complex numbers. It does not inherit anything. How can I enable casting from e.g. Numbers? I.e. I want this:

5 as Complex

to be the same as this:

new Complex(5);

is there a magic cast() function I can put in my class?

View 1 Replies

Professional :: Bitmap Not Drawing Correctly?

May 31, 2010

I'm a bit new to the ActionScript world, and I'm trying to get a custom class drawing a button correctly.I have a .png of a planet that I want to use for the image, this is how I load it:

imageRequest = new URLRequest(bmpName);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
imageLoader.load(imageRequest);

[code].....

View 1 Replies

Flex :: Casting Object From ArrayCollection To Instance Of Custom Class

Jan 28, 2011

I am using Flex 4 and for whatever reason I cannot get the following code to work which happens inside of a ListEvent handler for a dataGrid:
_tempRule = DataGrid(event.currentTarget).selectedItem as Rule;

Rule is a custom class, and the above code always returns null. The dataprovider for the datagrid is an ArrayCollection. If I try to wrap the above code to make it like the following:
DataGrid(event.currentTarget).selectedItem as Rule

I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert Object@e15a971 to com.mycompany.arcc.business.Rule

Now I know I have done this before with native Flex classes like Button, etc, but it my case it will not work. Here is the Rule class:
package com.mycompaany.arcc.business {
import flash.utils.describeType;
import mx.collections.ArrayCollection;
[Code] .....

View 2 Replies

Actionscript 3 :: Casting A Retrieved Mediator With PureMVC As Its Proper Class Returns Null?

Jul 15, 2010

I have a mediator that I've registered for a navigation page:

facade.registerMediator(new NavPageMediator(viewComponent));

I'm trying to retrieve that mediator on another page like so:

var navPageMediator:NavPageMediator = facade.retrieveMediator(NavPageMediator.NAME) as NavPageMediator;

However, that statement returns null. If I try to cast it using the NavPageMediator(facade.retrieveMediator(NavPageMediator.NAME)) syntax instead, I get a TypeError: Error #1034: Type Coercion failed: cannot convert com.website.mvc.view.page::NavPageMediator@237560a1 to com.website.mvc.view.page.NavPageMediator.`

I can't, for the life of me, understand why NavPageMediator@237560a1 would be unable to convert to NavPageMediator, nor what happened in between registering the mediator and retrieving it that caused this. Especially since trace(new NavPageMediator() as NavPageMediator); returns [object NavPageMediator].

Incidentally, and this may be part of my problem, I don't understand what the @hash at the end of the object is (@237560a1). Is it simply an internal identifier for that class instance?

Edit:Left a bit of important info: The SWF in which I instantiate and register the mediator is separate from the SWF in which I try to retrieve it.

View 1 Replies

ActionScript 3.0 :: How To Use The Date Class Correctly

Nov 30, 2009

I am trying to learn how to use the Date Class concisely - and only to display the Day, Month and Year properties. I have looked at Livedocs, O'Reilly books and quite a few tutorials, including Republic of Code, but I'm still not able to put this together. QUESTIONS:

1. can the Date Class be coded in an external as file and imported to the main movie?

2. can anyone point me to a resource that has a good explanation of how to implement the Date Class for the properties I need? I want to be able to display them on the STAGE.

View 2 Replies

Flex :: Creating Dynamic Class For Bitmap Containing BitmapData From SWC?

Jun 1, 2011

I have the following code

///Get BitmapData from library in SWC
var ClassReference:Class = getDefinitionByName(products[i].producticon+"Data") as Class;
// Create new BitmapData Instance From it

[Code]....

I get null in the trace. How do I make a dynamic class that I can refer to for this bitmap similar to how your reference a class from and embedded media?

View 1 Replies

AS3 :: Flash - Load Bitmap Data From The Library Without Specifying A Class Name For Linkage?

Feb 15, 2010

I have a movie clip that holds one bitmap image, some simple AS3 to change the image displayed, and a ton of bitmaps I've imported into my library.Currently, I swap the images by changing the bitmapData

holder.bitmapData = new test2(1,1);

but this requires me to check off 'Export for ActionScript' in every symbol. I'd rather not go through every bitmap in the library and do this, is there some way to reference them by their library name?

View 1 Replies

As3 :: Flex - Handling Inverted Pixels In BitmapData And Bitmap Class

Mar 29, 2010

I am using bitmapData and bitmap classes to render a mouse cursor on the display screen. The bitmapData consists of an area whose colors should be inverted according to the background color. This is a very basic thing which could be observed with text cursor(the vertical line with two small horizontals on top and bottom), when moved over the text area. want to be able to do the same with the pixels in my bitmapData, is there a way to find out the background color effectively and invert the color values? In this process i will be redrawing the whole pixels, is there any other efficient way to do that ?

View 1 Replies

ActionScript 3.0 :: Senocular Level - Put A Bitmap Inside A Clip Linked To A Class

May 4, 2009

Put a bitmap inside a clip linked to a class. do

[Code]...

Even more interestingly, you can make this even more perverted by doing

[Code]...

View 5 Replies

Flex :: Screen Casting Using 4.5

Jan 2, 2012

Is it possible to develop a Flex Mobile App to record the complete actions we do on the mobile?? Like recording (screencasting) all the activities I do on the Mobile Phone. I want to do this using Flash Builder 4.5.

View 2 Replies

Actionscript 3 :: Casting One Type To Another?

Mar 12, 2012

I have a base class called Room and a subclass called Attic, and another called Basement.

I have a controller class that has an attribute called CurrentLocation which is type Room. The idea is I want to be able to put Attic or Basement in that property and get it back, then cast that to whatever type it is.

So if on the controller the content is of type Attic, I'm trying to figure out how to explicitly cast it. I thought I knew but its not working... Here's what I thought it would be, borrowing from Java:

var myAttic:Attic = (Attic) Controller.CurrentLocation;

This gives me a syntax error:

1086: Syntax error: expecting semicolon before instance.

So how do you cast implicitly? Or can you? I could swear I've done this before as as3.

View 1 Replies

ActionScript 3.0 :: Library Bitmaps - Pass String To The Class Which Expects A Bitmap As A Parameter?

Nov 15, 2009

i have a bitmap in the library with export name Dots

1. how do i take this and pass it to the class which expects a Bitmap as a parameter? if i load it externally i could say:

[Code]...

View 5 Replies

ActionScript 3.0 :: Casting Variables Into Functions?

Feb 5, 2009

haven't wrote here for a while!This is what I'm trying to do:

var level:Number = 1;
var goat:* = "thisIsLevel" + (level + 1);
var camel:Function = goat;

[code].....

View 3 Replies

AS3 :: Casting A Subclass Into A Parent Variable?

Jan 7, 2010

I am calling on different types classes from within a loop. The objects can be of different types so therefore I am using the getDefinitionByName method. here is a piece of my code:

for(var y = 0; y < mapH; y++)
{
brickHolder[y] = new Array();

[Code]....

But I got an error when I tried to call on methods. The interface is blank; doesn't have any methods in it. I am not sure if that makes a difference. But the parent class inherits it and the subclasses inherit the parent class. Can I instead use the parent class?

var brick:ParentBrick2 = ParentBrick2(new classRef());

In a nutshell, what can I do to loosely cast these objects so I am able to use any subclass methods that get called?

View 4 Replies

Flex :: Casting Failed When Used Swf Loader?

Aug 18, 2011

Any class common between flash swf file, loaded in swfloader turns our to throw error ypeError: Error #1034: Type Coercion failed: cannot convert edia::PlayerContentView@12babac1 to media.PlayerContentView.My main swf has same class, since its been used by appplication all over, but when swfloader creates object of same name class, it adds 12babac1 to class name. and doesn't work for simple access of array values

public function get Current():media.PlayerContentView
{
return contentItems[VZPlay.CurrentIndex] as PlayerContentView;

[code].....

View 1 Replies

ActionScript 3.0 :: Difference In Casting 'as' Or Object()

Nov 4, 2010

What is exactly difference between casting with np: DisplayObject(myObj) or
myObj as DisplayObject

View 9 Replies

ActionScript 2.0 :: Shadow Casting Angle Bug?

Jan 10, 2011

Okay so quite an ambiguous title but what I'm trying to do is cast a shadow off shapes from a light source. Simple enough and I have it working but I just can't work out how to fix the problem of when the light source is at a certain angle to the shape I'm casting a shadow from.I know it's the whole 180 to -180 thing, but I just can't think of a work around.I've attached the swf and fla so you can see for yourself.Basically the code works by chucking points of the shape in an array and then arranging the array by the angle of each point from the light source. No big deal. From there it just takes the first and last point in the array and draws a shadow from there. Sketchy for the time being I know, but I just don't understand why it's doing what it is.

View 0 Replies

ActionScript 3.0 :: Casting A Remote-loaded SWF?

May 1, 2007

Let's say I have 3 items in the same package:Shouter interface - requires implementers to implement the shout() functionShell class - implements Shouter...this Shell.swf is to be loaded remotely from:ShellLoader class - loads Shell from a remote server, casts it as a Shouter and invokes its shout() function...uses allowDomain in order to cross-domain script.Now let's say ShellLoader.swf lives on and Shell.swf lives on ....I've got a cross-domain policy on Using LoaderContext's ApplicationDomain and SecurityDomain, I'm able to load and cast the Shell object as a Shouter and invoke the shout() function. Everything ok here.

Now let's say ShellLoader is run locally and is localTrusted. Shell.swf still lives on I'm now unable to use SecurityDomain property of LoaderContext within ShellLoader because it is now run locally. Shell.swf now exists in a different ApplicationDomain as my ShellLoader and I get the error "Type Coercion failed" when I try to cast the loader content as a Shouter.Is there anyway to resolve this issue? I believe it will require Shell.swf to be loaded in the same ApplicationDomain as ShellLoader but I don't know any way to do this when ShellLoader is run locally. Perhaps this is prevented in the Flash player on purpose?

View 7 Replies

ActionScript 3.0 :: Casting A 3d Movie Clip

Sep 1, 2009

I'm new to flash and actionscripting (i come from the land of ansi c but have traveled extensively). I've created a great animated animated 3d movie clip and want to have them generated on the stage in relation to an xml file. I've gotten this to work with a 2d movie clip but am running into problems casting a 3d object.my object (a movie clip - boxContainer with an instance name of boxContainer_mc) is built out of all movie clips in the following way (shown in tree form):[code]

View 6 Replies

Professional :: Casting String To Movie Clip?

Jan 14, 2010

I've been reading about this issue on the forums today, but I still don't understand what i'm doing wrong here:var theMC:String = "mcMenuItem1";var myX=[theMC];trace("myX = "+myX);myX.gotoAndStop(2);From what I've read, this should cast theMC string into a movie clip that exists on the stage, but I still get the error:TypeError: Error #1006: gotoAndStop is not a function.What am I doing wrong here? Or what is it that I've missed?

View 4 Replies

ActionScript 3.0 :: Cross-scripting And Type-casting?

Jul 5, 2010

I wrote a post a week ago but it seems no one is able to help or I didn't explain my problem well enough, so here I go again.I want to load an external SWF, get an object reference from it and add it to the PV3D scene of my main class. The problem is even though the types have the same names, they are not recognized as the same type.
 
---------------------------------pv3Dviewer--------------------------- -----------
package {
import org.papervision3d.objects.primitives.Sphere;
public class pv3Dviewer extends Sprite {

[code]....
 
When pv3Dviewer is run, it traces "no". If I try to assign shereRemote without type casting i get this error:TypeError: Error #1034: Type Coercion failed: cannot convert org.papervision3d.objects.primitives::Sphere@59930b1 to org.papervision3d.objects.primitives.Sphere.

View 7 Replies

ActionScript 3.0 :: Casting Results In Error #1009

Oct 28, 2011

I'm having a casting issue that I am hoping to resolve. I have 2 arrays:
 
1st array = the clip's parent that I'm trying to target 2nd array = the clip I'm trying to target
 
When I trace the results, I can see the clip and the clip's parent, they exist on the stage and are qualified. When I try and get the clip by name in part 3, I get an Error #1009.
 
Can someone lend insight into what I'm doing wrong, or suggest a better way of doing what I'm trying to do?

[Code]...

View 3 Replies

Flash :: Casting Variables To Movie Clip?

Apr 27, 2010

How i can convert gecko object to a movie clip

function finish(boxname, arrayname:Array):void {
for each (var item:String in arrayname) {
trace(boxname+"_"+item);

[Code]....

View 2 Replies

ActionScript 3.0 :: Implicit Casting Between Vector Types?

Dec 9, 2010

I'm trying to convert a generic JSON object into a somewhat complex typed dto-like object that has the following properties:

firstName:String
lastName:String
contactInfo:Vector.<ContactInfo>
resources:Vector.<Resource>

The way I'm doing this is by giving the function metadata which sort of maps the JSON data properties to these data properties and their types, using reflection.So, I have a JSON object that might look something like this:

Code:
{
firstName: "John",
lastName: "Smith",[code].........

and that didn't even compile.

View 0 Replies

ActionScript 3.0 :: Casting A String To Be A Resource Path?

Mar 18, 2011

I have a situation where I am trying to build a path to an xml node like this:

Code:
var personName:Object = ["xmLoader.xmlData.profilepage.p"]+num+[".p1name"];

Where "num" is a number passed into to the function. What is happenning is when I trace out personName after this code I get:

"xmLoader.xmlData.profilepage.p2.p1name"

instead of the value that resides at that node name (I can trace out p1name which is John from my processed xml earlier in the code).

View 5 Replies

ActionScript 2.0 :: Casting String Gotten From Xml To A Number Type?

May 1, 2007

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);

[code]....

View 2 Replies

ActionScript 3.0 :: Flash Casting Shadow / Light In 2d?

Sep 20, 2010

I want to make a game which uses a light effect similar to left4kdead (link). I just can't seem to be able to find how this effect is called. It will be strictly 2d top-down view.

View 13 Replies

Actionscript 3.0 :: Draw Lines With Flash's Core Graphic Class But Attach A Custom Bitmap To That Line?

Mar 31, 2009

[URL]

Are they just constantly adding MC's to the display list as the mouse is moved around? Doesn't that kill memory?

Is there a way to draw lines with Flash's core graphic class but attach a custom bitmap to that line?

View 10 Replies

Actionscript 3 :: Casting An Object Using 'as' Returns Null MyObject?

May 3, 2010

I am trying to create a custom object in AS3 to pass information to and from a server, which in this case will be Red5. In the below screenshots you will see that I am able to send a request for an object from as3, and receive it successfully from the java server. However, when I try to cast the received object to my defined objectType using 'as', it takes the value of null. It is my understanding that that when using "as" you're checking to see if your variable is a member of the specified data type. If the variable is not, then null will be returned.

This screenshot illustrates that I am have successfully received my object 'o' from red5 and I am just about to cast it to the (supposedly) identical datatype testObject of LobbyData:

[Code]...

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved