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

I want to get property of previous object from array

New Here ,
Aug 07, 2015 Aug 07, 2015

Hi

Here is my code

for(var i in MovieClip(root).arrySpt){

  var btn:MovieClip = MovieClip(box);

  //duplicate the movielcip (add a new one to the stage)

  var ClassDefinition:Class = Class(getDefinitionByName(getQualifiedClassName(btn)));

  var myMC:MovieClip = new ClassDefinition;

  myMC.inBin.text = MovieClip(root).arrySpt;

  trace(getChildByName("myMCC"+i as String).width);

  myMC.x = i * myMC.width;

  myMC.y = 0;

  myMC.velocityY = 0;

  box.addChild(myMC);

  box.boxin.visible = false;

}

  var myMC:MovieClip = new ClassDefinition;

     Here movieclips are creating and this line of code is assigning the position

myMC.x = i * myMC.width;


Here the width is assigning to X position of current object but I want assign width as X position to next object not current object. Mean If movieclip generate it should get width from previous movieclip from array.


please help me to solve this problem.


thanks

TOPICS
ActionScript
234
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

correct answers 1 Correct answer

Community Expert , Aug 07, 2015 Aug 07, 2015
use:

var prevX:int= 0 ;

for(var i in MovieClip(root).arrySpt){

  var btn:MovieClip = MovieClip(box);

  //duplicate the movielcip (add a new one to the stage)

  var ClassDefinition:Class = Class(getDefinitionByName(getQualifiedClassName(btn)));

  var myMC:MovieClip = new ClassDefinition;

  myMC.inBin.text = MovieClip(root).arrySpt;

  trace(getChildByName("myMCC"+i as String).width);

  myMC.x = prevX;

prevX+=myMC.width;

  myMC.y = 0;

  myMC.velocityY = 0;

  box.addChild(myMC);

  box.boxin.visible

...
Translate
Community Expert ,
Aug 07, 2015 Aug 07, 2015
use:

var prevX:int= 0 ;

for(var i in MovieClip(root).arrySpt){

  var btn:MovieClip = MovieClip(box);

  //duplicate the movielcip (add a new one to the stage)

  var ClassDefinition:Class = Class(getDefinitionByName(getQualifiedClassName(btn)));

  var myMC:MovieClip = new ClassDefinition;

  myMC.inBin.text = MovieClip(root).arrySpt;

  trace(getChildByName("myMCC"+i as String).width);

  myMC.x = prevX;

prevX+=myMC.width;

  myMC.y = 0;

  myMC.velocityY = 0;

  box.addChild(myMC);

  box.boxin.visible = false;

}

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
New Here ,
Aug 07, 2015 Aug 07, 2015

Thanks Kglad its working as i want. thank you so much for this help.

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 ,
Aug 07, 2015 Aug 07, 2015
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