Skip to main content
Known Participant
April 6, 2009
Question

external as2 userDrawingTablet into as3

  • April 6, 2009
  • 1 reply
  • 457 views

created a tablet where the user could draw on the pad. i did it a while ago using actionscript 2. now i'm loading it externally into as3. when placed in as3 it seems to be confused as to where the tablet is and draws only on the bottom right and off the page. also have a text function that is not working properly either.

kind of a random application and random problem, but not sure where else to go with this...

was just wondering if anyone had done this and had a similar problem?

thanx

This topic has been closed for replies.

1 reply

April 6, 2009

Do you have some actionscript you could post here so we might be able to see what you are doing?

BigHimAuthor
Known Participant
April 6, 2009

"submitter" is a movie clip on the main timeline. this code is inside submitter layed out with a mc named "blackboard". blackboard has a mc named "innerBlackboard" inside of it.

blackboard.clearChalk = function():Void {
    var cl = this._parent._parent.chalkLine;
    this.createEmptyMovieClip("chalkLayer", 0);
    this.chalkLayer.lineStyle(cl.thickness, cl.color, cl.alpha);
    this.drawings = [];
};
blackboard.clearText = function():Void {
    this.createEmptyMovieClip("textLayer", 10);
    this.textfields = [];
};
blackboard.clearAll = function():Void {
    this.clearChalk();
    this.clearText();
};

blackboard.enterDrawMode = function():Void {
    this.innerBlackboard.onPress = this.startDraw;
};
blackboard.startDraw = function():Void {
    var x:Number = Math.round(this._xmouse);
    var y:Number = Math.round(this._ymouse);
    var coordinates = [x + "," + y];
    this._parent.currentDrawing = coordinates;
    this._parent.drawings.push(coordinates);
    this._parent.chalkLayer.moveTo(x, y);
    this._parent.onMouseMove = this._parent.drawChalk;
    this.onRelease = function() {
        delete this._parent.onMouseMove;
    };
};
blackboard.endDraw = function():Void {
    delete this.onMouseMove;
    delete this.innerBlackboard.onRelease;
};
blackboard.drawChalk = function():Void {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
        var x:Number = Math.round(this._xmouse);
        var y:Number = Math.round(this._ymouse);
        this.currentDrawing.push(x + "," + y);
        this.chalkLayer.lineTo(x, y);
    } else {
        this.endDraw();
    }
    updateAfterEvent();
};

blackboard.enterTextMode = function():Void {
    this.innerBlackboard.onPress = this.startText;
};
blackboard.startText = function():Void {
    var d:Number = this._parent.textLayer.getNextHighestDepth();
    var x:Number = this._parent._xmouse;
    var y:Number = this._parent._ymouse;
    this._parent.textLayer.createTextField("t" + d, d, x, y, this._parent.width - x, this._parent.height - y);
    var tf:TextField = this._parent.textLayer["t" + d];
    this._parent.textfields.push(tf);
    tf.type = "input";
    tf.multiline = true;
    tf.wordWrap = true;
    tf.restrict = "^'<>";
    tf.setNewTextFormat(this._parent._parent._parent.chalkFormat);
    tf.embedFonts = true;
    tf.text = "Type message";
    Selection.setFocus(tf);
    Selection.setSelection(0, tf.text.length);
    tf.onKillFocus = function() {
        this.type = "dynamic";
        this.selectable = false;
    };
};
blackboard.formatEntry = function():String {
    var tf:TextField;
    var d:Object;
    var entryXML    =  "<entry>";
    entryXML        +=         "<text>";
    for (var i:Number = 0; i < this.textfields.length; i++) {
        tf = this.textfields;
        entryXML    +=            "<field x='" + tf._x + "' y='" + tf._y + "' text='" + tf.text + "' />";
    }
    entryXML        +=         "</text>";
    entryXML        +=         "<drawings>";
    for (i = 0; i < this.drawings.length; i++) {
        d = this.drawings;
        entryXML    +=            "<drawing coordinates='" + d.join("|") + "' />";
    }
    entryXML        +=         "</drawings>";
    entryXML        += "</entry>";
    return escape(entryXML);
};

blackboard.clearAll();
blackboard.innerBlackboard.useHandCursor = false;
blackboard.width = blackboard._width;
blackboard.height = blackboard._height;

draw_bn.onRelease = function() {
    blackboard.enterDrawMode();
    text_bn.gotoAndStop("_Up");
    text_bn.enabled = true;
    this.gotoAndStop("_Down");
    this.enabled = false;
};
text_bn.onRelease = function() {
    blackboard.enterTextMode();
    draw_bn.gotoAndStop("_Up");
    draw_bn.enabled = true;
    this.gotoAndStop("_Down");
    this.enabled = false;
};
clear_bn.onRelease = function() {
    blackboard.clearAll();
};
submit_bn.onRelease = function() {
    var name:String = name_if.text;
    if (name == "" || name == "name (required)") return;
    var email:String = email_if.text;
    if (email == "" || email == "email (required)") return;
    entry = new LoadVars();
    entry.name = name;
    entry.email = email_if.text;
    entry.message = blackboard.formatEntry();
    returnEntry = new LoadVars();
    returnEntry.onLoad = traceReturn;
    entry.sendAndLoad("submitEntry.php", returnEntry);
};

function traceReturn() {
    if (this.result == "success") {
        blackboard.clearAll();
    }
}

name_if.onSetFocus = email_if.onSetFocus = function() {
    this.text = "";
    delete this.onSetFocus;
};
name_if.restrict = email_if.restrict = "^'<>";