Posted By

adamcoulombe on 05/07/10


Tagged

actionscript dynamic properties


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

adrianparr
socialflasher
tspitzr


AS3 Properties Method


 / Published in: ActionScript 3
 

This method allows you to pass an object to a movieclip to quickly apply properties rather than tediously typing out each line.

  1. MovieClip.prototype.properties = function(properties) {
  2. for(var key:String in properties){
  3. this[key] = properties[key];
  4. }
  5. }
  6.  
  7. //the normal way
  8.  
  9. myMovieClip.x = 100;
  10. myMovieClip.y = 100;
  11. myMovieClip.width = 100;
  12. myMovieClip.height = 100;
  13.  
  14. //using MovieClip.prototype.properties
  15.  
  16. myMovieClip.properties({x:100,y:100,width:100,height:100});

Report this snippet  

You need to login to post a comment.