AS3 Movieclip Reset?

  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

I have recently came into the need for a movie clip reset function in a as3 project I'm doing not sure if there is something like that out there or not I have searched around for a bit and haven't found anything to fit my needs. I can write something that can do what i need but i would like to try and find something native first.

Here is the situation ... I loaded a movieclip with the loader class and within the movieclip I loaded i changed the scale of some of the objects with Action script. Now i what to reset the items i changed back to what they were when it was first loaded.

So to recap loaded movieclip, changed movie clip objects, want to return movieclip objects back to first load state.

Again I can write a function to do this. I just want to know if there is any native functions already out there that can do this.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Through some trials I think I'll figure out a another way. I have written a function to reset the movie clip however it seems to stop all interaction that happens to be within the SWF file itself. This code may not work for me just yet but may be helpful for someone trying to do the something similar.

This block of code will get the movieclip object, x, y positions, height, width and the Instance names for a movieclip and all nested movieclips within the original movieclip
ACTIONSCRIPT Code: [ Select ]
 
// Import the required classes
import flash.display.DisplayObject;
 
// Array - This will hold the position and scale info for the movieclip
var movieclip_info:Array = new Array();        
 
// This function will read and get all position and scale info of the skin
function read_movieclip(movie_clip) {
   
   // Loop through the children
   for(var i:int = 0; i < movie_clip.numChildren; i++) {
     
      // Make sure we are working with a movieclip
      if(movie_clip.getChildAt(i) is MovieClip) {
         
         // Make an object to hold our info
         var temp_object:Object = new Object();
         
         // Set the info
         temp_object.movie    = movie_clip.getChildAt(i);
         temp_object.height   = movie_clip.getChildAt(i).height;
         temp_object.width    = movie_clip.getChildAt(i).width;
         temp_object.x     = movie_clip.getChildAt(i).x;
         temp_object.y     = movie_clip.getChildAt(i).y;
         temp_object.name  = movie_clip.getChildAt(i).name;
         
         // Add to the movieclip info array
         movieclip_info.push(temp_object);
           
         // Check for nested movieclips
         read_skin(movie_clip.getChildAt(i));
         
      }
     
   }
   
}
 
// NOTE: I ADDED THIS JUST TO SHOW SOME RESULTS. I was using it to try to reset the movie clip but was having some weirdness going on.
function trace_info() {
   
   // Loop through the array
   for each(var mc:Object in movieclip_info) {
     
      // Do something here
      trace('Movieclip = ' + mc.movie + '\nInstance Name = ' + mc.name + '\nHeight = ' + mc.height + '\nWidth = ' + mc.width + '\nXpos = ' + mc.x + '\nXpos = ' + mc.y + '\n\n');
     
   }
   
}
 
  1.  
  2. // Import the required classes
  3. import flash.display.DisplayObject;
  4.  
  5. // Array - This will hold the position and scale info for the movieclip
  6. var movieclip_info:Array = new Array();        
  7.  
  8. // This function will read and get all position and scale info of the skin
  9. function read_movieclip(movie_clip) {
  10.    
  11.    // Loop through the children
  12.    for(var i:int = 0; i < movie_clip.numChildren; i++) {
  13.      
  14.       // Make sure we are working with a movieclip
  15.       if(movie_clip.getChildAt(i) is MovieClip) {
  16.          
  17.          // Make an object to hold our info
  18.          var temp_object:Object = new Object();
  19.          
  20.          // Set the info
  21.          temp_object.movie    = movie_clip.getChildAt(i);
  22.          temp_object.height   = movie_clip.getChildAt(i).height;
  23.          temp_object.width    = movie_clip.getChildAt(i).width;
  24.          temp_object.x     = movie_clip.getChildAt(i).x;
  25.          temp_object.y     = movie_clip.getChildAt(i).y;
  26.          temp_object.name  = movie_clip.getChildAt(i).name;
  27.          
  28.          // Add to the movieclip info array
  29.          movieclip_info.push(temp_object);
  30.            
  31.          // Check for nested movieclips
  32.          read_skin(movie_clip.getChildAt(i));
  33.          
  34.       }
  35.      
  36.    }
  37.    
  38. }
  39.  
  40. // NOTE: I ADDED THIS JUST TO SHOW SOME RESULTS. I was using it to try to reset the movie clip but was having some weirdness going on.
  41. function trace_info() {
  42.    
  43.    // Loop through the array
  44.    for each(var mc:Object in movieclip_info) {
  45.      
  46.       // Do something here
  47.       trace('Movieclip = ' + mc.movie + '\nInstance Name = ' + mc.name + '\nHeight = ' + mc.height + '\nWidth = ' + mc.width + '\nXpos = ' + mc.x + '\nXpos = ' + mc.y + '\n\n');
  48.      
  49.    }
  50.    
  51. }
  52.  


If this helps anyone that's great, use it :). I'll mess around with it for a bit but if it doesn't seem like it will work for me I will be moving on to different ideas.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 14 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.