-
attachmovie script
HI,
i'm really a newbie in AS2 and here is what i would like.
I have a MC in my library that is named brick. I want it that when i press "space bar", the MC "brick" is loaded into my main scene.
I know i have to use the attachmovie command and a kind of "linkage" but whatever i try with code and these 2, it just doesn't do anything.
Any idea what kind of coding i should use and must i add it to the timeline or the MC?
thanks a lot for your help
seb
-
.
Hi,
This should get you started
PHP Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function()
{
if (Key.getCode() == 32)
{
_root.attachMovie("brick","brick",5);
trace("Attached");
key.removeListener(keyListener);
}
};
Key.addListener(keyListener);
-
Designer, Programmer, Musician
Hello there,
if you want the clip being placed "once" and not creating more instances of it in the stage, use this script:
PHP Code:
var KeysListener:Object = new Object(); KeysListener.onKeyDown = function() { if(Key.isDown(Key.SPACE)) { if(!_root.brick) { _root.attachMovie("brick", "brick", _root.getNextHighestDepth()); } } } Key.addListener(KeysListener);
Otherwise:
PHP Code:
var KeysListener:Object = new Object(); KeysListener.onKeyDown = function() { if(Key.isDown(Key.SPACE)) { _root.attachMovie("brick", "brick", _root.getNextHighestDepth()); } } Key.addListener(KeysListener);
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|