Simple? Draw A Function Curve
I want to do something that seems simple. I want to draw a curve on the stage, without using a series of dots...let's say y=x^2.
I just want a line/curve/whatever to follow the path of a mathematical function. Can someone get me started?
FlashKit > Flash Help > Flash ActionScript
Posted on: 12-01-2003, 02:46 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Simple? Draw A Function Curve
I want to do something that seems simple. I want to draw a curve on the stage, without using a series of dots...let's say y=x^2.
I just want a line/curve/whatever to follow the path of a mathematical function. Can someone get me started?
Draw Curve Through 3 Points (not The Control Point)
I'm attempting to make a curve drawing tool a bit easier to use. Rather than drawing a basic curve and then clicking on the control point to change it, I would like the user to be able to click on the curve itself to change it, much as you do in the FlashIDE.
So, given start and end points, and a point on the curve, how do you determine the control point for use with the MX API?
(I googled this, but found mostly info on cubic rather than quadratic curves)
HowTo: Draw Bezier Curve Using Tweener
Hi all,
I was looking for some code the other day to draw a curve using a tween and didn't find much. I found that the Tweener class contained a "CurveModifiers" class that allowed you to tween numbers using a bezier function.
There wasn't much code out there that described how to use it and the Tweener documentation wasn't all that great, so after I figured it out, I thought I'd share some code with everyone.
You can find a demo and source at http://www.kilometer0.com/TweenCurves/
Basics
1. Initalize the CurveModifiers class: CurveModifiers.init(); or Tweener won't know what the _bezier property modifier is.
2. Create a sprite/shape to hold the curve, add it to the stage, and position it at the start of the point of the curve.
3. Create a dummy object to hold the curve's current x/y position.
4. Create a tweener property object with the final position of the curve and the control point (_bezier: {x:controlPoint.x,y:controlPoint.y}).
5. Assign / Create a onUpdate callback function and pass it 2 parameters (the dummy object, and the line sprite/shape).
6. Add the tween: Tweener.addTween(dummy object, tweener object);
7. In the onUpdate callback function, draw a line to the point in the current dummy object: line.graphics.lineTo(lineObj.x,lineObj.y);
Hehe... I guess that's not so basic, but its pretty easy once you play with it.
Best way to play with the demo is to move the second point around. Each time you release it, it will draw a curve. You can create some cool shapes / line drawings using it.
Enjoy.
Draw Curve Through 3 Points (not The Control Point)
I'm attempting to make a curve drawing tool a bit easier to use. Rather than drawing a basic curve and then clicking on the control point to change it, I would like the user to be able to click on the curve itself to change it, much as you do in the FlashIDE.
So, given start and end points, and a point on the curve, how do you determine the control point for use with the MX API?
(I googled this, but found mostly info on cubic rather than quadratic curves)
How Do I Draw An \"s\"-shaped Curve?
Hi all,
I\'ve been trying to understand how to draw bezier curve\'s to make an \"s\"-shaped ending to a rounded rectangle but I\'m dying on my arse with the maths. I know I need to make use of graphics.curveTo / moveTo / lineTo, but I\'m really struggling, can anyone give me a bit of AS that produces the shape attached.
Cheers.
I Need Some Simple Math Help: Want To Make A Sinus Curve Motion
I want to make an MC rise in a slow sinus curve motion, sort of like a leaf falling the wrong way.
This is what I have done but it doesn't seem to work properly and I am crap at math so please help me. I did some searching in both forum and tutorials but couldn't find anything useful.
Code:
onClipEvent (enterFrame) {
if (_y >0){
_y-=3;
_x += 5*Math.sin(_y);
} else{
this.removeMovieClip();
}
}
Draw Function
i need 2 create a drawing board for my site, where u can change the colours to draw in. i dont want the whole stage 2 be drawn on i need to create an area in a box, can anyone help me please?
Draw Instance Name From Function
I am attempting to use a function with a component (specifically the check box) and when the function is called, so on click, I want it to get the instance name of the component that was clicked. I have pondered a while over this to no avail. Is there a way to do this? Once again, any help would be more than welcome.
[F8] Reuse Function For Box Draw
I have the function below I use to draw a box.
Code:
public function drawBox(xPos:Number, yPos:Number)
{
// first create a 'pen' to draw with
_root.createEmptyMovieClip("pen_mc",5);
//
// set the line style - 0 pixels thick, black, 100% alpha
_root.pen_mc.lineStyle(0,0x000000,100);
//
// move the pen to 100 x,100 y on the stage
_root.pen_mc.moveTo(xPos,yPos);
//
// draw the next lines, each starting from the last point the pen was at
_root.pen_mc.lineTo(2*xPos,yPos);
_root.pen_mc.lineTo(2*xPos,2.5*yPos);
_root.pen_mc.lineTo(xPos,2.5*yPos);
_root.pen_mc.lineTo(xPos,yPos);
//
// end the fill
_root.pen_mc.endFill();
}
I need to reuse it to draw other boxes, but it will only draw the last one.
Why is that and how to reuse this.
Thanks,
Problem With Draw Function
Hi there,
I have a movie clip that I want to apply the draw function to (so I can save an image from it). It all works great, but the problem now comes when inside that movie clip I have another one, with a loaded image, and scaled.
The draw function let's works perfect, except for the fact that the movie clip that's inside the one I'm making the draw doesn't render scaled, it renders as it is on the library...
I read something about using a Matrix Transform for it, but can't make it work...
Any help?
Thanks,
Javier
Stop My Draw Function.
Hello
I am new to actionscript but have programmed before.
I have an application that I am working on.
I have a button that I can move by using the startdrag command
I can hover over the button and hit the <space> key, now my OnMouseDown will go in a draw mode and I can draw from the center of my button.
The next step is, I want to stop Drawing, by hitting the <esc> key
but I cannot seem to get the following to work
Code:
on (keyPress "<Escape>") {
onMouseDown=null;
}
here is my button code
Code:
on (press) {
startDrag("",true);
}
on (release) {
stopDrag();
}
on (keyPress "<Space>") {
//set up to start drawing
trace("hello");
createEmptyMovieClip("Line",1);
Line.lineStyle(1,0x000000,100);
Line.moveTo(_xmouse,_ymouse);
//redefine mousedown to draw
onMouseDown=function () {
Line.lineTo(_xmouse,_ymouse);
}
}
on (keyPress "<Escape>") {
onMouseDown=null;
}
also attached is my fla file
Problem With Draw Function
Hi there,
I have a movie clip that I want to apply the draw function to (so I can save an image from it). It all works great, but the problem now comes when inside that movie clip I have another one, with a loaded image, and scaled.
The draw function let's works perfect, except for the fact that the movie clip that's inside the one I'm making the draw doesn't render scaled, it renders as it is on the library...
I read something about using a Matrix Transform for it, but can't make it work...
Any help?
Thanks,
Javier
Draw A Simple Checkmark
Hello and thank you...
I am trying to creat a button_mov so when someone rolls over the text portion, a checkmark will draw itself out to the right of the text. I drew a checkmark in photoshop and then masked small portions of the image in separate keyframes but somehow I am getting a distorted checkmark/image. The image is inserted in frame 2 and then F5 to frame 9 so the image is stationary. Should I be using a motion guide? Thanks again...
Having Trouble Using The BitmapData.draw() Function
Im having trouble using the BitmapData.draw() function... for some reason I can't draw a movieclip to the stage if the source (when untransformed) is larger than the size of the stage.
Anyone know how to get around this?
EDIT: I can draw them, but they are cropped to the stage size. Setting the clipRect property to larger than the stage size has no effect.
Performance Of Draw/Drag Function
PHP Code:
function dragClip(clip, pressX, pressY) {
var x = clip._parent._xmouse;
var y = clip._parent._ymouse;
if (Key.isDown(32) && plateHit.hitTest(clip._parent._xmouse, clip._parent._ymouse, true)) {
var thisDot = plateRing.attachMovie("dot", "dot"+clip._parent.i, clip._parent.i);
point = new object();
point.x = x;
point.y = y;
plateHit.globalToLocal(point);
temp = (Math.atan2(point.y, point.x)*180/Math.PI)
this.radius = Math.sqrt(point.x * point.x + point.y * point.y)
angle = (angleRotation + temp )* (Math.PI/180);
thisDot._x = this.radius * Math.cos(angle)
thisDot._y = this.radius * Math.sin(angle)
thisDot.gotoAndStop(1);
clip._parent.i++;
}
clip._x = x;
clip._y = y;
updateAfterEvent();
}
http://wvlc.uwaterloo.ca/micro/streak/draw.html
That is the code to produce the following but when there are alot of dots drawn on the screen, the drag function seems to have a big performance hit where the clip (the loop) would be still drawing while the mouse is already at a different position.
Any Ideas how to compensate or to make it smoother?
The drag function above uses pixelWit's Drag Function
oh and btw this is all triggered with a onmouseMove function
PHP Code:
clip.onMouseMove = function() {
dragClip(clip, pressX, pressY);
};
BitmapData.draw() - Simple Question.
Can someone explain to me how to get a "drawn" bitmap to be rendered at 0,0 when using a clip rectangle.
To simplify, say I have a 300x300 bitmap inside a movie clip with it's x,y registered to top left. I want to crop a 100x100 square area from the bottom right corner. My issue is the copied bitmap is drawn with it's x,y relative to the source image's x,y coordinates. So when it's added to the stage it's 200 pixels in on both the x & y axis.
Any help would be appreciated.
Code:
var myBitmapData:BitmapData = new BitmapData(300,300,false);
var clipArea:Rectangle = new Rectangle(200,200,100,100);
var myBitmap:Bitmap = new Bitmap(bmd);
myBitmapData.draw(targetMC,null,null,null,clipArea,true);
addChild(myBitmapData);
BitmapData.draw() - Simple Question.
Can someone explain to me how to get a "drawn" bitmap to be rendered at 0,0 when using a clip rectangle.
To simplify, say I have a 300x300 bitmap inside a movie clip with it's x,y registered to top left. I want to crop a 100x100 square area from the bottom right corner. My issue is the copied bitmap is drawn with it's x,y relative to the source image's x,y coordinates. So when it's added to the stage it's 200 pixels in on both the x & y axis.
Any help would be appreciated.
Code:
var myBitmapData:BitmapData = new BitmapData(300,300,false);
var clipArea:Rectangle = new Rectangle(200,200,100,100);
var myBitmap:Bitmap = new Bitmap(bmd);
myBitmapData.draw(targetMC,null,null,null,clipArea,true);
addChild(myBitmapData);
Problem Using Draw Function With Attached Movies
I've created a movie that has 10 sliders as a set of spokes, and then used a draw function to generate a shape. When I move any of the sliders they move to a fixed position instead of following the spoke, resulting in the shape being distorted.
I've attached my file, any thoughts on fixing this would be really appreciated.
Draw Function Always Draws To Back Layer.
Hello,
I'm doing a movie whereby a line appears to be drawn between to points that are movable (the point eventually will be auto drawing a cable coming from a mouse cursor). The drawn line always appears to be at the back of the stage, even though the layer that the code is on is at the front. - Both movie clips at each end of the line are visible - just not the line itself. Any ideas how I can make the line appear on the top frame?
IT's done using this code:
numPoints = 20;
minDist = 50;
init();
function init()
{
var dx = h2._x - h1._x;
var dy = h2._y - h1._y;
points = new Array();
for(var i=0;i<numPoints;i++)
{
points[i] = {x:h1._x + dx / numPoints * i, y:h1._y + dy / numPoints * i, vx:0, vy:0};
}
onEnterFrame = draw;
}
h1.onPress = doDrag;
h2.onPress = doDrag;
h1.onRelease = doDrop;
h2.onRelease = doDrop;
h1.onReleaseOutside = doDrop;
h2.onReleaseOutside = doDrop;
function doDrag()
{
this.startDrag();
}
function doDrop()
{
this.stopDrag();
}
function draw()
{
for(var i=0;i<numPoints;i++)
{
points[i].x += points[i].vx;
points[i].y += points[i].vy;
/*
points[i].vx += Math.random() - .5;
points[i].vy += Math.random() - .5;
*/
if(i == 0)
{
var x1 = h1._x;
var y1 = h1._y;
}
else
{
var x1 = points[i-1].x;
var y1 = points[i-1].y;
}
if(i < numPoints-1)
{
var x2 = points[i+1].x;
var y2 = points[i+1].y;
}
else
{
var x2 = h2._x;
var y2 = h2._y;
}
//trace([x1, y1, x2, y2]);
points[i].vx += (x1 - points[i].x) * .05;
points[i].vy += (y1 - points[i].y) * .05;
points[i].vx += (x2 - points[i].x) * .05;
points[i].vy += (y2 - points[i].y) * .05;
points[i].vy += .05;
points[i].vx *= .93;
points[i].vy *= .93;
}
clear();
lineStyle(3.5, 0x00ff00, 100);
moveTo(h1._x, h1._y);
for(var i=0;i<numPoints-1;i++)
{
var x = (points[i].x + points[i+1].x) / 2;
var y = (points[i].y + points[i+1].y) / 2;
curveTo(points[i].x, points[i].y, x, y);
}
curveTo(points[i].x, points[i].y, h2._x, h2._y);
}
thanks in advance.
Drawing API - Making A Global Draw Box Function.
Hey everyone, I have here the code for a function that creates a box with curved corners and a fill. It works if the code is not within a function, but when I put it in a function and try to reference it globally, I get an error message saying that I can't use a "with" statement because there was no object. Any idea?
// The following code is on the main timeline. A movie clip on the main timeline houses a variable called movieClip. The variable holds the name of the movie clip in which it resides...so let's say i had a movie clip on the main timeline called "admin_login_bg". Within that movie clip I wanted to create a box. So I would call the global function...
createBox("admin_login_box", 0, 0, 300, 100, 10, 2, 0x000000, 100, 0xCCCCCC, false);
The global function below should create a movie clip within the movie clip that resides on the main timeline... _root.admin_login_bg.admin_login_box ...and within that movie clip create the box.
_global.createBox = function(clip_name, xloc, yloc, width, height, corner_bevel, l_thickness, l_colour, l_alpha, f_colour, drop_shadow) {
_root[movieClip].createEmptyMovieClip(""+clip_name+"", _root[movieClip].getNextHighestDepth());
_root[movieClip].clip_name._x = xloc;
_root[movieClip].clip_name._y = yloc;
with (_root[movieClip].clip_name) {
lineStyle(l_thickness, l_colour, l_alpha);
moveTo(corner_bevel, 0);
if (f_colour) {
beginFill(f_colour);
}
lineTo(width-corner_bevel, 0);
curveTo(width, 0, width, corner_bevel);
lineTo(width, height-corner_bevel);
curveTo(width, height, width-corner_bevel, height);
lineTo(corner_bevel, height);
curveTo(0, height, 0, height-corner_bevel);
lineTo(0, corner_bevel);
curveTo(0, 0, corner_bevel, 0);
if (f_colour) {
endFill();
}
}
};
Draw A Simple Filled Polygon In Actionscript
I need a function for drawing a filled polygon dynamically at runtime in actionscript. For example, I would like to be able to do this:
function drawFilledPoly(pointarray[]) {
// draw the poly and fill it here
// first and last point of the array can be the same to ensure a filled area
}
I have no clue what to do or where to start, any links, or words of wisdom would be SO helpful.
Thank you!!!!
MS Paint-like Function With The Drawing API: Can't Draw More Than 1 Line At A Time
Hi everyone! I've been lurking around here for some time now, and so many of you have been very helpful (via answering other people's similar questions), so I'd like to start by saying thanks, since this is my first post.
Now, on to business!
What I'm trying to do is imitate the functionality of a primitive drawing program, such as MicroSoft Paint, which comes with the PC. Actually, just one small part of it, but it's the best analogy I can think of. (Eventually this will be part of a chemistry-education site, so it's actually a curved electron arrow I'm looking to draw, ultimately. At the rate I'm currently going, eventually will probably mean 3012 A.D.).
I want the user to be able to click and draw lines on the screen. There's an excellent tutorial on here (I believe) that helped me get to the point where the user can draw a line, but there's a problem. Because I've basically had to make it so the line is drawn, erased, and redrawn as the mouse moves, using the clear() method, the first line vanishes once the second line is drawn.
It goes sort of like this:
-user clicks initial spot on screen
-moveTo() that initial spot
-lineTo() wherever the mouse is now
-user moves the mouse
-using clear() draw-erase-redraw-erase-redraw-erase-redraw-etc.
-user releases the mouse
-clear() and moveTo() the initial spot, then lineTo() the spot where mouse released
Up to this point, there is no problem. However, according the help file and my own experience, clear() deletes everything drawn in this way at runtime. So my question is this: how the heck do I get the existing lines to stay put when the user is drawing the second line? None of the tutorials I've seen have gone past drawing a single line. Ack!
I have seen a Flash version of MS Paint (Actionscript Cookbook from O'Rielly press has it as one of their recipies, but there's so much else going on in the code, I can't seem to pull out what I need), so this must be possible, but I haven't been able to get it to work, even by trying to capture the first and second clicks as separate sets of variables.
Here's the code that I have gotten to work for a single line (it's actually a specific curved line I'm looking to draw, which is why the curveTo() points are so mathy. It doesn't matter if it's lineTo() or curveTo(), the basic premise is the same).
code: onMouseDown = function()
{
createEmptyMovieClip("Line", 1);
// get the x and y mouse positions
//and store them in variables
var xstart:Number = _xmouse
var ystart:Number = _ymouse
onMouseMove = function()
{
this.clear()
this.moveTo(xstart, ystart);
this.lineStyle(1,0x000000,100);
this.curveTo((_xmouse-((_xmouse-xstart)/4)),(_ymouse-((_xmouse-xstart)/3)),_xmouse, _ymouse)
}
onMouseUp = function()
{
this.clear()
this.moveTo(xstart, ystart);
this.lineStyle(1,0x000000,100);
this.curveTo((_xmouse-((_xmouse-xstart)/4)),(_ymouse-((_xmouse-xstart)/3)),_xmouse, _ymouse);
onMouseMove=null;
onMouseUp=null;
}}
Thanks to anyone taking the time to try and help me with this!
Can't Find Mistake In Re-write Of Draw Function. No Error Msg, Just Doesn't Work
Hey there, I am trying to convert some code into something easier to re-use without a ridicualous amount of math and excess coding. I also want to be able to tell the mc (when necessary), when this function finishes --> go do ----- ;
the code progressively draws out an outline of a shape (i.e. a square or rect)
here is the my re-write that doesn't work:
Code:
MovieClip.prototype.drawShape = function(x, y, w, h, speed, stroke, color, alpha) {
var v1:MovieClip = this;
v1.points = [ [x, y], [x+w, y], [x+w, y+h], [x, y+h] ];
v1.time = 0;
v1.style = [stroke, color, alpha];
var seg = Math.min(Math.floor(v1.time*v1.points.length), v1.points.length-1);
var nextseg = (seg<v1.points.length-1) ? seg+1 : 0;
var segtime = (v1.time-seg/v1.points.length)*v1.points.length;
v1.onEnterFrame = function() {
var v1:MovieClip = this;
// increment, test for completion
if ((v1.time += v1.speed)>=1) {
v1.time = 1;
v1.onEnterFrame = null;
// this is where i need some sort of check or to set some var, so I can perform
// other actions with the clip, such as tweening to a different location or size
}
// or start drawing
v1.clear();
v1.lineStyle.apply(v1, v1.style);
for (var i = 0; i<=seg; i++) {
if (!i) {
v1.moveTo.apply(v1, v1.points[0]);
} else {
v1.lineTo.apply(v1, v1.points[i]);
}
}
v1.lineTo(v1.points[seg][0]+(v1.points[nextseg][0]-v1.points[seg][0])*segtime, v1.points[seg][1]+(v1.points[nextseg][1]-v1.points[seg][1])*segtime);
};
};
// draw a square
this.createEmptyMovieClip('mc', 1);
mc.drawShape(50, 50, 150, 20, .02, .25, 0xFFFFFF, 100);
//mc.drawShape(x, y, w, h, speed, stroke, color, alpha);
and this was the original code i had, which worked.. i just found it a pain in the *ss to have to code in all the xpos ypos values to position the clip where i wanted. I want to be able to draw the shape within the mc, and then move it around and tween it an do whatever i need with limited frustration. I also want to be able to draw within clips that already exist.
here is the old code i tried to rewrite (i don't know where or when i got this from, i found it in my files randomly)
Code:
drawShape = function () {
// variables
var seg = Math.min(Math.floor(this.time*this.points.length), this.points.length-1);
var nextseg = (seg<this.points.length-1) ? seg+1 : 0;
var segtime = (this.time-seg/this.points.length)*this.points.length;
// increment, test for completion
if ((this.time += this.speed)>=1) {
this.time = 1;
delete this.onEnterFrame;
}
// draw
this.clear();
this.lineStyle.apply(this, this.style);
for (var i = 0; i<=seg; i++) {
if (!i) {
this.moveTo.apply(this, this.points[0]);
} else {
this.lineTo.apply(this, this.points[i]);
}
}
this.lineTo(this.points[seg][0]+(this.points[nextseg][0]-this.points[seg][0])*segtime, this.points[seg][1]+(this.points[nextseg][1]-this.points[seg][1])*segtime);
};
// draw a square
this.createEmptyMovieClip('mc', 1);
mc.time = 0;
mc.speed = .03;
mc.style = [.25, 0xE2F7D4, 100];
mc.points = [
// [x, y]
[370, 220],
[430, 220],
[430, 280],
[370, 280]
];
mc.onEnterFrame = drawShape;
what am i doing wrong?... anyone see any reason it's not working?...
any help is appreciated...
Simple Function
i have this on frame 1 of a movie:
Code:
function gearMove () {
for (i=1;i<=6;i++) {
_root.["gear"+i].gotoAndPlay(2);
}
}
basically, i want to call this function every time you click a button, this will make the different mc's start animating...
i know that _root.["gear"+i].gotoAndPlay(2); is bad syntax...
so can someone tell me the right way to state it?
thank you...
Help With (simple?) Function
I hope this isn't too much of a bonehead question, but here's the AS I'm having trouble with (which is attached to a slider MC):
onClipEvent (load) {
function onSlide(val){
return(Math.round(val*200)-100);
}
}
onClipEvent (enterFrame) {
xPos=_root.testClip.xPos;
}
I'm trying to take the results of the "onSlide" function and pass them to the "xPos" of the testClip so that the testClip will move in relation to the slidebar.
Thanks in advance to any and all for helping on this one!
Erik
Simple Function Help.
Hello,
1. I have a movie clip called "mve_Home", and I've got a dynamic text field instantiated inside that movie clip named "buttonLabel"
2. On the main time line where this movie clip ("mve_Home") resides I have some function declarations in the first frame.
They are as follows:
------ CODE BEGINS -------
//function definition
mve_Home.onLoad = function() {
this.buttonLabel = "Home";
}
//function call
mve_Home.onLoad();
------ CODE ENDS --------
This code does nothing. My text field does not change, and I do not know why. I might be missing something about function operations within a frame's actions, all on one timeline. Can someone spin me around and tell me what I'm doing so I can walk in the right direction?
Thanks in advance.
Simple Function
I've a simple if statement:
Code:
if (web == "true") {
null;
} else {
getURL("cursor:in");
}
}
how do I put this on a frame function? so when a button is clicked it calls this in?
is that the right way to do it? it wont work straight off a button cos its sending a variable to authorware
Simple Function Q
I must admit I'm a total function newbie, but from what i've picked up so far this should work.
In a frame on my main timeline:
function startthislounge (track) {_root.movieclip[track].gotoAndPlay(2);
...and on an external swf loaded from the main timeline:
_root.startthislounge (lounge10);
...what's wrong with it?
BTW sometimes I see actionscript code posted in what looks like quotes but isn't - how's that done ?
Simple Function
I created this function:
function slotColor(eData:String,clipName:String){
if (eData==1) {
clipName.gotoAndStop("bs");
} else if (eData==2) {
clipName.gotoAndStop("bfs");
} else if (eData==3) {
clipName.gotoAndStop("nbs");
} else if (eData==4) {
clipName.gotoAndStop("nbfs");
}
}
And I am passing its values here:
var ext_data:LoadVars = new LoadVars();
s1_mc.onEnterFrame=function(){
slotColor(ext_data.s1,s1_mc);
};
ext_data.load("status.txt");
FlashMX is giving the following error:
**Error** Scene=Scene 1,
layer=actions,
frame=1:Line 14: There is no method with the name 'gotoAndStop'.clipName.gotoAndStop("bs");
What I am doing wrong? Flash is not "seeing" that my movie clip is created at the time the frame is loaded. I have another function on the same frame. The difference is that on this other function the movie clip is already on the stage.
Simple Function
I am trying to write a simple function on the root timeline that tells a movie clip on that timeline to play. Each movie clip is named sequentially (mc1, mc2, mc3, etc.). I want the function's parameter be the mc's number ( function intro(2);) I have tried this a bunch of ways but it doesn't seem to work. Any help would be appreciated, thanks,
chris
Simple Function
Hi,
I have four MCs on the root timeline, box1, box2, box3, and box4. I want to write an efficient function that says "when box(x), starting with box1, reaches frame 15, play box(x+1) and to stop after box4 plays." I hope I described this well enough. I can make it work but I know I am being really sloppy and cumbersome. Thanks,
ix
Simple Function
On Flash MX:
Hi, I entered this code:
MovieClip.onEnterFrame = function()
{
this._rotate += 5;
};
OK, this function rotates the "MovieClip", but doesn't it should only rotate once (5 degrees)?
It's rotation never stops, I have only 1 frame (I tried to put others, but the result is the same).
Viewing on Flash Player, I stoped "loop", but it keeps rotating.
Thanks for the help!
Regards,
pedro
[AS2] Simple If Function
so i have a dynamic text box on the first frame and it is a display name box, i used this code to load the data to the box and that works fine.
///this code /
var my_so:SharedObject = SharedObject.getLocal("displayname", "/");
_root.disname = my_so.data.txt;
///
Now i want flash to say ok he's been here before, go right on to frame 2 sir, i tried:
if (disname.text == undefined){
gotoAndStop(1);
}else{
gotoAndStop(2);
}
also tried with a false if statment after the else:
}else{
if (disname.length < 1){
gotoAndStop(2);
}
Also added function signin(){ at top aswell with extra } at bottom but none of these work. im gonna guess i need to use a diffrent method becuase im loading in to the dynamic text box aswell and thats what i want to detect.
Thanks in advance Astano
Help With Simple Function
Code:
var i:Number = 1;
function attachM(mov:Number) {
new mx.transitions.Tween([this], "_x", mx.transitions.easing.Strong.easeIn, 0, 70, 1, true);
new mx.transitions.Tween([this], "_alpha", mx.transitions.easing.Strong.easeIn, 100, 0, 1, true);
}
onEnterFrame = function () {
if (i<=20) {
i++;
var moo:MovieClip = attachMovie(mov, mov+i, i);
moo.onEnterFrame = _root.attachM;
trace(i);
}
};
Help With A Simple Function?
ActionScript Code:
function fadeOut(mc, speed) {
mc.onEnterFrame = function () {
if (this._alpha > 0) {
this._alpha -= speed
} else {
this._alpha = 0;
delete this.onEnterFrame;
}
}
}
so i have this code contrlling the fade outs in my movie. just need a little help modifying it.
I want mc to be any variable I call but im not sure how to go about that because its mc.onEnterFrame
for instance, i have a function
ActionScript Code:
var getinfo:Function = new Function (function() {
siteinfo = "map."+district+"."+infotype;
})
so for testing purposes, i made a button call district = "dist1" and infotype = "info1"
i trace siteinfo on another button and its map.dist1.info1, which is a movieclip that i have, and yet when i use fadeOut (siteinfo, 15) i wont do anything, i suppose its looking for a movieclip called siteinfo so how can i make the function accept the variable name??
Some Simple Function Help
Hello everyone,
I've had AS'ing block and I need some help what my problem is im trying to use a function inside a MovieClip from outside of it its litterally inside the movie clip not like saying click to view actionscript on the movieclip but its inside its area how would one use a function inside a frame inside a movie clip outside of it?
One Simple Function
can I write this in one simple function?
container1.onPress = function() {
slide.loadMovie("1.jpg");
}
container2.onPress = function() {
slide.loadMovie("2.jpg");
}
container3.onPress = function() {
slide.loadMovie("3.jpg");
}
container4.onPress = function() {
slide.loadMovie("4.jpg");
}
container5.onPress = function() {
slide.loadMovie("5.jpg");
}
container6.onPress = function() {
slide.loadMovie("6.jpg");
}
tks!
Help With A Simple Function.
Well I am trying to get a silly onResize Stage.addListener full flash browser site to work but content isn't moving when I resize the window.
I have done these before but I never ran into this problem and it is causing headaches. I will attach the FLA... please someone help me figure it out.
How To Draw Premieter Of MC? (using Draw Api)
Hi im trying to work out the perimeter of my mc visually, so I want to be able to draw the perimeter of the mc. I gathere there is use of getBOunds and the lineTo and moveTo methods, but how to use them to draw the boundary im not sure. Can any one help?
Simple Function Call?
Hi guys,
have a very simple problem....i can't call functions????!!!. can tell em what am i doing wrong here??? isn't working....puzzled!
code on main time line
*******************
namevar = "0";
area = 0;
_root.one.name();
_root.one.Circle(10);
trace ("name="+namevar);
trace ("area="+area);
********************
code on the timeline of mc one, instance name is also one
*********************
function name () {
_root.namevar = "mayavi";
}
function Circle (radius) {
this.radius = radius;
this.area = Math.PI*radius*radius;
_root.area = this.area;
}
************************
works fine when function has been defined inside the maintimeline??? is my function reference wrong? what??
cheers
mayavi
Problems With Simple Function
hi there!
in my main timeline i have a mc called "funcMC" and on his first frame i have the function:
function test(){
var1 = "hi ";
trace (var1);
}
when i call this function from the first frame of the main timeline like this:
_root.funcMC.test();
NOTHING HAPPENS!
what do i do wrong? i'd really like to understand the mistery of defining functions...
thanks for any help and peace, kolt
[Edited by kolt siewerts on 11-01-2001 at 11:17 AM]
Simple Function Causes IE To Crash?
Hi evereybody,
I've had a navigation problem wich I solved using an array (asStack) and asfunction.
The function plays an animation in the main timeline, unfolding a window, and then stops to load a movie. Where that movie starts to play is retreived from the "asStack" array.
This all woks fine in the preview, online in Netscape and IE on mac, but in IE on a windows machine it crashes the program. I don't know if this is a hidden leathal combination or something, but it seems to come down to the function.
I uses the asfunction alot with no problms and the array's seem to work fine in other parts so I ran out of ideas.
I used:
<A href= 'asfunction:_root.runRoot,omfi_what'>, to point to the function and
function runRoot (frame) {
asStack.push([frame]);
_level0.gotoAndPlay("gowindow");
}
thanks
Very Simple Function Question
How do?
I'm new to programming of any description and am muddeling through it.
My problem:
I have a load of Functions named "thumb1", "thumb2", "thumb3" through to "thumb33"
Basically I have a variable called "thumb_no" which is an integer.
If "thumb_no" is equal to 7, I want to call the function "thumb8 ()" when clicking on a button.
I have tried stuff like
on (release) {
["thumb"&&thumb_no+1] ();
}
If anyone can help I'd be very grateful (it's no doubt very easy and I'm being stupid).
Tom.
Simple Function Question
Here is the code:
form_mc.onData = function(){
form_mc._visible = false;
};
this is in the first frame on my root timeline. There is a form_mc movieclip in that same frame. in that movieclip is a form that is connected to a php script. when the submit button is clicked the form calls the php script and it returns text that goes into a text box. this all works fine. I want a script that will see the php has passed a variable back to flash and will make the form disappear. I thought this bit of code would work, but it doesn't. any suggestions?
eric
Function Question (simple I Think)
Hey guys,
i have a question about this function that I made. It simulates movement. The way I have it set up is as follows:
function move(movie, location){
movie._x=movie._x+(location._x-movie._x)/10;
movie._y=movie._y+(location._y-movie._y)/10;
}
is it possible, to get those two commands within the function to run over and over again until the movie reaches the location. I tried messing with some while statements but to no avail. Any help would be very much appreciate.d Thanks everyone
Don
Simple Function Problem..
I have this following script to trace my movieclip _x value..
on the root frame i have:
function rope() {
trace(this._x);
}
on the movie clip i have:
onClipEvent (enterFrame) {
_parent.rope();
}
But it give me 0 all the way... where is my mistake?
chup
How To Write A Simple Function?....
Hi,
This may sound completely ridiculous... but could someone please explain to me how to write a simple function. (so that I can get the basic idea of functions and variables..)
Any help much appreciated.
Thanks
Simple Function Question, Anyone Please
Hey, I figure this is simple, but how can I reference local variables in a function relative to the movie that is calling the function? I tried something like this but it didn't work. It just returned "undefined":
function whatever(nameofmovie){
trace (_root[nameofmovie].attribute1)
}
In short, how can I reference a variable that is local to the movie calling the function?
thanks,
greg
|