-
[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 i = _root.getNextHighestDepth(); _root.attachMovie("Arrow_mc", "Arrow_mc"+i, i, {_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 = [aa, bb]; 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 = [aa, bb]; for (var i:Number = 0; i<=a.length-1; i++) { 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.
-
.
Hi,
PHP Code:
var a:Array = [aa, bb]; for (var i:Number = 0; i < a.length; i++) { var mcArrow:MovieClip = MovieClip(a[i]); mcArrow.onPress = function() { trace(this._name); }; }
-
Originally Posted by fruitbeard
Hi,
PHP Code:
var a:Array = [aa, bb]; for (var i:Number = 0; i < a.length; i++) { 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|