Login
...or Sign up
Home
Search
Search Code Snippets
Search People
Code Snippets of
tpr
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed); function keyPressed (event:KeyboardEvent):void { switch (event.keyCode) { case Keyboard.RIGHT : blue_mc.x +=5 break; case Keyboard.UP : blue_mc.y -=5 break; case Keyboard.DOWN : blue_mc.y +=5 break; case Keyboard.LEFT : blue_mc.x -=5 break; default : break; } // test collision if(blue_mc.hitTestObject(green_mc)) { green_mc.alpha = 0.5; trace("green circle was hit!"); } else { green_mc.alpha = 1; } }
AS3 - Switch and collision
Uploaded on
11/22/2009 1:38:16 PM
0 comments
Programming Language:
ActionScript
collision
loop
switch
package { import flash.display.MovieClip; public class DragDrop extends MovieClip { public function DragDrop() { trace("drag drop class working!"); } } }
AS3 - Extend class
Uploaded on
11/22/2009 7:00:50 AM
0 comments
Programming Language:
ActionScript
class
function removeMail(event:MouseEvent):void { while(mail_mc.numChildren > 0) { mail_mc.removeChild(mail_mc.getChildAt(mail_mc.numChildren - 1)); } } remove_btn.addEventListener(MouseEvent.CLICK, removeMail);
AS3 - while loop
Uploaded on
11/22/2009 5:54:46 AM
0 comments
Programming Language:
ActionScript
loop
while
for(var i:uint = 0; i < 5000; i++) { trace(i); } --------------------------------- var colors:Array = new Array (red_mc, blue_mc, yellow_mc); for (var i:uint = 0; i < colors.length; i++) { colors[i].addEventListener(MouseEvent.CLICK, captureAllClicks); } function captureAllClicks (event:MouseEvent):void { trace(colors.indexOf(event.target)); } --------------------------------- var mail:Array = [mail1_mc,junk1_mc,mail2_mc,junk2_mc,mail3_mc,junk3_mc,mail4_mc,junk4_mc,mail5_mc,junk5_mc,mail6_mc,junk6_mc,mail7_mc,junk7_mc,mail8_mc,junk8_mc]; function sortMail(event:MouseEvent):void { var instanceName:String; for(var i:uint = 0; i < mail.length; i++) { instanceName = mail[i].name; if(instanceName.indexOf("junk") != -1) { mail[i].x = 170; mail[i].y = 300; } else { mail[i].x = 520; mail[i].y = 250; } } } sort_btn.addEventListener(MouseEvent.CLICK, sortMail);
AS3 - Loops
Uploaded on
11/22/2009 5:53:23 AM
0 comments
Programming Language:
ActionScript
for
loop
var colors:Array = new Array (red_mc, blue_mc, yellow_mc); stage.addEventListener(MouseEvent.CLICK, captureAllClicks); /*red_mc.addEventListener(MouseEvent.CLICK, captureAllClicks); blue_mc.addEventListener(MouseEvent.CLICK, captureAllClicks); yellow_mc.addEventListener(MouseEvent.CLICK, captureAllClicks);*/ /*function captureAllClicks (event:MouseEvent):void { trace(event.target.name); }*/ function captureAllClicks (event:MouseEvent):void { trace(colors.indexOf(event.target)); }
AS3 - Finding array indexes
Uploaded on
11/22/2009 5:45:58 AM
0 comments
Programming Language:
ActionScript
array
index
1
2
3
4
Help
Help by email
What is Naslu?
|
About Naslu
|
Contact
|
Terms of Use
|
Downloads
|
Webprogramacion.com
|
Blog
|
Top
Links
Select language:
Español
|
English
© 2009 naslu.com