A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Problem with my code... Help?

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    9

    Unhappy Problem with my code... Help?

    I am making a draw application and with a tutorial and some comment posts from it, I've come to this... Since I changed the commented out part to this:
    Code:
    //lineThickness = 0;
    //selectedColor = "0x000000";
    //_root.onMouseDown = startDrawing;
    //_root.onMouseUp = stopDrawing;
    //function startDrawing() {
    //if (_ymouse<420) {
    //_root.lineStyle(lineThickness, selectedColor);
    //_root.moveTo(_root._xmouse, _root._ymouse);
    //_root.onMouseMove = drawLine; 
    //		}
    //	}
    //function drawLine() {
    //_root.lineTo(this._xmouse, this._ymouse);
    //	}
    //function stopDrawing() {
    //delete this.onMouseMove;
    //	}
    //
    
    createEmptyMovieClip("surface",1);
    surface.lineStyle(1,"0×000000",100);
    onMouseDown = function (){
    surface.moveTo(_xmouse, _ymouse);
    if (_ymouse<420)
    onMouseMove = function (){
    surface.lineTo(_xmouse, _ymouse);
    _root.drawTools.swapDepths(1000);
    };
    };
    onMouseUp = function(){
    delete onMouseMove;
    }
    How do i get the buttons i made for line thickness and color to work properly??
    Everything but changing the size and color works... (even the eraser)

    Ready to pull my hair out!

    Code:
    _root.drawTools.line0.onPress = function() {
    lineThickness = 0;
    	};
    _root.drawTools.line3.onPress = function() {
    lineThickness = 3;
    	};
    _root.drawTools.line6.onPress = function() {
    lineThickness = 6;
    	};
    _root.drawTools.colorRed.onPress = function() {
    selectedColor = "0xFF0000";
    	};
    _root.drawTools.colorOrange.onPress = function() {
    selectedColor = "0xFF6600";
    	};
    _root.drawTools.colorYellow.onPress = function() {
    selectedColor = "0xFFFF00";
    	};
    _root.drawTools.colorGreen.onPress = function() {
    selectedColor = "0x00FF00";
    	};
    _root.drawTools.colorBlue.onPress = function() {
    selectedColor = "0x0000FF";
    	};
    _root.drawTools.colorPurple.onPress = function() {
    selectedColor = "0x9900FF";
    	};
    _root.drawTools.colorFuchsia.onPress = function() {
    selectedColor = "0xFF00FF";
    	};
    _root.drawTools.colorPink.onPress = function() {
    selectedColor = "0xFF3399";
    	};
    _root.drawTools.colorBlack.onPress = function() {
    selectedColor = "0x000000";
    	};
    _root.drawTools.colorWhite.onPress = function() {
    selectedColor = "0xFFFFFF";
    	};
    _root.drawTools.colorGray.onPress = function() {
    selectedColor = "0x666666";
    	};
    
    _root.drawTools.eraser_btn.onPress = function() {
    _root.clear();
    createEmptyMovieClip("surface",1);
    surface.lineStyle(1,"0×000000",100);
    	};

    the lineThickness and selectedColor worked before, but with the new code at the top, i dont know what to change them to.

    I know the problem is that this line doesnt match up with my old code, but I dont know what to do about it!

    Code:
    surface.lineStyle(1,"0×000000",100);

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var lineThickness = 0;
    var selectedColor = "0x000000";
    //
    createEmptyMovieClip("surface",1);
    //
    onMouseDown = function () {
    	surface.moveTo(_xmouse,_ymouse);
    	if (_ymouse<420) {
    		onMouseMove = function () {
    			surface.lineStyle(lineThickness,selectedColor,100);
    			surface.lineTo(_xmouse,_ymouse);
    			_root.drawTools.swapDepths(1000);
    		};
    	}
    };
    //
    onMouseUp = function () {
    	delete onMouseMove;
    };
    //
    _root.drawTools.line0.onPress = function() {
    	lineThickness = 0;
    };
    _root.drawTools.line3.onPress = function() {
    	lineThickness = 3;
    };
    _root.drawTools.line6.onPress = function() {
    	lineThickness = 6;
    };
    //
    _root.drawTools.colorRed.onPress = function() {
    	selectedColor = "0xFF0000";
    };
    _root.drawTools.colorOrange.onPress = function() {
    	selectedColor = "0xFF6600";
    };
    //
    _root.drawTools.eraser_btn.onPress = function() {
    	_root.clear();
    	createEmptyMovieClip("surface",1);
    };

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    dawsonk I think I love you.

    THANK YOU SO MUCH,

    when i have it live, ill try and remember to post you the link. you'll laugh

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    I'll go ahead and post a temporary link, to show it off. hehe...

    Basically I'm building a new website for my portfolio, and this will go on my bio page. just a little funny treat for viewers. eventually I'd like to make it have the option to save their work to the server, and possibly post to a gallery page, or email it to me. That would be hilarious!

    I'm SO glad it works now. you have no idea... o.o

    http://www.thegreenecrystal.com/CG_drawingobject4.html

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