A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Combine these into a for loop...

  1. #1
    Senior Member flipsideguy's Avatar
    Join Date
    Dec 2000
    Location
    Sweden
    Posts
    834

    Combine these into a for loop...

    Hi. I have this code that I'm trying to optimize.

    Code:
    extendTween = new TweenExtended(img01_mc.img_mc,["_x"],easingType,[img01_mc.img_mc._x],[499],0.5,true);
    extendTween = new TweenExtended(img02_mc.img_mc,["_x"],easingType,[img02_mc.img_mc._x],[499],0.5,true);
    extendTween = new TweenExtended(img03_mc.img_mc,["_x"],easingType,[img03_mc.img_mc._x],[499],0.5,true);
    I'm trying to put that all in a for loop like this:

    Code:
    for (i=0; i<10; i++){
    path = _root["img0"+i+"_mc.img_mc"];
    pathx = _root["img0"+i+"_mc.img_mc"]._x;
    extendTween = new TweenExtended(path,["_x"],easingType,[pathx],[499],0.5,true);
    }
    But it doesn't work. Any ideas?

    Thanks,

    /Flip
    Flipsideguy

  2. #2
    Member
    Join Date
    Dec 2001
    Posts
    69
    Have you tried putting in the ( ) brackets? and combine _root with img0 bit
    Your code :
    path = _root["img0"+i+"_mc.img_mc"];

    With brackets and combined path:

    path =("_root.img0"+i)+"_mc.img_mc";

  3. #3
    Re Member websam's Avatar
    Join Date
    Jul 2000
    Location
    Australia (VIC)
    Posts
    660
    try this:

    path = _root["img0"+i+"_mc"].img_mc;
    pathx = _root["img0"+i+"_mc"].img_mc._x;

    *** Because .img_mc is not part of dynamic names, cannot included into dynamic naming bracket.

    By doing this, data type for "path" is MovieClip, data type for "pathx" is Number
    Last edited by websam; 06-07-2005 at 09:32 PM.
    Challenging you: I explore my strengths;
    Being challenged: I discover my weaknesses;
    Defeating you: I GIVE you my knowledge;
    Being defeated: I GAIN your knowledge;

  4. #4
    Senior Member flipsideguy's Avatar
    Join Date
    Dec 2000
    Location
    Sweden
    Posts
    834
    Quote Originally Posted by websam
    try this:

    path = _root["img0"+i+"_mc"].img_mc;
    pathx = _root["img0"+i+"_mc"].img_mc._x;

    *** Because .img_mc is not part of dynamic names, cannot included into dynamic naming bracket.

    By doing this, data type for "path" is MovieClip, data type for "pathx" is Number
    Thanks man, that worked like a charm

    /Flip
    Flipsideguy

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Posts
    204
    [] dont work with dot syntax , but eval does

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