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

How to convert from AS1 to AS3

New Here ,
Jul 19, 2009 Jul 19, 2009

Copy link to clipboard

Copied

Hi I am new to AS3. I have a program in AS1 and trying to convert in AS3. But getting some error message  "1093: Syntax error. #initclip 1"   &  "1093: Syntax error. #endinitclip"

I checked and found that #initclip is removed in AS3. So plase suggest me what should I do, Is there any alternative of #initclip?

Here is the code

#initclip 1
MovieClip.prototype.getNextHighestDepth = function() {
    var t = -Infinity;
    for (var i in this) {
        if (this.getDepth() != null && this._parent == this) {
            t = Math.max(t, this.getDepth());
        }
    }
    return (t>-1) ? ++t : 0;
};
//CREATING OBJECT OF MOVIECLIP ## INHERITENCE ##
ColorPalette.prototype = new MovieClip();
// COLORPALETTE CLASS ##
function ColorPalette() {
    this.stor = this._parent[this.stor];
    this.attachMovie("hold_main1", "hold_main", 0);
    this.setButtonColor(this.bcol);
    this.col_pick.arrow1._visible = this.sa;
    this.hold_main._alpha = 100;
    this.apPosition(this.pos);
    this.hold_main.but._visible = 0;
    mx = 0;
    my = 0;
    st1 = 0;
    st2 = 0;
    st3 = 0;
    rr = "";
    gg = "";
    bb = "";
    targ = "hold1";
    // THREE SLABS LOAD IN HOLD1
    for (k=1; k<=6; k++) {
        for (i=1; i<=6; i++) {
            for (j=1; j<=6; j++) {
                this.hold_main[targ].attachMovie("but", "b"+j+i+k, j+""+i+""+k);
                this.hold_main[targ]["b"+j+i+k]._x = mx;
                // X POSITION ##
                this.hold_main[targ]["b"+j+i+k]._y = my;
                // Y POSITION ##
                if (st1 == 12) {
                    rr = "CC";
                } else if (st1 == 15) {
                    rr = "FF";
                } else {
                    rr = st1+""+st1;
                }
                if (st2 == 12) {
                    gg = "CC";
                } else if (st2 == 15) {
                    gg = "FF";
                } else {
                    gg = st2+""+st2;
                }
                if (st3 == 12) {
                    bb = "CC";
                } else if (st3 == 15) {
                    bb = "FF";
                } else {
                    bb = st3+""+st3;
                }
                mcol = new Color(this.hold_main[targ]["b"+j+i+k]);
                mcol.setRGB("0x"+rr+gg+bb);
                this.hold_main[targ]["b"+j+i+k].onRelease = function() {
                    mcol = new Color(this);
                    this._parent._parent._parent.onChange("0x"+mcol.getRGB().toString(16));
                    coo1 = new Color(this._parent._parent._parent.col_pick.show_col);
                    coo1.setRGB("0x"+mcol.getRGB().toString(16));
                    this._parent._parent._visible = false;
                    this._parent._parent.swapDepths(this._parent.depth);
                    var mtf = new TextFormat();
                    mtf.color = "0x"+mcol.getRGB().toString(16);
                    Selection.setFocus(eval(this._parent._parent._parent.stor));
                    Selection.setSelection(this._parent._parent._parent.tempBegin, this._parent._parent._parent.tempEnd);
                    eval(this._parent._parent._parent.stor).setTextFormat(this._parent._parent._parent.tempBegin, this._parent._parent._parent.tempEnd, mtf);
                    Selection.setSelection(this._parent._parent._parent.tempBegin, this._parent._parent._parent.tempEnd);
                };
                this.hold_main[targ]["b"+j+i+k].onRollOver = function() {
                    mcol = new Color(this);
                    coo = new Color(this._parent._parent._parent.col_pick.show_col);
                    coo.setRGB("0x"+mcol.getRGB().toString(16));
                };
                this.hold_main[targ]["b"+j+i+k].useHandCursor = false;
                my += 11;
                st3 += 3;
            }
            my = 0;
            mx += 11;
            st3 = 0;
            st2 += 3;
        }
        st3 = 0;
        st2 = 0;
        st1 += 3;
        if (st1 == 9) {
            targ = "hold2";
            // AND THREE IN HOLD2
            mx = 0;
        }
    }
    r = 0;
    g = 0;
    b = 0;
    for (i=1; i<=12; i++) {
        this.hold_main.hold3.attachMovie("but", "c"+i, i);
        this.hold_main.hold3["c"+i]._y = this.hold_main.hold3["c"+(i-1)]._y+this.hold_main.hold3["c"+(i-1)]._width+1;
        mcoll = new Color(this.hold_main.hold3["c"+i]);
        if (i<=6) {
            if (r == 12) {
                mcoll.setRGB(0xCCCCCC);
            } else if (r == 15) {
                mcoll.setRGB(0xFFFFFF);
            } else {
                mcoll.setRGB("0x"+r+r+g+g+b+b);
            }
            r += 3;
            g += 3;
            b += 3;
        }
        if (i == 7) {
            mcoll.setRGB(0xFF0000);
        }
        if (i == 8) {
            mcoll.setRGB(0x00FF00);
        }
        if (i == 9) {
            mcoll.setRGB(0x0000FF);
        }
        if (i == 10) {
            mcoll.setRGB(0xFFFF00);
        }
        if (i == 11) {
            mcoll.setRGB(0x00FFFF);
        }
        if (i == 12) {
            mcoll.setRGB(0xFF00FF);
        }
        this.hold_main.hold3["c"+i].onRelease = function() {
            mcol = new Color(this);
            //coo = new Color(this._parent._parent._parent.stor);
            coo.setRGB("0x"+mcol.getRGB().toString(16));
            this._parent._parent._parent.onChange("0x"+mcol.getRGB().toString(16));
            coo1 = new Color(this._parent._parent._parent.col_pick.show_col);
            coo1.setRGB("0x"+mcol.getRGB().toString(16));
            this._parent._parent._visible = false;
            this._parent._parent.swapDepths(this._parent.depth);
            var mtf = new TextFormat();
            mtf.color = "0x"+mcol.getRGB().toString(16);
            Selection.setFocus(eval(this._parent._parent._parent.stor));
            Selection.setSelection(this._parent._parent._parent.tempBegin, this._parent._parent._parent.tempEnd);
            eval(this._parent._parent._parent.stor).setTextFormat(this._parent._parent._parent.tempBegin, this._parent._parent._parent.tempEnd, mtf);
            Selection.setSelection(this._parent._parent._parent.tempBegin, this._parent._parent._parent.tempEnd);
        };
        this.hold_main.hold3["c"+i].onRollOver = function() {
            mcol = new Color(this);
            coo = new Color(this._parent._parent._parent.col_pick.show_col);
            coo.setRGB("0x"+mcol.getRGB().toString(16));
        };
        this.hold_main.hold3["c"+i].useHandCursor = false;
    }
    this.hold_main._visible = false;
    this.col_pick.onPress = function() {
        if (!this._parent.hold_main._visible) {
            this._parent.depth = this._parent.getDepth();
            this._parent.swapDepths(this._parent._parent.getNextHighestDepth());
        }
        this._parent.tempBegin = this._parent._parent.selectedBeginText;
        this._parent.tempEnd = this._parent._parent.selectedEndText;
    };
    this.col_pick.onRelease = function() {
        if (this._parent.hold_main._visible) {
            this._parent.hold_main._visible = false;
            this._parent.swapDepths(this._parent.depth);
            trace(this._parent.getDepth());
        } else {
            this._parent.hold_main._visible = true;
        }
    };
    this.col_pick.onRollOver = function() {
        this._parent._parent.toolTip._visible = true;
        this._parent._parent.toolTip.tipText.text = "Color";
    };
    this.col_pick.onRollOut = function() {
        this._parent._parent.toolTip._visible = false;
    };
}
ColorPalette.prototype.setButtonColor = function(bcol) {
    hold_col = new Color(this.col_pick.base);
    hold_col.setRGB(bcol);
};
ColorPalette.prototype.showArrow = function(sa) {
    this.col_pick.arrow1._visible = sa;
};
ColorPalette.prototype.apPosition = function(pos) {
    if (pos == "TopLeft") {
        this.hold_main._x = -146;
        this.hold_main._y = -138;
    } else if (pos == "TopRight") {
        this.hold_main._x = 0;
        this.hold_main._y = -138;
    } else if (pos == "BottomLeft") {
        this.hold_main._x = -146;
        this.hold_main._y = 32;
    } else if (pos == "BottomRight") {
        this.hold_main._x = 0;
        this.hold_main._y = 32;
    }
};
ColorPalette.prototype.targ = function(msg) {
    this.stor = msg;
};
// REGISTERING CLASS ##
Object.registerClass("ColorPalette", ColorPalette);
#endinitclip

Please help me.

TOPICS
ActionScript

Views

2.2K

Translate

Translate

Report

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 19, 2009 Jul 19, 2009

Copy link to clipboard

Copied

delete those 2 lines of code.

then convert your prototype code into functions that accept movieclip and colorpallete instances.

Votes

Translate

Translate

Report

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 31, 2010 Aug 31, 2010

Copy link to clipboard

Copied

LATEST

Hi kglad,

Can you please explain a bit more say if I have below code

#initclip 45


Object.registerClass("Border", mx.skins.Border);


#endinitclip

What should be the as3 output?

Thanks in advance.

With Regards,

Sagar S. Ranpise

Votes

Translate

Translate

Report

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