ActionScript 2.0 :: Using A Switch To Control Drawing Function?

Mar 12, 2004

I need to create a specific drawing sequence that uses multple clicks to arrive at a certain shape.

Basically, I need the user to be able to draw a pie wedge over a bitmap image. The actual drawiing is not the problem right now, what I am struggling with is how to control the action based on how many times the person has clicked.

On the very first click, a temporary line is drawn from the center of the image, and the user can move the mouse around to get the first line where they want.

They click again and the temp line is cleared and the final line is put in place. Then, as they move the mouse off that last end point, I need a new temporary line to automatically generate (this is the second straight side of the wedge). They click a final time and that line locks in place and the wedge completes.

Now, the problem I have is that I am using a switch statement to test the clicks. When the routine starts I've got the var _root.c = 0. Here's the switch:

[AS]switch (_root.c) {
case 0 :
_root.canvasArc.onMouseUp = drawFirstLine;
break;

[Code]....

As you can see I am incrementing _root.c at the end of this. This part works fine (I verified that it is making _root.c = 1), but it seems that by breaking out of the switch statement, it doesn't go back and check anything again, so my case 1 never gets read and the rest of the process can't happen. I tried an if statement and even looped through that with setInterval but that doesn't seem to work either. Is there just a smarter way to do this?

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Add A Parameter To Control The Speed Of Drawing?

Sep 8, 2011

Now it draws a square with normal speed but I would like to customize the speed. How to add a parameter to control the speed of drawing?

Code:
import com.greensock.*;
import flash.events.MouseEvent;
//create line

[Code]....

View 2 Replies

ActionScript 3.0 :: Function To Go To The Next Case On The Switch?

Apr 19, 2010

i have created a switch that assign different case to different toggle  buttons. so when each case is activate, it loads a different swf.so  far it works fine..It's going to be like a sub menu thing, the toggle  button remains activated so viewer know which page they are at right  now..until they click the next toggle button..so on and so on.

[Code]...

View 5 Replies

ActionScript 3.0 :: Run A Function For Every Case In A Switch?

Jan 20, 2009

ActionScript Code:
function changeBox(event:MouseEvent):void {
switch(box.boxclass.whichboxvar) {

[code]......

View 3 Replies

ActionScript 2.0 :: Using Switch Function For Two Variables

Sep 6, 2011

How one would go about switching 2 variables around. For example if I have
Code:
a = 5; b = 3;
Then use the switch function and get:
Code:
a = 3; b = 5;
Is there any such thing?

View 4 Replies

ActionScript 2.0 :: Switch A Function Completely Off

Aug 13, 2007

Just looking at a quick way to turn a Code: object.onRollover = function off and on?

[Code]...

View 6 Replies

ActionScript 1/2 :: MovieClip Control - Drawing Line By Connecting Dots

Oct 7, 2009

I've almost got a bit of flash finished, The .swf so-far is here: [URL]. For some reason the file won't attach but the important bit of code I have so-far is below. I need to make a line to literally 'connect the dots', each of which is one end of a movieclip, I know it needs to boil down to ' line x,y, to (movieclipname)x,y, but cannot work it out!

time.onChanged = function() {
if(time.text.length == 4) {
var hours:Number = parseInt(time.text.substr(0,2),10);
hours *= 60;
var minutes:Number = parseInt(time.text.substr(2,2),10);
[Code] ......

View 3 Replies

Flash5 Using Switch Case To Call Function

Nov 10, 2010

I have a set of switch case conditions. On the last one, i want it to run a function called mainMenu, so i put:

[Code]...

View 2 Replies

ActionScript 3.0 :: Switch Case Does Not Works With Function

Oct 31, 2010

The switch case doesn't works with function. This is the AS3 code:
ActionScript Code:
var med:Number, mdi:String, op:int, tot:String;
bt1.addEventListener(MouseEvent.CLICK,yardas);
function yardas(MouseEvent:Event):void{
op=1
[Code] .....

View 1 Replies

Call An Independent Function From A Switch Case?

Feb 4, 2010

Is it possible to call an independent function from a switch case?

I'm using an instance of the slider component to trigger a variable function via the switch statement.. The compiler throws an error, incorrect number or arguments.[code]...

View 2 Replies

ActionScript 2.0 :: Function For AttachMovie With Switch/Case?

Aug 4, 2011

I have multiple movieclips (ml1, ml2, ml3 and ml4) to which I attach various clips out of the library to. Each movieclip uses a switch statemtent then attaches the appropriate movieclip from the library... so I got thinking, why can't I do a function rather than all this scripting? And I must have had a really long weekend because whatever I try just isn't working. Here's my code at the moment....

Code:
switch (supp1) {
case "bu" :

[code].....

View 2 Replies

ActionScript 3.0 :: Flash Is Flagging All Of The Functions Within The Switch/case Function?

Oct 25, 2010

I keep getting this message from Flash: "Scene 1, Layer 'A', Frame 1, Line 411136: Incorrect number of arguments. Expected 1." and for the life of me, I can't understand why. I simplified the name and number of the buttons called but otherwise the code is intact. Flash is flagging all of the functions within the switch/case function, telling me that an argument is expected there. Why? I've tried the switch/case functionality with other requests (e.g., trace), but I cannot make it run a function.

Code:
var clicked = MouseEvent.CLICK;
country01_btn.addEventListener(clicked, butClicked);
country02_btn.addEventListener(clicked, butClicked);[code]...............

View 8 Replies

ActionScript 3.0 :: Switch Function With Comparison Operators Inside Cases?

May 13, 2011

I'm having difficulties with my switch script. Below is the code:

Code:
public function resultValue():void {
switch (_calcSwitch) {
case 0:
break;

[Code]...

View 5 Replies

ActionScript 3.0 :: Optimize The Code And Make Some Kind Of Switch Case Inside The Function?

Aug 29, 2009

i have many buttons(they are actually movieclips) and for each i made separate listener function.. is it posible to optimize that code and make some kind of switch case inside the function. I don't know how to find out who called the function... is there way to find out. I don't want pass the additional argument with events because it wouldn't be optimization at all.I put only two buttons to reduce code:

Code:
button1.addEventListener(MouseEvent.CLICK, idi);
button2.addEventListener(MouseEvent.CLICK, idi2);
function idi(event:MouseEvent):void {[code]....

View 3 Replies

ActionScript 2.0 :: Drawing A Line In A Function, But Not Solid?

May 16, 2005

I have in a function a line to be drawn. I want the line to be not solid but like this ------. Can I code for that.line4.lineStyle(2,"0000FF",100);

View 4 Replies

ActionScript 3.0 :: Stop A Function In Drawing ( Painting ) App?

Jan 12, 2011

i have a problem with functions, i'm creating a painting app in flash as3. i want to draw two different style a pen and rectangle.

When i draw pen style in first frame there is no problem, but when i click rectangle style in second frame it is drawing with both style. How can i stop or kill other function?

How do I make both of the not drawing. And How can i undo my last action in drawing?

Fla is in the attachement (CS4 version)

in first frame drawing pen;

Code:
var clip : Shape = new Shape();
addChild (clip);
stage.addEventListener(MouseEvent.MOUSE_DOWN, _handleMouseEvent);

[Code]....

View 5 Replies

ActionScript 2.0 :: Drawing A Line In A Function But Not Solid

May 16, 2005

I have in a function a line to be drawn. I want the line to be not solid but [code]

View 4 Replies

ActionScript 3.0 :: Function - Drawing The Polygon Based On The Number Of Sides

Dec 29, 2011

I'm trying to create a function that draws a polygon with two parameters that are: number of sides and length of sides. You would input a number for side length and a number for the number of sides. Then it would draw the side length, then turn at a angle based on the number of sides, then draw side length again... until it has finished drawing the polygon based on the number of sides that were put in.

View 1 Replies

ActionScript 3.0 :: Make A Mouse-drawing Function Which Is Frame Independent?

Sep 8, 2010

i am trying to make a mouse-drawing function which is frame independent (for collision detection).somehow my trigonometry brain part seems to be out of order. fill in the blanks?here is my code so far (simplified):

Code:
mport flash.events.MouseEvent;
import flash.geom.Point;

[code]......

View 0 Replies

ActionScript 2.0 :: Control Function For MC's?

Apr 6, 2004

I have 120 MC's (little squares, names square_01, square_02, etc) around my stage like a frame around a painting. I would like to create an onRollOver/Out effect for these mc's, but it seems a bit much to me to place them all in an array.

The effect have to be that when you roll over the alpha is going to 0 and that on roll out the alpha will be restored to 100. I also would like the effect to be easing. I know how make a function to control the alpha.But I don't know how to continiue from there. I think it has something to do with a (for in) loop witch I tried, without any results.

View 7 Replies

IDE :: Control Multiple MCs With Function?

Nov 26, 2009

I have a keyboard which consists of 26 MCs, named keya, keyb, keyc.... and so on.

I want to create a button that will disable all these buttons at once, but I'm not sure how to express it in actionscript. Basically, I need it to say 'on release, key X (where x = all characters from a to z) _enabled= false;

View 3 Replies

ActionScript 2.0 :: [FMX] Control Function For MC's?

Apr 6, 2004

I have 120 MC's (little squares, names square_01, square_02, etc) around my stage like a frame around a painting. I would like to create an onRollOver/Out effect for these mc's, but it seems a bit much to me to place them all in an array.

The effect have to be that when you roll over the alpha is going to 0 and that on roll out the alpha will be restored to 100. I also would like the effect to be easing. I know how make a function to control the alpha. But I don't know how to continiue from there. I think it has something to do with a (for in) loop witch I tried, without any results.

View 7 Replies

ActionScript 3.0 :: Pencil Tool - Drawing Above A Image But The Drawing Is Below The Picture

Nov 9, 2010

i've tried to simulate a pencil tool, for drawing above a imagem, but the drawing is below the picture. How fix it?

[Code]....

View 3 Replies

ActionScript 3.0 :: Control A Movieclip In A Function?

Aug 14, 2010

I'm doing a simple game. When two objects collide, a function is activated with a movie clip of an animated explosion. I wonder how to do to control this animation so it's played two times? Just a simple for loop?Then another thing, how to create a short delay so that the code don't jump away direct without showing the explosion when there is code like gotoAndStop in the end of the function? Perhaps I also whant a tweeing rotation of the explosion movie clip before leaving the function? In some way it seem like it would be necessary with some delay?

View 0 Replies

ActionScript 2.0 :: Function To Control External Swf?

Jul 21, 2004

I need a function to load and play external swf�s.

I need it to load and play intro.swf into movieclip clip1 , when it is finished load and play about.swf into movieclip clip 2. when this swf has finished load and play outro.swf into clip3. the swfs contains proggressive flv. The function should be as dynamic as possible, cause i need it to control other videoclips in swfs as well.

View 1 Replies

ActionScript 2.0 :: Function To Control External Swf

Jul 21, 2004

I need a function to load and play external swf's.I need it to load and play intro.swf into movieclip clip1 , when it is finished load and play about.swf into movieclip clip 2. when this swf has finished load and play outro.swf into clip3. the swfs contains proggressive flv. The function should be as dynamic as possible, cause i need it to control other videoclips in swfs as well.

View 1 Replies

ActionScript 3.0 :: Generate Drawing API Data From Drawing Object?

Jul 22, 2009

Basically I've got a reasonably complex drawing object in a fla and I want to reproduce it in a class definition using the drawing api. However obviously this is a tedious task, so is there some trick or automated method of doing this?

Last time I needed to do this it was a drawing of an arrow and I ended up writing down x,y,width,height values for everything but this one has curves in it which I don't have experience with drawing anyway.

View 2 Replies

ActionScript 2.0 :: Control A Function From A Button Inside A Mc?

Jan 5, 2009

This is the code for my cycle function on the main timeline:

var intID:Number;
var frame:Number = 0;
function playOn(){
if(frame == 2){

[Code].....

I want my button to clear the function and then stop where it is. Shouldn't this work?

on (release) {
_root.clearInterval(intID);
_root.stop();
}

View 6 Replies

ActionScript 2.0 :: Control Multiple Rollovers From One Function?

Apr 27, 2007

I have been developing an interactive map, part of that has buildings, each is separate movie clip. Each needs to have a bit of stuff happen onrollover and stop onrollout. I have that all working if I code each building separate. Instead of having 60-80 nearly identical blocks of code, is there a way I can consolidate this down to less code. for instance, instead of declaring the name and path of the button I'm rolling over, is there a way for flash to figure that out by getting the name of the current movieclip the mouse is over and then sticking that in the code? here is the code as it is right now:

Code:
var tt2:TooltipBuilding = new TooltipBuilding(0x660000, 0x000000, 0xFFFFFF);
_root.mainMap.mainMap.cateteachingcenter.onRollOver = function() {

[code]......

View 1 Replies

ActionScript 2.0 :: Control - Take The First Value Of An Array After Shuffle Function

Jan 21, 2012

i've a problem about checking array with if statement.. my code is above and i can't see "it works" text on trace. I want to take the first value of an array after shuffle function, and i want to check it with if statement.

[Code]...

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved