ActiveDen

as3 to as2 conversion problem

4709 posts
  • Exclusive Author
  • Author had a File in an Envato Bundle
  • Elite Author
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • India
+4 more
VF says

plictis, you need to add the clips into the holder_mc, right? in such case, hers is the working example:


//Your linkage IDs goes here:
var myArray:Array = ["1mc","2mc"];

//This loop populates and positions the clips:
for (var i:Number = 0; i<myArray.length; i++) {
    holder_mc.attachMovie(myArray[i], "mc"+i, i);
    if (i>0) {
        holder_mc["mc"+i]._x = holder_mc["mc"+(i-1)]._x+holder_mc["mc"+(i-1)]._width+40;
    }
}

You can use EnterFrame loop instead of “for loop” in case needed. But only if the library symbol’s dimension expected to change after attaching.

6 posts
  • Bought between 1 and 9 items
  • Europe
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
plictis says

thanks pez, but this code duplicates the mc’s, first time on stage and then in the holder. i only need to add the mc’s once.


var mc1 = _root.attachMovie("1mc", "mc1", 0);
var mc1 = _root.attachMovie("2mc", "mc2", 1);
mc2._x = mc1._x + mc1._width;

var myArray:Array = new Array();
myArray.push(mc1);
myArray.push(mc2);

for (var i:Number = 0; i<=myArray.length; i++) {
 holder_mc.attachMovie(i+"mc", "mc"+i, i, {_x:i*40});
}

6 posts
  • Bought between 1 and 9 items
  • Europe
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
plictis says

Thanks VF, it seems that this is the right answer. working just fine. and it’s so simple. thanks again. have a perfect day!


plictis, you need to add the clips into the holder_mc, right? in such case, hers is the working example:

//Your linkage IDs goes here:
var myArray:Array = ["1mc","2mc"];

//This loop populates and positions the clips:
for (var i:Number = 0; i<myArray.length; i++) {
    holder_mc.attachMovie(myArray[i], "mc"+i, i);
    if (i>0) {
        holder_mc["mc"+i]._x = holder_mc["mc"+(i-1)]._x+holder_mc["mc"+(i-1)]._width+40;
    }
}
You can use EnterFrame loop instead of “for loop” in case needed. But only if the library symbol’s dimension expected to change after attaching.
6 posts
  • Bought between 1 and 9 items
  • Europe
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
plictis says

So a huge thanks to all of those who helped me or just tried helping. i’m really grateful. now i know the usage of adding an array to an mc, and where to use enterFrame event. i tought the “for” cycle can only work inside of a function. anyway THANKS and many many sales to you guys!

3593 posts
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Exclusive Author
  • Beta Tester
  • Has been a member for 3-4 years
  • Spain
+3 more
pezflash says

thanks pez, but this code duplicates the mc’s, first time on stage and then in the holder. i only need to add the mc’s once.

Well, its the way you had it, so i just kept it! :P
Nice you got it running.

3409 posts
  • Has been a member for 4-5 years
  • Contributed a Tutorial to a Tuts+ Site
  • Netherlands
  • Community Moderator
  • Microlancer Beta Tester
  • Sold between 10 000 and 50 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
+4 more
Joost moderator says

Hello everybody, so here’s the story: the freelance wasn’t going well lately so i had to get a job
I follow..

a company recruited me, but instead of an interview they gave me a little test.
Always a great way to test someone’s skill!

the test is converting a stupid game
A dull task, but I guess it should suffice..

from as3 to as2.
Sorry.. what?! :shocked:

there are 3 years since I’ve stopped working with as2
And so should they! What nonsense converting a game back to AS2 . Why would anyone want to do that? I guess it’s understandable that people still like AS2 and have projects written in it that their stuff needs to work together with, but.. This is just being contra-innovative. :P I hope the projects you’ll be doing for them will just allow you to work with what you’ve worked with for the past 3 years – recent technology ;)

EDIT : I guess I took ages to make that point. This post seemed a lot better in my mind.. ;)

6 posts
  • Bought between 1 and 9 items
  • Europe
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
plictis says

Ha ha. I was surprised too when i received the test with as2 conversion. A friend of mine, part of Plictis team, also works there and he told me that they are using as2 because they are creating flip-books and as2 it’s the only one compatible with the flip-book program they are using. But hey, for my country it’s well paid job. PS: i still didn’t finish the test, the as2 convention are driving me nuts. 2 hour sleep and 3 cigarette packs. i still have 8 hours, let’s be positive. NOT !!!!

1389 posts
  • Beta Tester
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 4-5 years
  • Microlancer Beta Tester
  • Referred between 10 and 49 users
+3 more
Pdesignx says

i think you totally forgot about as2 :D or you just learnt as3.

because you were trying to add movieclip to the stage first, then into holder_mc, you can do it with addChild and removeChild in as3 and move same movieclip from root to holder_mc…

but in as2 when you attach a movieclip into root or somewhere, you can’t move it into another movieclp, you need to remove it and attach another one in to the desired one…

so instead of adding it to root and than removing it from root and adding it into holder_mc again, you should directly put it into holder_mc which VF made already…

i am suprised, just he could reply this :D

and hope that agency does not see this post of yours (:

688 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Interviewed on the Envato Notes blog
  • Lebanon
  • Sold between 5 000 and 10 000 dollars
SimplyDo says

i think you totally forgot about as2 :D or you just learnt as3.

because you were trying to add movieclip to the stage first, then into holder_mc, you can do it with addChild and removeChild in as3 and move same movieclip from root to holder_mc…

but in as2 when you attach a movieclip into root or somewhere, you can’t move it into another movieclp, you need to remove it and attach another one in to the desired one…

so instead of adding it to root and than removing it from root and adding it into holder_mc again, you should directly put it into holder_mc which VF made already…

i am suprised, just he could reply this :D

and hope that agency does not see this post of yours (:

+1 we are helping you cheat

4709 posts
  • Exclusive Author
  • Author had a File in an Envato Bundle
  • Elite Author
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • India
+4 more
VF says

and hope that agency does not see this post of yours (:

haha, +1

I think companies would be pleased to see quick learners (with their own efforts) rather depending those who believes “I already know” and without quick learning habits.

by
by
by
by
by