Skip to main content
Rodrigo_Girona
Participating Frequently
November 14, 2020
Question

Change scaleX to many movieClip (Animate CC)

  • November 14, 2020
  • 1 reply
  • 552 views

Hi all!!!

 

I have more than 15 movieClips on stage with instance name icon1, icon2, icon3 ..... and I need to change their scaleX and scaleY from a variable in

 

function onMouseMove (evt) {
var sizeIconXY = (scaleNumerica / 10000)
this.map.icon1.scaleX = sizeIconXY // statement 1
this.map.icon1.scaleY = sizeIconXY // statement 2
}

 

Is it possible to have a function that unifies the scaleX / scaleY (sentence 1 and 2) and not have to repeat the sentence in all 15 (icon1, icon2, icon3 ...), is it possible?

I was looking with:
document.getElementById ("icon *")
but I can't solve it.

From already thank you very much.

    This topic has been closed for replies.

    1 reply

    Vladin M. Mitov
    Inspiring
    November 14, 2020

    Hi,

    Yes, it is posiible 🙂
    Could you specify a little bit what you try to achieve?
    What kind of scripting you use: JSFL (authoring mode), AS or JS?

    A basic advice: you can store all your references in array during creation and later you can itarate through this collection:

    var iconCollection = [];
    
    /* 
    	You need to add all references, e.g. icon1, icon2, icon3 ...
    	to iconCollection array in order to manipulate them with a loop
    
    */
    function onMouseMove (evt) {
    
    	var sizeIconXY = (scaleNumerica / 10000);
    	
    	for( var i = 0; i < iconCollection.length; i++ ){
    		
    		var theIcon = iconCollection[ i ];
    		theIcon.scaleX = sizeIconXY; // statement 1
    		theIcon.scaleY = sizeIconXY; // statement 2		
    		
    	}
    
    }

     

     

    - Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
    Rodrigo_Girona
    Participating Frequently
    November 16, 2020

    Thanks for your answer!!!

     

    When adding and removing movieClips from the stage, the ideal is to detect the instance of the movieClips that start with "icon" and all change the scaleX / scaleY, it is possible with:

     

    document.getElementById ("icon *") 

     

    thanks

    Legend
    November 16, 2020

    Animate HTML5 Canvas objects are not browser DOM objects. Canvas projects use the CreateJS library for everything. There is no such thing as getElementById() in CreateJS.

     

    To find every clip on the stage with a name that starts with "icon", you'd have to do something like this:

    var i, clip;
    for (i = 0; i < this.numChildren; i++) {
    	clip = this.children[i];
    	if (clip.name.indexOf("icon") === 0) {
    		console.log(clip.name);
    	}
    }