Thanks Evan and Craig for the reply's.

Will try the new alternatives and let you know about success/failure.
Anyways like I mentioned and Craig said; it does work if you hardcode the
reference. I am just interested in knowing why?

again
//Kristian

> 
> hi Kristian,
> 
> When generating objects of scripts on the fly to attach to sprites, 
> you're actually invoking the 'new' handler, not the 
> beginSprite handler:
> 
> xCursor = (script "flaCursorScript").new(2)
> 
> This almost makes sense if you think about it - the sprite 
> has already 
> begun (it's on the stage, and your movie is playing). What 
> you're doing 
> is creating a new script object and attaching that to an already 
> existing sprite.
> 
> therefore, I'm guessing (without looking at your whole movie) 
> that the 
> beginSprite isn't executing at all and you should add the following 
> handler to your behavior:
> 
> on new me
>     return me
> end
> 
> then in your calling script, refine it to read:
> 
> ...
> 
> xCursor = new(script "flaCursorScript")
> sprite(2).scriptInstanceList.Add(xCursor)
> sendSprite(2, #beginSprite)
> 
> ....
> Don't be tricked into thinking you can just shortcut the last 
> step and 
> put your 'beginsprite' code in your 'new'  handler - remember, the 
> script hasn't been attached to a sprite yet and will puke 
> when you try 
> to reference stuff like me.spriteNum.
> 
> check out this quite ugly movie (i keep reusing it, so i 
> should really 
> clean it up one of these days): 
> http://www.evanadelman.com/puppetTest/puppetTest.dir
> If you want further reference...
> 
> hth,
> Evan
> 
> 
> Kristian wrote:
> 
> >Hi,
> >
> >Below I have attached some simple code... The purpose with 
> the code is 
> >to (at runtime) be able to attach a behavior to a puppeted sprite 
> >containing a flash member. The code works as long as I do 
> not use the 
> >'pSpriteRef' variable and say instead type '2' or '3' (in 
> the exitFrame 
> >handler in the BEHAVIOR CODE below)... Unfortunately this 
> will not work 
> >for me because this behavior will be attached to more than 
> one sprite 
> >(and the purpose of using a behavior would be lost if I need to 
> >hardcode object references)... The error message complains about the 
> >#hitTest which to me sounds like it does not recognize the 
> sprite as a 
> >flash sprite.
> >
> >Anyone? Suggestions?
> >
> >//Kristian
> >
> >
> >-- PART OF MOVIE SCRIPT CODE
> >puppetSprite 2, TRUE
> >sprite(2).member = puppetName
> >sprite(2).width = 220
> >sprite(2).height = 491
> >sprite(2).locH = 5
> >sprite(2).locV = 76
> >if member(puppetName).loaded = TRUE then
> >     flaSetActiveSubItem(gAMemList.aSubMain,gAMemList.aSubSub,
> >AMemList.aCastPage)
> >end if
> >xCursor = (script "flaCursorScript").new(2)
> >sprite(2).scriptInstanceList.Add(xCursor)
> >
> >
> >-- BEHAVIOR CODE
> >property spriteNum, pSpriteRef
> >
> >on beginSprite me
> >     pSpriteRef = me.spriteNum
> >end
> >
> >on exitframe me
> >     if sprite(pSpriteRef).hitTest(the mouseLoc) = #button then
> >             if sprite(pSpriteRef).cursor <> 280 then
> >                     sprite(pSpriteRef).cursor = 280
> >             end if
> >     else
> >             if sprite(pSpriteRef).cursor <> -1 then
> >                     sprite(pSpriteRef).cursor = -1
> >             end if
> >     end if
> >end
> >
> >
> >[To remove yourself from this list, or to change to digest 
> mode, go to 
> >http://www.penworks.com/lingo-l.cgi  To post messages to the list, 
> >email [EMAIL PROTECTED]  (Problems, email 
> [EMAIL PROTECTED]). 
> >Lingo-L is for learning and helping with programming Lingo.  Thanks!]
> >
> >  
> >
> 
> -- 
> 
> 
> 
> _  _  _  _  _  _  _  _  _  _  _ _  _  _  _  _  _  _  _  _  _  
> _  _  _  _
> 
> 
> *m u t a n t
>              m e d i a*      >     /solutions for success
> //
> //
> / *Evan Adelman* | 917.916.7378 | 303 E 71st St  NY NY 10021 
> [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> | 
> www.mutantmedia.com 
> <http://www.mutantmedia.com>
> 
> 
> 
> [To 
> remove yourself from 
> this list, or to change to digest mode, go to 
> http://www.penworks.com/lingo-l.cgi  To post > messages to the 
> list, email [EMAIL PROTECTED]  (Problems, email 
> [EMAIL PROTECTED]). Lingo-L is for learning and 
> helping with programming Lingo.  Thanks!]
> 


[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email [EMAIL 
PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping 
with programming Lingo.  Thanks!]

Reply via email to