Loading Sprite Using Loader Need Access to Sprite Type  
Author Message
vDiaz761





PostPosted: 2007-6-26 8:58:10 Top

flash-actionscript, Loading Sprite Using Loader Need Access to Sprite Type Hello,

I'm loading a Sprite via a Loader and once loaded I have access to that Sprite
via the Loader class. I can manipulate the Sprites alpha, x and y coordinates
ect. However, I have a custom function that fades in or out the passed param
and it expects a Sprite. When I pass the loaded Sprite (loaded via the Loader
class) I get an error:

1067: Implicit coercion of a value of type flash.display:Loader to an
unrelated type flash.display:Sprite.

I know that the problem is that it expects a Sprite, but how do I access the
Sprite type once the swf is loaded via the Loader?

My Code:
import FadeClip;

var ldrMovieCntr:Loader = new Loader();
addChild(ldrMovieCntr);

var fcLoadedMovie:FadeClip = new FadeClip(); //CUSTOM CLASS
fcLoadedMovie.setClipToFade(ldrMovieCntr); //PASSING IN A TYPE Loader - CLASS
EXPECTS A Sprite

Thanks in advanced,

Vic




 
vDiaz761





PostPosted: 2007-6-26 9:29:00 Top

flash-actionscript >> Loading Sprite Using Loader Need Access to Sprite Type I tried Loader.content after the clip is loaded:

fcLoadedMovie.setClipToFade(ldrMovieCntr.content);

Now I get this error:
1118: Implicit coercion of a value with static type
flash.display:DisplayObject to a possibly unrelated type flash.display:Sprite.

However when I trace("ldrMovieCntr.content " + ldrMovieCntr.content); I get:
ldrMovieCntr.content [object MovieClip]

Vic

 
kglad





PostPosted: 2007-6-26 9:40:00 Top

flash-actionscript >> Loading Sprite Using Loader Need Access to Sprite Type i doubt you're loading a sprite.
 
 
vDiaz761





PostPosted: 2007-6-26 9:50:00 Top

flash-actionscript >> Loading Sprite Using Loader Need Access to Sprite Type KGlad,

The class expects a Sprite, but I'm passing in a Loader with:

import FadeClip;

var ldrMovieCntr:Loader = new Loader();
addChild(ldrMovieCntr);

var fcLoadedMovie:FadeClip = new FadeClip(); //CUSTOM CLASS
fcLoadedMovie.setClipToFade(ldrMovieCntr); //PASSING IN A TYPE Loader - CLASS

and with the revised code, a DisplayObject::
fcLoadedMovie.setClipToFade(ldrMovieCntr.content);

I changed the expected Param in the Class to be object as apposed to Sprite,
but I was hoping for a better solution.

How can I load an swf via the Loader class and access it as a Sprite or
subclass of Sprite?

Thanks for the response,

Vic

 
 
kglad





PostPosted: 2007-6-26 10:02:00 Top

flash-actionscript >> Loading Sprite Using Loader Need Access to Sprite Type you can try casting it as a sprite, but it's really a movieclip so i can't see how that's going to work. does it only have 1 frame?
 
 
vDiaz761





PostPosted: 2007-6-26 10:06:00 Top

flash-actionscript >> Loading Sprite Using Loader Need Access to Sprite Type Currently it has one frame, but it will most likely contain many frames, I
tried casting it like this Movieclip(ldrMovieCntr) and it doesn't work.

What are the consequences of using Object instead of being more specific and
using Sprite in my class?

 
 
kglad





PostPosted: 2007-6-26 12:45:00 Top

flash-actionscript >> Loading Sprite Using Loader Need Access to Sprite Type i have no idea what the consequences are because i know nothing about your
class.

but it makes no sense to cast your loader as a movieclip. use the content
property of your loader. and you wouldn't cast it using Movieclip(). use
MovieClip(), if you needed to cast it. which isn't needed because it already
is a movieclip.