Skip to main content
Participant
August 4, 2008
Answered

Loader changes name property of Sprite

  • August 4, 2008
  • 2 replies
  • 379 views
Hi,

I gave a name to a sprite and if traced, it shown the name given. But after loading an image into Sprite and name is traced only the instance name is shown. Please help me to solve this. Code added.

Thanks,

Manu
This topic has been closed for replies.
Correct answer Newsgroup_User
You could try adding:

tclip.mouseChildren = false;

Hope this helps!

tamagorci

Manu Palasery wrote:

> Hi,
>
> I gave a name to a sprite and if traced, it shown the name given. But after
> loading an image into Sprite and name is traced only the instance name is
> shown. Please help me to solve this. Code added.
>
> Thanks,
>
> Manu
>
> var scrollerClip = new Sprite();
> var toyNames:Array = new Array("toy0","toy1","toy2","toy3");
> var i:int;
> for(i=0;i<toyNames.length;i++){
> var tclip = toyNames ;
> tclip = new Sprite();
> tclip.name = toyNames
;
> tclip.graphics.beginFill(0xFF0000);
> tclip.graphics.drawCircle(30, 30, 30);
> scrollerClip.addChild(tclip);
> //
> var loader:Loader = new Loader();
> var toyURL:String = "../Images/iPhoneScroller/"+toyNames +".png";
> var request:URLRequest = new URLRequest(toyURL);
> loader.load(request);
> tclip.addChild(loader);
> //addChild(tclip);
> tclip.x = i*65;
> tclip.y = 5;
> tclip.buttonMode = true;
> tclip.useHandCursor = true;
> tclip.addEventListener(MouseEvent.MOUSE_OVER,eventHandler);
> tclip.addEventListener(MouseEvent.MOUSE_OUT,eventHandler2);
> }
> //
> addChild(scrollerClip);
> //
> function eventHandler(event:MouseEvent){
> event.target.scaleX = 1.10;
> event.target.scaleY = 1.10;
> }
> function eventHandler2(event:MouseEvent){
> event.target.scaleX = 1.0;
> event.target.scaleY = 1.0;
> }
> //
>
>

2 replies

kglad
Community Expert
Community Expert
August 4, 2008
the compiler should generate an error: tclip isn't declared and you're assigning it both a string and a sprite.

and i don't see where you're trying to trace the name property of tclip, the sprite.
Newsgroup_UserCorrect answer
Inspiring
August 4, 2008
You could try adding:

tclip.mouseChildren = false;

Hope this helps!

tamagorci

Manu Palasery wrote:

> Hi,
>
> I gave a name to a sprite and if traced, it shown the name given. But after
> loading an image into Sprite and name is traced only the instance name is
> shown. Please help me to solve this. Code added.
>
> Thanks,
>
> Manu
>
> var scrollerClip = new Sprite();
> var toyNames:Array = new Array("toy0","toy1","toy2","toy3");
> var i:int;
> for(i=0;i<toyNames.length;i++){
> var tclip = toyNames ;
> tclip = new Sprite();
> tclip.name = toyNames
;
> tclip.graphics.beginFill(0xFF0000);
> tclip.graphics.drawCircle(30, 30, 30);
> scrollerClip.addChild(tclip);
> //
> var loader:Loader = new Loader();
> var toyURL:String = "../Images/iPhoneScroller/"+toyNames +".png";
> var request:URLRequest = new URLRequest(toyURL);
> loader.load(request);
> tclip.addChild(loader);
> //addChild(tclip);
> tclip.x = i*65;
> tclip.y = 5;
> tclip.buttonMode = true;
> tclip.useHandCursor = true;
> tclip.addEventListener(MouseEvent.MOUSE_OVER,eventHandler);
> tclip.addEventListener(MouseEvent.MOUSE_OUT,eventHandler2);
> }
> //
> addChild(scrollerClip);
> //
> function eventHandler(event:MouseEvent){
> event.target.scaleX = 1.10;
> event.target.scaleY = 1.10;
> }
> function eventHandler2(event:MouseEvent){
> event.target.scaleX = 1.0;
> event.target.scaleY = 1.0;
> }
> //
>
>
Participant
August 5, 2008
Hi,

I added 'mouseChildren = false' . Now it works as i expected. Thanks tamagorci for the advice. Thanks kglad for the reply.

Thanks,

Manu