Animate a symbol on the stage using a JS function

Lets say I want to animate SampleSymbol to the right, the following code is placed in the CLICK trigger for a button, my understanding is the best way to liven things up is to write JS functions in Action panels, is - this?

The following line fails animate the SampleSymbol placed on stage...

moveToRight();

function moveToRight() {}

SYM. $("SampleSymbol").style.left = (sym. $("SampleSymbol").style.left + 1) + 'px ';

This code supposed to move the object 1px right

setTimeout(moveToRight,20); / / call function() in 20 msec

}

Hi, check-

In fact, I would say that the best practice is to animate on the timeline and code to call the animations of the reserve.  Personally, I only animate with code, when there is absolutely no other way to get what I want.  In regards to your code, some of the syntax is incorrect, but instead of doing things in this way, you can use jQuery to animation method of:

SYM. $("SampleSymbol") .animate ({left: ' 20px +='}, 20);

http://API.jQuery.com/animate/

-Elaine

Tags: Edge Animate

Similar Questions

  • Add the symbol to the stage based on string of symbols

    Hello

    I am the string to add a symbol on the stage based on a string value in an existing symbol which is on the stage. I get no error when the game turns, but the symbol just reproduce on stage. I have no idea why

    This is the code:

    Variables used

    var score: int = 0

    var startX:int = stage.stageWidth = 920

    var startY: int = stage.stageWidth = 475

    Check to see if the "partition" amounts to 350 in ScoreBoardDisplay.txtScore.text

    If (ScoreBoardDisplay.txtScore.Text == String (350))

    {

    var HD1 = new HealthDrop();

    HD1.x = stage.stageWidth = startX

    HD1.y = stage.stageHeight = startY

    stage.addChild (HD1);

    HealthDrops.push (HD1)

    }

    Assuming you do not penetrate into this framework, when you check the score, but are always there, or at least hang out for a while, the problem is that the conditional code that you show only will run once, immediately entering into this framework.  He is not sitting it monitor any changes in the value of the text field.  You must specify the code to run.

    In this case what you could do is to place this code in a function that runs whenever the textfield value is changed.

    This code that you have to change the value of the TextField?

  • JSON content - click here to see another symbol on the stage

    Hello

    Thanks Zaxist, I have a code of work similar to that below:

    $.getJSON ("content.json",

    {function (Data)}

    for (var i = 0; i < data.length; i ++) {}

    var s = sym.createChildSymbol ('template', 'content');

    s.$("title").html (Data [i] .title);

    s.$("description").html (Data [i]. Description);

    s.$("Seira").html (Data [i]. Seira);

    s. $("imageholder") .css ({'background-image': "url ('" + data [i].) "}) (image_+_«_'_»)});

    .data s. $("imageholder") ("Great", data [i] .largeimage);

    s.. Click$ ("imageholder") ("click", Function {}

    sym.getComposition () .getStage ().$("finte").css ({'background-image': ' url ("+ .data ('l arge') $ (this) + ') '});

    });

    }

    });

    Now, I'm trying on the click function to show the display symbols on the stage, for example during the click on the first point, the red symbol will appear, so cliked the second element of the (previous symbols which appeared will be hidden) and the new blue symbol will appear. So on with all the other ellements with JSON files.

    I tried this on the code, but nothing:

    $.getJSON ("content.json",

    {function (Data)}

    for (var i = 0; i < data.length; i ++) {}

    var s = sym.createChildSymbol ('template', 'content');

    s.$("title").html (Data [i] .title);

    s.$("description").html (Data [i]. Description);

    s.$("Seira").html (Data [i]. Seira);

    s. $("imageholder") .css ({'background-image': "url ('" + data [i].) "}) (image_+_«_'_»)});

    .data s. $("imageholder") ("Great", data [i] .largeimage);

    s.. Click$ ("imageholder") ("click", Function {}

    sym.getComposition () .getStage ().$("finte").css ({'background-image': ' url ("+ .data ('l arge') $ (this) + ') '});

    If (data [i] = 3) {}

    sym.getComposition () .getStage ().$("red").show ();

    }

    else {}

    sym.getComposition () .getStage ().$("red").hide ();

    }

    If (data [i] = 5) {}

    sym.getComposition () .getStage ().$("blue").show ();

    }

    else {}

    sym.getComposition () .getStage ().$("blue").hide ();

    }

    });

    }

    });

    Could you help me?

    Thanks in advance!

    Well, if I have understood correctly, you want to check your image index, and the index was 3 or 5 show you a symbol appropriate for this...

    I want to tell you something before I tell you how you can do this:

    data [i] is your index of json files that return data from your json file not a number, and if your json file is something like this:

    [

    {"image": "images/toy - B.jpg",}

    "title": "1st Image."

    'Names': 'toy-B '.

    }

    ]

    (I'm looking for purpose of json that have index 0) means of data [0]

    Well in this address, we have an object, but no data! because it has not itself data say witch we want, so it just return a data unreadable (just object), so if we say

    Image Data [0] (now we have image data and this will return us Images/toy - B.jpg )

    so we cannot simply say that [i] data

    you need to do this way:

    .data s. $("imageholder") ("Great", data [i] .largeimage);

    s. $("imageholder") .data ('myIndex', i); We need another variable to save our index

    s.. Click$ ("imageholder") ("click", Function {}

    sym.getComposition () .getStage ().$("finte").css ({'background-image': "u rl (" + $(this).data('Large') + ")"});

    If ($(this) .data ("myIndex") == 3) {/ / read value right and check}

    sym.getComposi () .getStage ().$("blue").hide () ing;

    sym.getComposition () .getStage ().$("red").show ();

    }

    ElseIf ($(this) .data ("myIndex") == 5) {}

    sym.getComposi () .getStage ().$("red").hide () ing;

    sym.getComposition () .getStage ().$("blue").show ();

    }

    });

    }

    });

    also, you wrote your statement if and else in an improper way, learn the right way at the top for future use

    If you have any question do not hesitate to ask

    Zaxist



  • Dynamically set the order of the symbols on the stage?

    Is it possible to change the order of the symbols on the stage dynamically via the coding?

    While clicking on a button would be a symbol on the back?

    The reason why I ask is because even if one of my symbols is set to invisible, it still hinders my ability to click on the buttons that are technically below.

    Any help would be appreciated.

    Thank you

    You can use the z-index with this basic format:

    SYM. $('NomSymbole') .css ({' z-index': 100 '});

  • Make subtle tweaks to the similar symbols on the stage

    Let's say I have create a symbol of a stick figure holding a shield.

    Symbol 1: The Stick man

    Side 2: The shield

    Side 3: the Stick man holding the shield.

    Now, how would it be possible to place multiple copies of a symbol on the stage 3 while making subtle tweaks for EACH symbol on the stage 3.

    Is this possible?

    Let's say I want to make each stickman slightly a different color, without each unique stickman taking the same color.

    So I want to side 2 (the shield) a slightly different color in each of the stickman.

    How could I do all of this subtle adjustment without making each symbol instance 1 and 2 on the scene. Is this possible in flash? It seems that flash has so much power, but I still have to figure out how to use it, and I really hope that something like this is possible.

    If I need to explain what I mean, of course I will take the time to do it, but if someone could help me here, that would be much appreciated.

    Here is an example of what I was trying to describe you: http://www.ddg-designs.com/downloads/stick.zip . I have two instances of the same figure on the stage. I put a value of color transformation for the shield of one of these bodies. Shield of the other figure remains unchanged.

    If you double-click any figure given on the stage and then double-click on the shield of this figure and change the color, you change the color of the original symbol, and if all instances of this shield in each figure on the stage will be changed. Leaning on the transformation of color to an individual instance in an instance unique figure on the stage, you are able to change one and not all of the shields.

  • Find the number of symbols on the stage

    Hello

    I'm trying to find out how much of symbols with a certain naming convention is on the scene. The name of these symbols are incremented by 1, if for example I have symbols "drag_1" & "drag_2" currently on the stage and I want to go back to how many symbols "drag_" is on the scene. This can change depending on how much of these symbols that the user adds to the scene.

    I have included some pseudo-code below to help understand what I'm talking about!

    for (var i = 0; i < 100; i ++) {}

    If (SYMBOL_ON_STAGE = "drag_" + i) {}

    number_of_symbols = number_of_symbols + 1

    }

    }

    Thanks for any help!

    You can use

    var childSymbols = sym.getChildSymbols ();

    var num = 0

    for (var i = 0; i)<>

    var reg = new RegExp(/Stage_drag_*/);

    {if (Reg.test (childSymbols [i] .getSymbolElementNode (USER.USER)))}

    NUM ++;

    }

    }

    Alert (num);

  • Reset button for all the chronologies of symbol on the stage

    I have several slideshows in my animated document, and I have three buttons at the top of the document that a user can click. Each button calls some slide shows (which are symbols) and brings them to animate using sym.getComposition () .getStage ().getSymbol("mySymbol").play. It works fine, but as soon as I click a different button, the symbols that the other button activated keep animating.

    I know that I can reset the timelines for symbols referencing each slide show by name individually, but y at - it an easier way? I have so many symbols!

    Thanks in advance!

    Erik

    You can also use getChildSymbols(), which gives you a table of references of the symbols of your scene.  Here is a brief sample, which uses the same code of sample of the API to animate:

    https://creative.Adobe.com/share/b2c57450-5bc6-41d7-ACF6-8aac9a84456a

    This code would be a bit more generic and would not involve to maintain a list of objects.  Please note that this applies only to symbols that are currently on your scene, dynamically declared or not.

    I hope this helps!

    -Elaine

  • How to remove all symbols within a symbol on the stage?

    Hi all

    I have this code located on the close button click:

    var childSymbols = sym.getSymbol("mc_InnerStage").getChildSymbols ();

    Alert (childSymbols.Length);

    for (var i = 0; i < childSymbols.length; i ++) {}

    childSymbols [i] .deleteSymbol ();

    }

    SYM. Stop ("Start");

    which could remove all the symbols inside the symbol (mc_InnerStage), but it does not everyone knows what is wrong with this code? I had alerted the number of children, but it keep giving me 0 any number of symbols in the symbol of the mother there? ! can someone help me please?

    Thanks in advance.

    and I forgot to say that you can remove them by using this line:

    SYM. $(". Name of your class here"). remove();

    Zaxist

  • Retrieve the names of the measures of the stage using LabVIEW

    How retrieve you the names of the measures a digital multiple of the step using LabVIEW?

    I have built a vi to be called TestStand and will pass the "ThisContext', but the vi is not complie.  That's how far I got.  The vi is attached.  The error message is:

    "The method selected in the invoke node is invalid or no method has been chosen.  Click on the invoke node and select a method. »

    My vi is an attempt to write the code of

    Normal
    0

    fake
    fake
    fake

    MicrosoftInternetExplorer4

    / * Style definitions * /.
    table. MsoNormalTable
    {mso-style-name: "Table Normal";}
    MSO-knew-rowband-size: 0;
    MSO-knew-colband-size: 0;
    MSO-style - noshow:yes;
    "mso-style-parent:" ";" "
    MSO-padding-alt: 0 to 5.4pt 0 to 5.4pt;
    MSO-para-margin: 0;
    MSO-para-margin-bottom: .0001pt;
    MSO-pagination: widow-orphan;
    do-size: 10.0pt;
    do-family: "Times New Roman";
    MSO-ansi-language: #0400;
    mso-fareast-language: #0400;
    mso-bidi-language: #0400 ;}

    message.ID = 10653 in LabVIEW.  More precisely:

    Normal
    0

    fake
    fake
    fake

    MicrosoftInternetExplorer4

    / * Style definitions * /.
    table. MsoNormalTable
    {mso-style-name: "Table Normal";}
    MSO-knew-rowband-size: 0;
    MSO-knew-colband-size: 0;
    MSO-style - noshow:yes;
    "mso-style-parent:" ";" "
    MSO-padding-alt: 0 to 5.4pt 0 to 5.4pt;
    MSO-para-margin: 0;
    MSO-para-margin-bottom: .0001pt;
    MSO-pagination: widow-orphan;
    do-size: 10.0pt;
    do-family: "Times New Roman";
    MSO-ansi-language: #0400;
    mso-fareast-language: #0400;
    mso-bidi-language: #0400 ;}

    Dim MyStep ACE [step]
    Dim MyMeasurement As PropertyObject

    MyStep =
    seqContext.AsPropertyObject.GetPropertyObject ("Step", 0)
    MyMeasurement =
    MyStep.AsPropertyObject.GetPropertyObject ("Result.Measurement [0]", 0 ")

    MsgBox (MyMeasurement.Name)

    Can someone help me complete the vi?

    Thank you

    Thank you very much.

    A small change to the vi required.

  • Count the number of symbols on the stage

    It is possible to count the number of symbol on the composition and store it in a variable?

    symbolCount = 0;

    var childSymbols = sym.getChildSymbols (); for (var i = 0; i)

    symbolCount ++;

    Alert (symbolCount);

    Add to the compositionReady, loops through the child symbols and alerts and how they are.

  • call a symbol on the stage of the nested symbol

    sym.getComposition () .getStage ().getSymbol("mySymbol").hide ();

    and it does not work!

    What I am doing wrong?

    Try this:

    sym.getComposition () .getStage ().$("mySymbol").hide ();

  • Compaction generically of the paintings using a test function

    Is it possible to do the following (or at less that kind of thing in the box) generically. Is there a name for this algorithm?

    Essentially, I want to reduce a picture to just elements that pass a test. The test may be just another array of Boolean values that indicate whether or not the table has passed the test. I feel like I'm writing you this code and it bothers me that I write it so well.

    Thank you!

    What version of LabVIEW are you using?

    If you use 2012, there is a conditional index on exit tunnels (right click on the tunnel to configure).  This would eliminate the need for the second loop.

    If you are using an older version, OpenG has a 'conditional index' VI that will perform the action that you have in your box (the second loop).

  • How to insert the value of the variable using select statement - function Oracle

    Hello

    I have a function that inserts the record based on a condition


    INSERT IN the case
    (
    Case_ID,
    Case_Status,
    Closure_Code,
    Closure_Date
    )(
    SELECT newCaseID,
    caseStatus,
    Closure_Code,
    Closure_Date,
    CASE
    WHERE Case_ID = caseID
    );

    Now, I want the new value casestatus instead of value caseStatus select statement. I have a m_caseStatus variable and I want to use the value of this variable in the select statement above.
    How can I use this.


    Thank you
    INSERT INTO Case
    (
    Case_ID,
    Case_Status,
    Closure_Code,
    Closure_Date
    )(
    SELECT newCaseID,
    m_caseStatus,  <-- here place your variable
    Closure_Code,
    Closure_Date,
    FROM Case
    WHERE Case_ID = caseID
    );
    

    Nicolas.

  • How to read a label on the stage of in a symbol

    Hi Edgefriends,

    I'm working on a side project lead, but I have zero experience with JavaScript and I can't seem to get this to work without him so I hope someone can help me to achieve this.

    Below you see the code that I need help. It is part of a symbol on the stage. What I need to do is to play a label ("subFontsTitels") located on the level of the stage. I tried a lot of posibilities but without (good) results. Could you please help me?

    Part of the code:

    Symbol.bindElementAction (compId, NomSymbole, "${_Button} ', 'click', function (sym, e) {})

    read the chronology of the given position (ms or label)

    sym.getComposition () .getStage ().sym.play ('subFontsTitels');

    Insert the code for the mouse, click here

    });

    End of binding edge

    Hi, Rangata01-

    You're close enough.  Tell him in your symbol:

    useful only if your symbol is a level down

    sym.getParentSymbol () ("myLabel") .play;

    can be used any level

    sym.getComposition () .getStage () ("myLabel") .play;

    Hope that helps,

    -Elaine

  • symbol of the editing stage

    I am a very new newbie, so please forgive me if I use enough right words to describe my problem. I'm going through the tutorial from lynda.com on Flash Pro 8, and I'm in the chapter on the symbols. The instructor has described two ways to access the coast to change when you're in the scene mode: double click on the symbol in the library (which works wonders for me) or double-click the symbol on the stage (which did nothing for me). Is this strange? Is - this disturbing? I'll miss all the fun because I can not do this? If anyone else has experienced this? It works for someone else who uses a Wacom Tablet?

    Thanks for the ideas there ' All can provide!

    ~ Valerie

    -The first thing, make sure you have the selection tool and not the Subselction tool. The selection tool is a black arrow, while the subselect tool is a white arrow. You can access this tool in your Control Panel tool, located on the left side of the screen, or pressing the key "v" on your keyboard, while that in Flash.

    -If you use a Tablet, try just a regular old mouse to see if it makes a difference.

    -Make sure that you are, in fact, not inside the symbol. After double clicking to go to the symbol, watch your timeline. There is a bar between the calendar and the workspace (step) which has a few buttons, which one of these buttons is the zoom percentage. On the left side of this bar, you will see "Scène 1". If it is followed by something else (as symbol 1, movie_clip, etc.) it means that you are inside the symbol. Sometimes you notice even when you are actually in the symbol (I did before), so this is a way to be sure where you stand on the stage/timeline.

Maybe you are looking for