|
From: Bob220867 on 9 Apr 2008 04:16 I've created a new sprite with imaging lingo - making a copy, setting it to a member and then applying to a new sprite. Now I'd like to apply a script from the cast to it. How can I do this? Many thanks
From: The Minds Eye on 9 Apr 2008 07:27 p_sprite = sprite(1) --(or whatever) p_sprite.scriptInstanceList.add(script("my script"))
From: Bob220867 on 9 Apr 2008 10:15 Thanks for this I had something similar-ish based on Director's documentation - all the right words but in a different order. When I try though, it still doesn't respond. (For the moment the added script is just a simple mouseDown alert for testing.) Is there something I'm asking it to do that isn't allowed? The script 'dynPieceScript' is just sitting in the cast. Here's the code: on createPiece me -- iterate i that is method of naming sprites i=i+1 -- set up ref point for new piece origLoc=my.loc -- make a copy of the play piece stageImage=(the stage).image spriteimage=stageImage.crop(my.rect) pMember=_movie.newMember(#Bitmap) -- name the member, set pMember to it's image, -- find an available channel, assign it to a sprite in place pMember.name="NewPiece"&&i pMember.image=spriteImage myChannelNum=_movie.lastChannel-i myNewSprite=channel(myChannelNum).makeScriptedSprite(member(pMember.name), origLoc) -- myNewSprite.name=my.member.name&&i myNewSprite.moveableSprite=TRUE myNewSprite.scriptInstanceList.add(script ("dynPieceScript")) end createPiece me Everything else works the way I expect it to - the moveable is fine etc. Any ideas? One other thing, there's a commented out attempt to name the newly created sprite but I get a No Access script error. Does that mean I can't name a sprite created like this? Many thanks
From: CenturyMan1979 on 9 Apr 2008 14:54 Just one quick thing I noticed in your make scripted sprite call, you can just use pMember for the member item in it like so, myNewSprite = channel(myChannelNum).makeScriptedSprite(pMember, origLoc) Also I am not sure what your reference to "my" is in your scripts but should probably be removed from what I can see. This might also explain why you get an error when trying to set the sprite name. So for that line try this instead, myNewSprite.name=pMember.name&&i Not sure that is the exact output you want since I am not sure what your reference to "my" is. Is your script dynPieceScript a behavior script or a parent script?
From: Mike Blaustein on 9 Apr 2008 15:06
You can not name a scripted sprite. It is annoying, and I do not understand why this basic thing was not implemented, but it wasn't. You have access to every sprite property except name. |