PDA

Volledige versie bekijken : Teken Tutorial


-Rutger-
%Europe/Berlin %924 %2007, 22:11
Ik weet niet of het moeilijk is, maar het lijkt me leuk om een tekenprogrammatje te maken, zoiets als linerider maar dan zonder slee ofzo, als er tutorials voor zijn, kent iemand dan een goeie?

PS: ik plaats dit bij actionscript omdat je hiervoor actionscript nodig hebt.

Emveedee
%Europe/Berlin %926 %2007, 22:13
Zoek eens in de flash help op drawing API

Ruben!
%Europe/Berlin %931 %2007, 22:20
Ah, zoiets heb ik toevallig laats gemaakt. Hij staat alleen op de andere pc, maar even zo uit mn hoofd, en minder uitgebreid:

var lineMC:MovieClip = _root.createEmptyMovieClip("line", 1);//maak een lege MC aan
lineMC.lineStyle(0x000000, 1, 100);//als er getekend gaat worden in de lege MC zal de lijnkleur zwart zijn, lijndikte 1, en de alpha 100%.
var down:Boolean = false;//de muis is niet naar beneden op dit moment
onMouseDown = function () {//als je muis naar beneden
down = true;//is de muis wel naar beneden
lineMC.moveTo(_xmouse,_ymouse)//positie van de lege MC is nu die van de _x en _ymouse.
onMouseMove = function(){//als je de muis beweegt
if(down)lineMC.lineTo(_xmouse,_ymouse)//als de muis naar beneden is, trek dan een lijn van de huidige positie van lineMC naar de _x en _y van de muis
}
};
onMouseUp = function(){//
down = false;//nu is de muis niet meer naar beneden
}

-Rutger-
%Europe/Berlin %667 %2007, 16:01
ik heb ide drawing api tut. van flash maar daar heb je alleen circels en vierkanten ik dacht ik maak en pen maar het lukt voor geen meter :-\
//************************************************** **************************
//Copyright (C) 2005 Macromedia, Inc. All Rights Reserved.
//The following is Sample Code and is subject to all restrictions on
//such code as contained in the End User License Agreement accompanying
//this product.
//************************************************** **************************

/*
Using the Drawing API Example
This example shows you how to create shapes, draw lines,
fill shapes, sort shapes and remove shapes using the Drawing API.
*/

// create an array of web safe colors using a series of loops.
var colors = new String("00,33,66,99,CC,FF").split(",");
var color_array:Array = new Array();
for (var r = 0; r<colors.length; r++) {
for (var g = 0; g<colors.length; g++) {
for (var b = 0; b<colors.length; b++) {
var rgb = colors[r]+colors[g]+colors[b];
color_array.push({data:"0x"+rgb, label:"#"+rgb});
}
}
}
// bind the font array to both the fillColor_cb ComboBox and strokeColor_cb ComboBox.
fillColor_cb.dataProvider = color_array;
strokeColor_cb.dataProvider = color_array;

// set the available drawing shapes.
shape_cb.dataProvider = ['Oval', 'Rectangle', 'pen'];

// create a mouse listener which you use to track when the mouse button is pressed and released.
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
_global.pos1 = {x:_xmouse, y:_ymouse};
};
mouseListener.onMouseUp = function() {
_global.pos2 = {x:_xmouse, y:_ymouse};
// test to make sure that the mouse is pressed while over the "canvas" (the stage_mc movie clip)
if (stage_mc.hitTest(_xmouse, _ymouse, false)) {
// draw the selected shape
drawShape(_global.pos1.x, _global.pos1.y, _global.pos2.x, _global.pos2.y);
}
};
Mouse.addListener(mouseListener);

// create the function which you use to draw the requested shape on the stage.
function drawShape(x1:Number, y1:Number, x2:Number, y2:Number) {
// calculate the difference between the various X and Y coordinates.
var thisWidth:Number = Math.abs(x2-x1);
var thisHeight:Number = Math.abs(y2-y1);

// store the next available depth on the main Timeline
var nextDepth = this.getNextHighestDepth();

// create a new movie clip where you draw the shape.
var thisClip:MovieClip = this.createEmptyMovieClip("clip"+nextDepth+"_mc", nextDepth);

/* use the drawing API to draw the selected shape on the Stage.
There are two shapes available: a rectangle and oval. */
with (thisClip) {
lineStyle(strokeWidth_ns.value, strokeColor_cb.selectedItem.data, 100);
beginFill(fillColor_cb.selectedItem.data);
switch (shape_cb.selectedItem.toLowerCase()) {
case 'oval' :
moveTo(0, thisHeight/2);
curveTo(0, 0, thisWidth/2, 0);
curveTo(thisWidth, 0, thisWidth, thisHeight/2);
curveTo(thisWidth, thisHeight, thisWidth/2, thisHeight);
curveTo(0, thisHeight, 0, thisHeight/2);
_x = Math.min(x1, x2);
_y = Math.min(y1, y2);
break;
case 'rectangle' :
moveTo(x1, y1);
lineTo(x2, y1);
lineTo(x2, y2);
lineTo(x1, y2);
lineTo(x1, y1);
break;
case 'pen' :
moveTo(x1, y1);
lineTo(x1, y1);
lineTo(x1, y1);
lineTo(x1, y1);
lineTo(x1, y1);
break;
}

endFill();
}

// when the mouse is released over a shape, clear the lines/fill drawn by the drawing API.
thisClip.onRelease = function() {
this.clear();
};
}
// change the colors of the labels
shape_lbl.setStyle("color", 0xFFFFFF);
fill_lbl.setStyle("color", 0xFFFFFF);
strokeC_lbl.setStyle("color", 0xFFFFFF);
strokeW_lbl.setStyle("color", 0xFFFFFF);
als ik de pen tool selecteer kleurt hij niets

Ruben!
%Europe/Berlin %668 %2007, 16:03
Heb je mijn post weleens bekeken!?

-Rutger-
%Europe/Berlin %674 %2007, 16:10
yup, en hij werkt goed! waarom loop ik dan idd zo te zeuren :P....
nu nog even de kleuren instellen....0.o ik ga het even proberen je hoort het nog wel als ik met kleuren in de problemen kom...

Ruben!
%Europe/Berlin %683 %2007, 16:24
yup, en hij werkt goed!

Begrijp je de code ook?

-Rutger-
%Europe/Berlin %690 %2007, 16:34
Ja, var lineMC:MovieClip = _root.createEmptyMovieClip("line", 1);
lineMC.lineStyle(0x000000, 1, 100);
//creeert een nieuwe lege movieclip en de soort lijn, alhoewel ik dat nog niet helemaal begrijp...
var down:Boolean = false;
onMouseDown = function () {
down = true;
lineMC.moveTo(_xmouse,_ymouse)
onMouseMove = function(){
if(down)lineMC.lineTo(_xmouse,_ymouse)
}
};
//zegt dat als de muis ingedrukt is en / of beweegt een spoor achterlaat, als het ware de lineMC
onMouseUp = function(){
down = false;
}
//als de muis niet meer ingedrukt is, dan stopt hij met down, dan word hij dus false, en down is het spoor dus je tekent ook niet meer
dacht ik.... maar even over de kleuren, je stelt in het as de kleurcode in en zorgt ervoor dat je daarvoor bijv. een groen knopje, de groene kleurcode geeft en als je erop klikt het spoor ook groen word vanaf het punt wanneer je dat knopje indrukt, maar hoe je dat instelt weet ik niet, ik ken wel kleurcodes maar kleurcodes geven aan knopjes?

marcvz
%Europe/Berlin %692 %2007, 16:36
Je weet hoe je kleurcodes van een lijn in moet stellen.
En je weet welke kleur de lijn bij welk knopje moet worden..

Ik begrijp het probleem even niet...

-Rutger-
%Europe/Berlin %694 %2007, 16:39
Nee, maar dat is mijn verwachting van hoe je het moet maken...
Dus, kent iemand nog een tutorial? want daarmee begon ik dit topic eigenlijk :P

septunas
%Europe/Berlin %727 %2007, 17:27
Interessante code.
Weet iemand hoe je dit kan bewaren om nadien te delen?

josko
%Europe/Berlin %729 %2007, 17:30
Even kijken. TFW / peter heeft vast wel iets....
As-> Drawing API (http://www.flashfocus.nl/forum/showthread.php?p=52365#drawing API)

septunas
%Europe/Berlin %740 %2007, 17:45
Even kijken. TFW / peter heeft vast wel iets....
As-> Drawing API (http://www.flashfocus.nl/forum/showthread.php?p=52365#drawing API)

Heb ze allen bekeken, maar nergens staat omschreven hoe je die kan saven.
Maar even nadenken heeft me het idee gegeven alle parameters in een array te steken en die dan met php te saven..

Iemand een beter idee?

josko
%Europe/Berlin %748 %2007, 17:57
Heb ze allen bekeken, maar nergens staat omschreven hoe je die kan saven.
Maar even nadenken heeft me het idee gegeven alle parameters in een array te steken en die dan met php te saven..

Iemand een beter idee?
swf object?

Opslaan met flash zelf.

Zo slaat line-rider het in ieder geval op. Maarja :)

septunas
%Europe/Berlin %767 %2007, 18:24
swf object?

Opslaan met flash zelf.

Zo slaat line-rider het in ieder geval op. Maarja :)

heb er ook al eens mee gespeeld. :) Maar die geven geen code vrij dacht ik?

septunas
%Europe/Berlin %583 %2007, 14:00
http://pume.be/ff/draw/

:bigsmile:

Nidd
%Europe/Berlin %598 %2007, 14:22
Leuk joh! :)

Niels.

Ruben!
%Europe/Berlin %600 %2007, 14:24
Cookies of php+mySQL?

Zou je wat code kunnen laten zien?:)

Nidd
%Europe/Berlin %601 %2007, 14:26
Het kan vrij makkelijk met cookies alleen kun je dan geen tekening opslaan en ergens anders bekijken.

Niels.

septunas
%Europe/Berlin %604 %2007, 14:29
Cookies of php+mySQL?

XML en php

Zou je wat code kunnen laten zien?:)

Allé dan , omdat je zo'n mooie muziek maakt :P

params_a = [];
var nodeLeng:Number = new Number();
// **** Load XML ****************************
myXML = new XML();
myXML.ignoreWhite = true;
receiverXML = new XML();
myXML.onLoad = function(success) {
myXML.contentType = "text/xml";
if (success) {
this.showXML();
} else {
trace("Error loading XML file");
}
};
myIdentifier1 = Math.round(Math.random()*10000);
myXML.load("raadjenooit.xml?uniq="+myIdentifier1);
receiverXML.onLoad = function() {
};
XML.prototype.showXML = function() {
nodeLeng = myXML.firstChild.childNodes.length;
// START!
showdrawing();
};
// **** Draw functions ****************************
function showdrawing() {
draw_mc = _root.createEmptyMovieClip("draw_mc", 1);
draw_mc.lineStyle(1);
for (i=0; i<nodeLeng; i++) {
movex = myXML.firstChild.childNodes[i].attributes.movex;
movey = myXML.firstChild.childNodes[i].attributes.movey;
linex = myXML.firstChild.childNodes[i].attributes.linex;
liney = myXML.firstChild.childNodes[i].attributes.liney;
if (movex != "") {
draw_mc.moveTo(movex, movey);
}
if (linex != "") {
draw_mc.lineTo(linex, liney);
}
}
}
function drawline() {
draw_mc = _root.createEmptyMovieClip("draw_mc", 1);
draw_mc.lineStyle(1);
draw_mc.onMouseDown = function() {
this.moveTo(_xmouse, _ymouse);
params_a.push({movex:this._xmouse, movey:this._ymouse, linex:"", liney:""});
this.onMouseMove = drawALine;
};
draw_mc.onMouseUp = function() {
this.onMouseMove = null;
};
function drawALine() {
this.lineTo(_xmouse, _ymouse);
params_a.push({movex:"", movey:"", linex:this._xmouse, liney:this._ymouse});
}
}
erase_bt.onPress = function() {
removeMovieClip(draw_mc);
params_a = [];
drawline();
};
// Save XML
save_bt.onPress = function() {
nodeLeng = params_a.length;
myXML.firstChild.removeNode();
myXML.appendChild(myXML.createElement("params"));
for (i=0; i<nodeLeng; i++) {
myXML.firstChild.appendChild(myXML.createElement("par"));
myXML.firstChild.childNodes[i].attributes.movex = params_a[i].movex;
myXML.firstChild.childNodes[i].attributes.movey = params_a[i].movey;
myXML.firstChild.childNodes[i].attributes.linex = params_a[i].linex;
myXML.firstChild.childNodes[i].attributes.liney = params_a[i].liney;
if (i == nodeLeng-1) {
myXML.sendAndLoad("jemoesteensweten.php", receiverXML);
}
}
};


(draw api geďnspireerd van de blog van Daunt)

caBG
%Europe/Berlin %566 %2007, 14:35
weet iemand wat de action script voor linerider is?

-Rutger-
%Europe/Berlin %569 %2007, 14:39
Dit topic is al 2 maanden oud, start een nieuw topic met je vraag. Geen oude topics omhoog halen.