dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Linking several mcs to a single mc instance.

  1. #1
    Member
    Join Date
    Sep 2014
    Posts
    77

    resolved [RESOLVED] Linking several mcs to a single mc instance.

    Hello All,

    Reference is made to the original thread in the link below:

    http://board.flashkit.com/board/show...ith-mouse-drag

    PHP Code:
    on (press) {
    var 
    _root.getNextHighestDepth();
    _root.attachMovie("Arrow_mc""Arrow_mc"+ii, {_x:100_y:100});
    var 
    mcArrow:MovieClip MovieClip(eval("Arrow_mc"+i));

    This code worked well. It is about linking the instance name of the attached mcs to a single instance name "mcArrow". So that code written to "mcArrow" can be applied to all the attached mcs.

    Now, trying to reuse the same code buy in frame 1 on stage.

    PHP Code:
    var a:Array = [aabb];
    var 
    mcArrow:MovieClip MovieClip(a[0]);
    var 
    mcArrow:MovieClip MovieClip(a[1]);
    _root.mcArrow.onPress = function() {
        
    trace(this._name);
    }; 
    or like the following, by using "for" loop:

    PHP Code:
    var a:Array = [aabb];
    for (var 
    i:Number 0i<=a.length-1i++) {
        var 
    mcArrow:MovieClip MovieClip(a[i]);
    }
    _root.mcArrow.onPress = function() {
        
    trace(this._name);
    }; 

    The result was that only movie "bb" was linked, why?

    Can some one find out how to solve that, Thanks!
    Last edited by Dr_flash; 04-15-2016 at 07:06 AM.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    PHP Code:
    var a:Array = [aabb];
    for (var 
    i:Number 0a.lengthi++)
    {
        var 
    mcArrow:MovieClip MovieClip(a[i]);
        
    mcArrow.onPress = function()
        {
            
    trace(this._name);
        };


  3. #3
    Member
    Join Date
    Sep 2014
    Posts
    77
    Quote Originally Posted by fruitbeard View Post
    Hi,

    PHP Code:
    var a:Array = [aabb];
    for (var 
    i:Number 0a.lengthi++)
    {
        var 
    mcArrow:MovieClip MovieClip(a[i]);
        
    mcArrow.onPress = function()
        {
            
    trace(this._name);
        };

    Thank you fruitbeard,

    Little change/re-position of code lines , and here we are, it works.

    That was very great of you, thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center