|
Prev: Text field user input
Next: rollover cursor change
From: w_danilo on 10 Apr 2008 11:44 Hi, I'm new to Director, so this question could be very simple, but i can't find the answer in internet. I very like Flash and ActionScript and now i've started to learn Director. When I create a Sprite in a Cast- how can I (with JavaScript) copy this Sprite to the Stage as a new object with a new name? And the second question - Do you know any good sites, where are good articles, tutorials, examples, connected with scripting in Director? Than you very much :):)
From: Mike Blaustein on 10 Apr 2008 11:59 One thing here is that any items in the Cast are Members, not Sprites. Sprites do not exist in the Cast. The Cast is like Flash's Library. Sprites exist on the Stage or in the Score. The standard (non scripting) way to take a member and make a sprite on stage is to drag it there. If you want to script it, you have 2 options: 1) puppetSprite 2) makeScriptedSprite The 2nd option gives more control over the sprite. Check out the help file for syntax and examples
From: w_danilo on 10 Apr 2008 12:27 Thank you! Could you answer one more question? When i create sprite like this: newsp1=channel(5).makeScriptedSprite(member("p1"), point(35, 70)); I don't see it on the stage. How could I add it to this Stage (like addChild in AS3). And The last one: When i make this new Sprite, put it on the Stage, how can I write to it dynamically function, that it (f.e.) should move in every frame about 1px right? (Can I write aaa.enterFrame=function (){...} ?) Thank you really very much :)
From: Mike Blaustein on 10 Apr 2008 12:37 I don't use Javascript syntax, so you will have to translate some of it, but here is how to do it in Lingo: You should see the sprite appear when you run that command, as long as the member you are using exists. You can add a script to the sprite by using the scriptInstanceList. If you have a parent script named "dynamicScript", then you would do something like this: newsp1=channel(5).makeScriptedSprite(member("p1"), point(35, 70)) newspl.scriptInstanceList.add(script("dynamicScript").new()) // add is the lingo method to add something to a list. You may need to adjust that to the JS version...push I think... --THIS IS THE PARENT SCRIPT NAMED DYNAMICSCRIPT IN LINGO-- on new me return me end on enterFrame --do something end --END OF DYNAMICSCRIPT
From: w_danilo on 10 Apr 2008 15:09
Thank you :) I have unfortunately something wrong translated, because I've got no errors, but nothing happens. The script on the 1st Timeline frmae is: function exitFrame(me) { aaa=channel(5).makeScriptedSprite(member("p1"), point(0,1)); aaa.locV=100; trace("t1") //this is traced aaa.scriptInstanceList.push(new script("dynamicScript")); trace("t2") //this is not traced } on the second frame: function exitFrame(me) { _movie.go(2); } and in the cast (name of this script is "dynamicScript"): function enterFrame() { trace("dsd"); } I'm really thankful to you :):smile;:beer; |