Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

attachMovie & depths

Participant ,
Jul 05, 2013 Jul 05, 2013

I wanbt to be able to create buttons inside dNumHolder_mc everytime loadVars return its value (Each time the number of buttons varie). I used removeMovieClip() to remove the current buttons and tried to recreate the next set of buttons. I believe the issue is due to the depths. But with my code the buttons are created once only. How can recreate buttons eachtime btnsRceLoad receives data?

btnsRceLoad.onData = function(src) {

          _root.uusersNow.text = "Total Pages: " + src;

          for(var i:Number=0; i<src; i++){

                    _root.dNumHolder_mc.attachMovie("btnNum","numberBtn"+i,_root.dNumHolder_mc.getNextHighestDepth());

                    _root.dNumHolder_mc["numberBtn"+i]._x = xNumPosition;

                    _root.dNumHolder_mc["numberBtn"+i]._y = yNumPosition;

                    _root.dNumHolder_mc.attachMovie("txtNum","textBtn"+i,_root.dNumHolder_mc.getNextHighestDepth());

                    _root.dNumHolder_mc["textBtn"+i]._x = xNumPosition;

                    _root.dNumHolder_mc["textBtn"+i]._y = yNumPosition;

                    _root.dNumHolder_mc["textBtn"+i].theNum.text = BtnNumz;

                    xNumPosition = xNumPosition + 24.1;

                    BtnNumz = (BtnNumz + 1);

          }

TOPICS
ActionScript
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2013 Jul 05, 2013

i don't see where you're removing anything.  but you should use different names and depths:

btnsRceLoad.onData = function(src) {

          _root.uusersNow.text = "Total Pages: " + src;

          for(var i:Number=0; i<src; i++){

                    var mc:MovieClip=_root.dNumHolder_mc.attachMovie("btnNum","numberBtn"+_root.dNumHolder_mc.getNextHighestDepth(),_roo t.dNumHolder_mc.getNextHighestDepth());

                   mc._x = xNumPosition; // assuming this is initialized

                   mc._y = yNumPosition;  // "   "

                    var mc1:MovieClip=_root.dNumHolder_mc.attachMovie("txtNum","textBtn"+_root.dNumHolder_mc.getNextHighestDepth(),_root. dNumHolder_mc.getNextHighestDepth());

                   mc1._x = xNumPosition;

                   mc1._y = yNumPosition;

                   mc1.theNum.text = BtnNumz;  // assuming this is initialized

                    xNumPosition = xNumPosition + 24.1;

                    BtnNumz = (BtnNumz + 1);

          }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 05, 2013 Jul 05, 2013

Thanks Kglad.

I tried your code and it does the same.

Does var mc:MovieClip need to be a new name eachtime btnsRceLoad is called? But how?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2013 Jul 05, 2013

yes.

what do you see that makes you think the code is not working?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 05, 2013 Jul 05, 2013

I did the below. But no luck.

var sparkle:Array = [];

var n:Number = 16;

for (var j:Number = 0; j < n; j++) {

var mc:MovieClip = MovieClip(getChildByName("s"+j) );

sparkle = mc;

}

btnsRceLoad.onData = function(src) {

          _root.uusersNow.text = "Total PagesS: " + src;

           for(var i:Number=0; i<src; i++){

                     sparkle=_root.dNumHolder_mc.attachMovie("btnNum","numberBtn"+_root.dNumHolder_mc.getNextHighestDepth(),_root.dNumHolder_mc.getNextHighestDepth());

                     sparkle._x = xNumPosition;

                    sparkle._y = yNumPosition; 

                     sparkle=_root.dNumHolder_mc.attachMovie("txtNum","textBtn"+_root.dNumHolder_mc.getNextHighestDepth(),_root.dNumHolder_mc.getNextHighestDepth());

                     sparkle._x = xNumPosition;

                     sparkle._y = yNumPosition;

                     sparkle.theNum.text = BtnNumz; 

                     xNumPosition = xNumPosition + 24.1;

                     BtnNumz = (BtnNumz + 1);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2013 Jul 05, 2013

that code makes no sense.  it looks like some as2 and some as3 and none of the as3 would do anything useful.

copy and paste the trace output from the following:

for(var src:Number=5;src<11;src+=5){

testF(src)

}

function testF(src) {

          _root.uusersNow.text = "Total Pages: " + src;

          for(var i:Number=0; i<src; i++){

                    var mc:MovieClip=_root.dNumHolder_mc.attachMovie("btnNum","numberBtn"+_root.dNumHolder_mc.getNextHighestDepth(),_roo t.dNumHolder_mc.getNextHighestDepth());

                   mc._x = xNumPosition; // assuming this is initialized

                   mc._y = yNumPosition;  // "   "

trace(src+": "+mc+"_x: "+mc._x+" depth: "+mc.getDepth());

                    var mc1:MovieClip=_root.dNumHolder_mc.attachMovie("txtNum","textBtn"+_root.dNumHolder_mc.getNextHighestDepth(),_root. dNumHolder_mc.getNextHighestDepth());

                   mc1._x = xNumPosition;

                   mc1._y = yNumPosition;

                   mc1.theNum.text = BtnNumz;  // assuming this is initialized

                    xNumPosition = xNumPosition + 24.1;

                    BtnNumz = (BtnNumz + 1);

          }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 05, 2013 Jul 05, 2013

trace:

10: _level0.dNumHolder_mc.numberBtn28_x: 337.4 depth: 28

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2013 Jul 05, 2013

you fail to see 15 lines of trace output???

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 07, 2013 Jul 07, 2013

Sorry about that Kglad.

5: _level0.dNumHolder_mc.numberBtn0_x: 0 depth: 0

5: _level0.dNumHolder_mc.numberBtn2_x: 24.1 depth: 2

5: _level0.dNumHolder_mc.numberBtn4_x: 48.2 depth: 4

5: _level0.dNumHolder_mc.numberBtn6_x: 72.3 depth: 6

5: _level0.dNumHolder_mc.numberBtn8_x: 96.4 depth: 8

10: _level0.dNumHolder_mc.numberBtn10_x: 120.5 depth: 10

10: _level0.dNumHolder_mc.numberBtn12_x: 144.6 depth: 12

10: _level0.dNumHolder_mc.numberBtn14_x: 168.7 depth: 14

10: _level0.dNumHolder_mc.numberBtn16_x: 192.75 depth: 16

10: _level0.dNumHolder_mc.numberBtn18_x: 216.9 depth: 18

10: _level0.dNumHolder_mc.numberBtn20_x: 240.95 depth: 20

10: _level0.dNumHolder_mc.numberBtn22_x: 265.05 depth: 22

10: _level0.dNumHolder_mc.numberBtn24_x: 289.2 depth: 24

10: _level0.dNumHolder_mc.numberBtn26_x: 313.3 depth: 26

10: _level0.dNumHolder_mc.numberBtn28_x: 337.4 depth: 28

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2013 Jul 07, 2013

and do you see 15 movieclips attached to _level0.dNumHolder_mc?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 08, 2013 Jul 08, 2013

yes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 08, 2013 Jul 08, 2013

Oops!! I know what's wrong...

I've forgotten to reset x,y to zero!!!!!

Anyway Thanks Kglad!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2013 Jul 08, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines