View Full Version : Converting AS2 to AS3!
prone
August 21st, 2009, 01:58 PM
Hello!
I am a newbie when it comes to AS3, but I'm gradually picking up things here and there. I really don't know how to convert the code below to AS3. If someone could please help me, I would greatly appreciate it! I understand that the underscores are no longer used in AS3. Thanks in advance!
numOfMask = 4;
// number of mask
numOfImage = 3;
// number of images
gap1 = 300;
// interval between one mask appearing and the next one(0.3 second)
gap2 = 3000;
// interval between the background image and the next one(3 second)
gap3 = 200;
// distance between one mask and the other
gap4 = 5000;
// looping time after all images displayed(5 second)
current = 1;
back.swapDepths(1);
front.swapDepths(3);
back.gotoAndStop(1);
front.gotoAndStop(1);
front.setMask(mask);
//
for (i=1; i<=numOfMask; i++) {
mask.attachMovie("rectMoveSet", i, i);
mask[i]._x = (gap3/2+gap3*(i-1));
}
counter = 1;
id = setInterval(mask, "aa", gap1);
//
mask.aa = function() {
for (temp in mask[counter]) {
mask[counter][temp].gotoAndPlay(2);
}
if (counter>numOfMask) {
clearInterval(id);
id = setInterval(bb, 1000);
}
counter++;
};
function bb() {
clearInterval(id);
_root.textMove.removeMovieClip();
_root.attachMovie("textMove"+current, "textMove", 4);
back.gotoAndStop(current+1);
for (temp in mask) {
mask[temp].removeMovieClip();
}
if (current == numOfImage) {
current = 1;
id = setInterval(cc, gap4);
} else {
current++;
id = setInterval(cc, gap2);
}
front.gotoAndStop(current);
}
//
function cc() {
_root.textMove.swapDepths(2);
for (i=1; i<=numOfMask; i++) {
mask.attachMovie("rectMoveSet", i, i);
mask[i]._x = (gap3/2+gap3*(i-1));
if (i%2) {
mask[i]._y = 0;
} else {
mask[i]._y = 0;
}
}
counter = 1;
clearInterval(id);
id = setInterval(mask, "aa", gap1);
}
myoreo
August 21st, 2009, 02:00 PM
check this out:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
prone
August 21st, 2009, 03:17 PM
Thanks for the migration documentation, but I still don't quite know where to begin. Actually, its deciphering the code so that I can make the conversion lies the problem.
myoreo
August 21st, 2009, 03:29 PM
well i'm too lazy to convert it all for you but this should get u started:
var _numOfMask:int = 4;
//for best practice define var and type, also add underscore or $ before name. again just for best practice and you can do the rest.
back.swapChildrenAt(1)
front.swapChildrenAt(3);
back.gotoAndStop(1);
front.gotoAndStop(1);
front.mask = mask;
//
for (var i:int=1; i<= _numOfMask; i++) {
var _rectMoveSet:RectMoveSet = new RectMoveSet();
mask.addChild(_rectMoveSet);
//mask.attachMovie("rectMoveSet", i, i);
mask[i].x = (gap3/2+gap3*(i-1));
}
//....zzzZZZZ
prone
August 21st, 2009, 04:02 PM
Thank you! I'll try to make sense out of the rest of it.
prone
August 22nd, 2009, 03:03 PM
Hello!
I tried my hand at this... and still need help trying to get this to work. Arrgguuhh!!! ;( If some could lend a hand I would be very grateful! Thanks!
prone
August 24th, 2009, 08:38 AM
I would really like to use this awesome effect in my project. Can someone please help with converting this code to AS3? Please???
prone
August 24th, 2009, 11:26 AM
Hello!
I've changed all of the code, but I'm getting this error message...
1152: A conflict exists with inherited definition flash.display:DisplayObject.mask in namespace public. Can anyone help me resolve this matter? There's a movieclip that's labeled mask. Even if I change the name of it... I get back even more errors. Do I need to change the word mask to something else altogether?
numOfMask = 4;
// number of mask
numOfImage = 3;
// number of images
gap1 = 300;
// interval between one mask appearing and the next one(0.3 second)
gap2 = 3000;
// interval between the background image and the next one(3 second)
gap3 = 200;
// distance between one mask and the other
gap4 = 5000;
// looping time after all images displayed(5 second)
//
current = 1;
back.swapChildren(1);
front.swapChildren(3);
back.gotoAndStop(1);
front.gotoAndStop(1);
front.mask = mask;
//
for (var i:int=1; i<=numOfMask; i++) {
var _rectMoveSet:RectMoveSet = new RectMoveSet();
mask.addChild(_rectMoveSet);
//mask.attachMovie("rectMoveSet", i, i);
mask[i].x = (gap3/2+gap3*(i-1));
}
counter = 1;
id = setInterval(mask, "aa", gap1);
//
mask.aa = function() {
for (temp in mask[counter]) {
mask[counter][temp].gotoAndPlay(2);
}
if (counter>numOfMask) {
clearInterval(id);
id = setInterval(bb, 1000);
}
counter++;
};
function bb() {
clearInterval(id);
root.textMove.removeMovieClip();
root.addChild("textMove"+current, "textMove", 4);
back.gotoAndStop(current+1);
for (temp in mask) {
mask[temp].removeMovieClip();
}
if (current == numOfImage) {
current = 1;
id = setInterval(cc, gap4);
} else {
current++;
id = setInterval(cc, gap2);
}
front.gotoAndStop(current);
}
//
function cc() {
root.textMove.swapChildren(2);
for (var i:int =1; i<=_numOfMask; i++) {
var _rectMoveSet:RectMoveSet = new RectMoveSet();
mask.addChild(_rectMoveSet);
mask[i].x = (gap3/2+gap3*(i-1));
if (i%2) {
mask[i].y = 0;
} else {
mask[i].y = 0;
}
}
counter = 1;
clearInterval(id);
id = setInterval(mask, "aa", gap1);
}
//
myoreo
August 24th, 2009, 11:41 AM
your displayobject (movieclip) named mask is already a built in flash function name so it conflicts and confuses flash. Just try naming it something else. _mask would do as well.
prone
August 24th, 2009, 01:28 PM
So, I changed my movieclip from mask to _mask. Now I have a boat load of errors. I even changed it in my code as well from mask to _mask and I still get all of these errors. I don't know what I need to do to get this to work.
numOfMask = 4;
// number of mask
numOfImage = 3;
// number of images
gap1 = 300;
// interval between one mask appearing and the next one(0.3 second)
gap2 = 3000;
// interval between the background image and the next one(3 second)
gap3 = 200;
// distance between one mask and the other
gap4 = 5000;
// looping time after all images displayed(5 second)
//
current = 1;
back.swapChildren(1);
front.swapChildren(3);
back.gotoAndStop(1);
front.gotoAndStop(1);
front._mask = _mask;
//
for (var i:int=1; i<=numOfMask; i++) {
var _rectMoveSet:RectMoveSet = new RectMoveSet();
_mask.addChild(_rectMoveSet);
//mask.attachMovie("rectMoveSet", i, i);
_mask[i].x = (gap3/2+gap3*(i-1));
}
counter = 1;
id = setInterval(_mask, "aa", gap1);
//
_mask.aa = function() {
for (temp in mask[counter]) {
_mask[counter][temp].gotoAndPlay(2);
}
if (counter>numOfMask) {
clearInterval(id);
id = setInterval(bb, 1000);
}
counter++;
};
function bb() {
clearInterval(id);
root.textMove.removeMovieClip();
root.addChild("textMove"+current, "textMove", 4);
back.gotoAndStop(current+1);
for (temp in _mask) {
_mask[temp].removeMovieClip();
}
if (current == numOfImage) {
current = 1;
id = setInterval(cc, gap4);
} else {
current++;
id = setInterval(cc, gap2);
}
front.gotoAndStop(current);
}
//
function cc() {
root.textMove.swapChildren(2);
for (var i:int =1; i<=_numOfMask; i++) {
var _rectMoveSet:RectMoveSet = new RectMoveSet();
_mask.addChild(_rectMoveSet);
_mask[i].x = (gap3/2+gap3*(i-1));
if (i%2) {
_mask[i].y = 0;
} else {
_mask[i].y = 0;
}
}
counter = 1;
clearInterval(id);
id = setInterval(_mask, "aa", gap1);
}
//
myoreo
August 24th, 2009, 01:32 PM
first of all,
front._mask = _mask;
should be
front.mask = _mask;
what other errors are you getting? Sorry this is so painful for you
if you want, you can PM or upload the flash file and I will help you out
prone
August 24th, 2009, 02:33 PM
first of all,
front._mask = _mask;
should be
front.mask = _mask;
what other errors are you getting? Sorry this is so painful for you
if you want, you can PM or upload the flash file and I will help you out
There's a long list of errors. If you don't mind helping me out that would be great!
Thanks a bunch!
peacock
August 24th, 2009, 03:01 PM
so just upload the fla as attachment
prone
August 24th, 2009, 03:02 PM
The fla file is too big to upload. I can send it to you if possible?
peacock
August 24th, 2009, 03:05 PM
yes, you can send me a private message (click on my username)
prone
August 25th, 2009, 11:43 AM
Hello Peacock!
Thank you so much for making this effect work! :hugegrin:!!! I totally appreciate it!!!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.