addChild: action script

Hello to you all,

I'm drawing a straight line from two normal values a slider, but every time I likely the old right of the slider remains displayed with the new and so on, I tried the removeChild and clear() functions but nothing is fixed. Thanks for helping me!

ONE of this code:

import fl.events.SliderEvent; import fl.controls.Slider; import flashx.textLayout.formats.Float; import flash.display.Shape;   //uOutPut.text = "U = 0"; //uSlider.value = 0; //rSlider.value =0;  var resistance:Number; var tension:Number; var myShape: Shape = new Shape(); var tension_var:Number; var resistance_var:Number;  tension_var =0; resistance_var=0; addChild(myShape);  uSlider.addEventListener(SliderEvent.CHANGE,uSliderReseize);  function uSliderReseize (event:SliderEvent):void{                 if (resistance >= 0){           if (tension>=0){      myShape.graphics.lineStyle(3, 0xFF0000, 100);      myShape.graphics.moveTo(465.15 , 380.35 - tension*35);      myShape.graphics.lineTo(465.15 +5*resistance     , 380.35); }     } else {      myShape.graphics.lineStyle(3, 0xFF0000, 100);      myShape.graphics.moveTo(465.15 , 380.35 - tension*35);      myShape.graphics.lineTo(750     , 380.35 - tension*35); }      uOutPut.text = "U = "+event.target.value + " V";      tension = event.target.value; }    rSlider.addEventListener(SliderEvent.CHANGE,rSliderReseize);  function rSliderReseize (event:SliderEvent):void{                 if (resistance >= 0){           if (tension>=0){      myShape.graphics.lineStyle(3, 0xFF0000, 100);      myShape.graphics.moveTo(465.15 , 380.35 - tension*35);      myShape.graphics.lineTo(465.15 +5*resistance     , 380.35); }     } else {      myShape.graphics.lineStyle(3, 0xFF0000, 100);      myShape.graphics.moveTo(465.15 , 380.35 - tension*35);      myShape.graphics.lineTo(750     , 380.35 - tension*35); }      rOutPut.text = "r = "+event.target.value + " Ω";      resistance = event.target.value; }

And here a picture illustrating the problem:

import fl.events.SliderEvent; import fl.controls.Slider; import flashx.textLayout.formats.Float; import flash.display.Shape;

uOutPut.text = "U = 0";//uSlider.value = 0;//rSlider.value = 0;
var strength: Number; var voltage: Number; var myShape: Shape = new Shape (); var tension_var:Number; var resistance_var:Number;
tension_var = 0; resistance_var = 0; addChild (myShape);




uSlider.addEventListener (SliderEvent.CHANGE, uSliderReseize);
function uSliderReseize (event: SliderEvent): void { if (resistance > = 0) { if (blood pressure > = 0) { myShape.graphics.lineStyle (3, 0xFF0000, 100); myShape.graphics.moveTo (465.15, 380.35 - voltage * 35);}}} myShape.graphics.lineTo (465,15 + 5 * resistance , 380.35) ;} { } else { myShape.graphics.lineStyle (3, 0xFF0000, 100); myShape.graphics.moveTo (465.15, 380.35 - voltage * 35);} myShape.graphics.lineTo (750 , 380.35 - voltage * 35) ;} = uOutPut.text ' U = ' + event.target.value + 'V '; voltage = event.target.value ;}

rSlider.addEventListener (SliderEvent.CHANGE, rSliderReseize);
function rSliderReseize (event: SliderEvent): void { if (resistance > = 0) { if (blood pressure > = 0) { myShape.graphics.lineStyle (3, 0xFF0000, 100); myShape.graphics.moveTo (465.15, 380.35 - voltage * 35);}}} myShape.graphics.lineTo (465,15 + 5 * resistance , 380.35) ;} { } else { myShape.graphics.lineStyle (3, 0xFF0000, 100); myShape.graphics.moveTo (465.15, 380.35 - voltage * 35);} myShape.graphics.lineTo (750 , 380.35 - voltage * 35) ;} rOutPut.text = "r =" + event.target.value + "Ω"; resistance = event.target.value ;}

use:

myShape.graphics.clear)

to delete a drawing.

Make sure your drawing methods is inside your cursor to change listener function if they use values from the sliders.

Tags: Adobe Animate

Similar Questions

  • I'm on a W7 PC, of FlashProCC. -Have a Z1, jpg in the library. Choose Properties, export for ActionScript and get name Z1, class flash.display.BitmapData - how I introduce in a display by using Action Script 3.0 object?

    I'm on a W7 PC, of FlashProCC. -Have a Z1, jpg in the library. Choose Properties, export for ActionScript and get name Z1, class flash.display.BitmapData - how I introduce in a display by using Action Script 3.0 object?

    var z1:Bitmap = new bitmap;

    Z1. BitmapData = new Z1 (1,1);

    yourDisplayObject.addChild (z1);

  • Chess in action script

    Hey there :-)

    I had a little problem with actionscript. I want to leave my chessboard fade from lack of transparency to 100% transparency and I need to do this in action script... i have tried in many ways via greensock etc can anyone help me? Thank you here is my code:

    import com.greensock;

    com.greensock.plugins import. *;

    TweenPlugin.activate ([TintPlugin]);

    var Schachbrett:Array = new Array();

    for (var i: int = 0; i < 4; i ++)

    {

    Schachbrett.push (new Array ("1,0,1,0,1,0,1,0"));

    Schachbrett.push (new Array ("0,1,0,1,0,1,0,1"));

    }

    var taille_unite: int = 60;

    function baueSchachbrett (): void

    {

    for (var i: int = 0; i < Schachbrett.length; i ++)

    {

    for (var j: int = 0; j < Schachbrett [i] .length; j ++)

    {

    var tile: Sprite = new Sprite();

    var tileColor:int = [i] [j] Schachbrett * 0xffffff;

    tile.graphics.beginFill (tileColor);

    tile.graphics.drawRect (0, 0, taille_unite, taille_unite);

    tile.graphics.endFill ();

    Tile.Name = ("tile__" + i + "_" + j + ", _sp");

    tile.addEventListener (MouseEvent.CLICK, klick);

    Tile.x = j * taille_unite;

    Tile.y = i * taille_unite;

    addChild (tile);

    }

    }

    }

    import com.greensock;

    com.greensock.plugins import. *;

    TweenPlugin.activate ([TintPlugin]);

    var schachbrett:Sprite = new Sprite();

    addChild (schachbrett);

    Schachbrett.Alpha = 0;

    var Schachbrett:Array = new Array();

    for (var i: int = 0; i< 4;="">

    {

    Schachbrett.push (new Array ("1,0,1,0,1,0,1,0"));

    Schachbrett.push (new Array ("0,1,0,1,0,1,0,1"));

    }

    var taille_unite: int = 60;

    function baueSchachbrett (): void

    {

    for (var i: int = 0; i< schachbrett.length;="">

    {

    for (var j: int = 0; j< schachbrett[i].length;="">

    {

    var tile: Sprite = new Sprite();

    var tileColor:int = [i] [j] Schachbrett * 0xffffff;

    tile.graphics.beginFill (tileColor);

    tile.graphics.drawRect (0, 0, taille_unite, taille_unite);

    tile.graphics.endFill ();

    Tile.Name = ("tile__" + i + "_" + j + ", _sp");

    tile.addEventListener (MouseEvent.CLICK, klick);

    Tile.x = j * taille_unite;

    Tile.y = i * taille_unite;

    schachbrett.addChild (tile);

    }

    }

    TweenLite.to(schachbrett,1,{alpha:1});)

    }

  • Action Script 3 Drag &amp; Drop

    Hello

    I've been following a Lynda tutorial to generate a simple drag and drop game in Flash CS5, using ActionScript 3 and met with what I'm sure that someone will be a simple problem to solve. I got to the stadium where I have video clips 10 and 10 on _target areas to drop these clips, they then snap into the right area.

    My problem is that I have a meter running in the background that counts the number of correct conversions; what I want is when all 10 points fell in the right zone (_target relative), a line of Action Script will be executed, now for this example, I would like to bring the Alpha of a textfield/clip on 0-1 scene, showing a message of victory.

    Here is my code so far, I use external classes for the process of what drag / move.

    The grid class:

    package
    {

    import flash.display. *;
    import flash.events. *;


    Grid/public class extends MovieClip
    {
    var dragdrops:Array;
    var numOfMatches:uint = 0;


    public void Grid()
    {
    the constructor code
    dragdrops = [moneya moneyb, moneyc, moneyd, moneye, moneyf, moneyg, moneyh, Anil, moneyj];
    var currentObject:DragDrop;
    for (var i: uint = 0; i < dragdrops.length; i ++)
    {
    currentObject = dragdrops [i];
    currentObject.target = getChildByName (currentObject.name + "_target");

    }
    }

    public void match (): void

    {
    numOfMatches ++;
    if(numOfMatches == dragdrops.) Length)
    {
    HERE, it IS WHERE I want TO PUT the ALPHA CODE
    }
    }

    }

    }

    Class DradDrop:

    package
    {
    import flash.display. *;
    import flash.events. *;

    SerializableAttribute public class DragDrop extends Sprite
    {

    var origX:Number;
    var origY:Number;
    var target: DisplayObject;

    public void DragDrop()
    {
    the constructor code
    origX = x;
    origY = y;
    addEventListener (MouseEvent.MOUSE_DOWN, drag);
    buttonMode = true;
    }

    function drag(evt:MouseEvent):void
    {
    stage.addEventListener (MouseEvent.MOUSE_UP, drop);
    startDrag();
    parent.addChild (this);
    }

    function drop(evt:MouseEvent):void
    {
    stage.removeEventListener (MouseEvent.MOUSE_UP, drop);

    stopDrag();

    If (hitTestObject (target))
    {
    Visible = false;
    Target.Alpha = 1;
    Object (parent) match ();
    }

    x = origX;
    y = origY;
    }

    }

    }

    Any help would be great.

    use:

    package
    {

    import flash.display. *;
    import flash.events. *;

    Grid/public class extends MovieClip
    {
    var dragdrops:Array;
    var numOfMatches:uint = 0;

    public void Grid()
    {
    the constructor code


    dragdrops = [moneya, moneyb, moneyc, moneyd, moneye, moneyf, moneyg moneyh, Anil, money j];
    var currentObject:DragDrop;
    for (var i: uint = 0; i< dragdrops.length;="">
    {
    currentObject = dragdrops [i];
    currentObject.target = getChildByName (currentObject.name + "_target");
       
    }
    }
     
    public void match (): void
     
    {
    numOfMatches ++;
    if(numOfMatches == dragdrops.) Length)
    {

    Use a dynamic textfield you can assign an instance name (for example, tf) and use:
    TF.alpha = 1;
    }
    }
     
    }

    }

    Class DradDrop:

    package
    {
    import flash.display. *;
    import flash.events. *;

    SerializableAttribute public class DragDrop extends Sprite
    {
     
    var origX:Number;
    var origY:Number;
    var target: DisplayObject;

    public void DragDrop()
    {
    the constructor code
    origX = x;
    origY = y;
    addEventListener (MouseEvent.MOUSE_DOWN, drag);
    buttonMode = true;
    }
     
    function drag(evt:MouseEvent):void
    {
    stage.addEventListener (MouseEvent.MOUSE_UP, drop);
    startDrag();
    parent.addChild (this);
    }
     
    function drop(evt:MouseEvent):void
    {
    stage.removeEventListener (MouseEvent.MOUSE_UP, drop);
      
    stopDrag();
      
    If (hitTestObject (target))
    {
    Visible = false;
    Target.Alpha = 1;
    Object (parent) match ();
    }
      
    x = origX;
    y = origY;
    }

    }

    }

  • How to create the object rectangular box with a pure action script.

    How to create the object rectangular box with a pure action script?

    I think, it can be done through the clip library, but I'm not sure. Please, I want to take the suggestion to create a rectangular box as a script through

    Take a new file and write about the first image the code below, it works fine:

    var rect = new Shape();
    rect.graphics.beginFill (0xFF0000);
    rect.graphics.drawRect (0, 0, 100,50);
    rect.graphics.endFill ();

    var MC = new MovieClip();
    mc.addChild (rect);
    addChild (mc);

    If this doesn't solve your problem then paste the error you get

  • I try to install an air 320u sierra wireless card and I get an error message "could not access vb run time for custom action script. Cannot install the Manager of mobile broadband services.

    could not access vb run time for custom action script

    I try to install an air 320u sierra wireless card and I get an error message "could not access vb run time for custom action script.  Cannot install the Manager of mobile broadband services.  Any ideas?

    Hello

    I suggest you run the fixit and see if it helps:

    http://support.Microsoft.com/mats/Program_Install_and_Uninstall

    Also check out this link:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-windows_programs/error-2738-could-not-access-VBScript-run-time-for/1a4499ae-8bc1-4534-9c6f-4d399ac70d9a

    It will be useful.

  • After you create the action script for the creation of user Oracle DB - connector DBUM

    Hello

    After we have set up a user of IOM in the database on the target system, you must insert the same user in the RLS_USER_GROUPS table. (INSERT INTO CAMPDB. The VALUES of RLS_USER_GROUPS ('DV < user name >', RLS_DEV');  )

    The requirement is available to the user of multiple databases (different values of SID). But, the user to insert in a table to a database (DB1).

    If I write an after create a file of Action with action script, it will fire for all databases?  How to trigger this script only on the DB1 database?

    (2) in the literature, it is mentioned as below

    (Q) I installed the connector only in IOM (there is no connector server). Thus, in the 3rd and 5th stage, what should I mention

    Key code?

    Decode?

    Please suggest

    Thank you

    This query has worked well.

    INSERT INTO CAMPDB. RLS_USER_GROUPS (USERNAME, GROUPNAME) VALUES ({__NAME__}, "RLS_DEV")

  • I need help on the matrix of action script 3.0

    I need help on the matrix of action script 3.0

    [Ask in the correct forum allows... Left non-technical Forum Lounge for forum specific program... MOD]

    to apply a matrix for mc mat oppose:

    var mat: Matrix = new Matrix;

    mat.a = Whatever;

    mat.b =

    mat.c =

    mat.d =

    mast. TX =

    mat.Ty =

    MC. Transform.Matrix = Matt;

  • Action Script to add a node value parent for the top node

    I need to add a new value of the node parent to a hierarchy to the top node.  The script parameters to add a node is "Add | Version | Hierarchy | Node | Parent Node. Property sheet. "  I am at a loss on what to do for the top node because there is no node Parent above this level, but the settings ask him.  I have reviewed the manual and the manual of admin, but did not help.  Can someone help me?

    Thank you!

    You have the answer with you, do not be confused between the Parent node and the top node context, when adding a new node, the node of your Top will become your Parent node.

    ' Add | Version | Hierarchy | Node | Parent Node. Property of the worksheet.

    If you're still confused, just do the following.

    1. right click on the node of your top and add a new worksheet or node branch manually

    2. Once added, go back to the homepage-> Script

    3. Select the Type of Source in the paper transactions, and then select the newly added node and load

    4. in the lower part select Script-> download-> Download Action Script.

    5. open in a Notepad and use to create your new script.

  • Convert a HTML5 canvas 3.0 action script?

    Hello world

    I made an animation in HTML5 to realize now that I should have used action script 3.0. Is there a way to convert the document or move all my layers and images to a new document action script 3.0?

    Thank you.

    Copy / paste works, but also look at the menu of commands. Here, you can change other document formats.

  • Is it possible to group objects, which are placed in the project and then hide them with line a single action-script? THX in advance, Philip

    I work in CP 9 and I'm going to try the following: the user must be able to make ALL invisible or visible to highlight boxes by clicking on the corresponding button on the first page layout. Thus, for example, if the user does not want the highlight boxes appear, click on "Hide the boxes" and boxes are hidden for the rest of the project. I managed to get to this point for help... but it is still a lot of work for me to manually enter all the different names of these boxes in the action-script. So my question is: is it possible to group objects, which are placed in the project and then hide them with line a single action-script? THX in advance, Philip

    Actually... releasing the CpExtra HTML5 widget, it will be possible.

    It has a function called @syntax that allows you to perform an action (for example HIDE) automatically on any object throughout a project of Cp9 simply based on the name of the object.

    So for example, if you named all the boxes to highlight you want hidden this way to have the suffix _HideMe and you say CpExtra you want all of them hidden if a user variable is assigned to a certain value, then that is what will happen.

    That's the good news.  The bad news is that the widget is still in BETA final tests at the moment, so you may need to wait a bit before you can realize your idea.

  • the path to import actions (script)

    I received a few actions (scripts) extencion .atn to a join a friend the old version of Ps, there was a simple way to import them in Ps, but Ps cc version in 2014 no way. But in my opinion they must be a way with the finder to search for the folder where to put them.

    Y at - there someone who can help me with this problem.

    THX.

    Actions or Scripts?

    The files are clearly named "Actions" and "Scripts" in the English installation at least.

  • How a beginner can learn Action Script?

    I don't have a technical background, but I've been addicted to Flash for 2 years.  Where can I find really Action Script?  (Should I be worried?)

    If you have trouble is a good question.

    I think you'd be better to learn javascript if you're thinking about 10-40 years from now.  JavaScript been around and looks like he will stay longer than actionscript.

    However, actionscript and javascript are very similar so if you want to use flash learning you earn will be widely applicable to javascript.

    For more ActionScript, use the help files adobe and tutorials of senocular (senocular.com).

  • Flash action script 3 settings

    How can I change the 3 action script settings? I want to make sure the default scene dimensions are different.

    This isn't really an Actionscript parameter. Open the Properties window for the movie, be sure that it says, 'Document' at the top of the window. In the Properties section, select the icon for key to the right of the dimensions of the stage. Which opens a new window. Here, you can define a new default step size, and then click make default in the lower left corner.

  • Action scripts when the PDF opens in the browser

    I may be in the wrong forum or can answer this question already

    I think that the answer will be no. but thought I would ask

    I use Adobe Pro and our institution as a whole has a license for Adobe Pro

    I wrote a script of Action that retrieves certain pages of a document package, some of them emails, records some of them and destroy them before that parts of the package that need signed are printed

    Here's my number

    We have Adobe Pro xi

    Windows 7

    THAT IS TO SAY 10

    The formula in question is generated from a browser application. All employees have the ability to go into tools - manage add-ons - and enable or disable Adobe Reader

    Mine is always disabled

    Several members of the staff have it turned on and open the document in the browser

    -so far all document javascripts I have written have worked anyway

    Action script though - I can't call when I go and activate Adobe Reader as the only elements that show to the staff's signature and comments form. The 'Tools' option is not there, and this is where my action script.

    I could force the staff to open in PDF format - but they won't be happy if I force this option

    is far from having the tools - and so my action script work if they open the PDF file in the browser?

    I guess I could try to do all the action script code in a JSButton if this is not possible, but action script allowed me to break the code into the section

    Thank you

    Acrobat/Reader install a limited Player plug-in and allows only some features that allow to interact with the file PDF is displayed in the browser for playback and recording. It does not features.

    If you need this plug-in, save the PDF file on the local system, and then open the saved PDF file.

Maybe you are looking for