Scripted animation question

Hi all,
I need a little help to solve what I think is a pretty simple problem.
This is the scenario:
A map of the world. Sixty pins in the map.
(think three pins for any examples or help)
Click any pin and an oblong box grows (animates) from it to fill the screen at about 80%. Animation lasts about a second.
OK, I could do this by making a tweened animation for each "pin" but on a weekly basis the location of the pins will change so I'm wondering if anyone
can help me design a better functionality than tweening them one by one.
i.e a function I can call to say "as any pin (let's name them pin1, pin2 etc)  is clicked, animate a "zoom box_mc" from whatever X and Y to fill the screen 80%.
Each "zoom" needs to look as if it's "growing" from it's position on the map and not just from the centre of the screen.
I'd like to use a single MC as the zoom box (or as the background to the box) so that each pin can populate the box with different dynamic content.
I'm a designer and not much of a coder and I never made the leap form AS2 to 3.
I looked through the help and found some cool stuff like THIS but after playing around for three hours I'm not getting close to what I want.
So all and any help, links, pointers or tutorials very much appreciated.
Best wishes
Tony

You could increase/decrease the ._width and ._height properties of the movieclip.
To do this each frame use onEnterFrame (there are other ways but here is what I know);
onEnterFrame = function(){
This goes in the main timeline, and code to execute each from goes within it.
First you need to store the new width/height of the box_mc. It's probably best to put the anchor point of the mc at the top left corner of the block.
If all 4 corners of the box need to be moved, then store the new x and y positions too in individual variables (e.g. newX, newY, newWidth, newHeight).
Secondly you need to change the current x,y, width, and height of the box_mc to be closer to those stored in the variables. You can find a way to do this, it could involve using if statements and incrementing/decrementing the x,y,width,height etc. each from until the mc_box variables are the same as those you stored in the first step.
Another way is using box_mc.propertyValue = (box_mc.propertyValue - newPropertyValue)/20; Where propertyValue could be x, y, width, height and '20' could be any number. The /20 causes the values to 'ease' together, slowing down the closer it gets to the new value. Alternatively you could divide by the real distance (using a^2+b^2=c^2) which would create a constant movement rather than an easing movement.

Similar Messages

  • I keep getting error messages that a script "may have stoped responding", The script in question is "contentAreaUtils.js".

    I just updated to FireFox v3.6.8, after using v3.5 successfully for many months. With the new version I keep getting error messages that a script "may have stopped responding", The script in question is "contentAreaUtils.js". My OS is Win2k SP4, with 253,424 KB RAM.
    Is there a known fix. If not, is there an easy way to revert to FireFox v3.5 ?

    Attached is an image of the error message.

  • Can send me recent real time sap script interivew question?

    Hi any one plz send me the real time sap script interivew questions... or mail me on [email protected]

    Hi,
    Please check the links,
    http://www.sap-img.com/sapscripts/faq-for-sap-scripts.htm
    FAQ on Scripts
    If this data isn't enough, then you can search for SAP script interview questions in SDN, you get more results.
    Regards,
    Hema.
    Reward points if it is useful.

  • Script animation

    Is there any tutorials on google or youtube or guides on this forum that has step by step on how to do script animation and NOT timeline animation?

    The first reply to your posting is using AS2 code for the example, so if you happen to be using AS3, the example won't work unless you adjust a few things.
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    var cT:Tween = new Tween(mcClip, "alpha", Strong.easeOut, 0, 100, 0.5, true);
    cT.addEventListener(TweenEvent.MOTION_FINISH, motionCompleteAftermath);
    function motionCompleteAftermath(evt:TweenEvent):void
       trace("You can do something after motion completes here");

  • [JS][CS3] Script deployment question

    Hi everyone,
    I am currently writing scripts in a corporate environment (~30 users), and I'm contemplating the easiest and most efficient way of deploying the scripts. We have a couple of scripts already with the users that are located locally on their machines. As time goes on we'll be writing more and more scripts and updating the existing ones as necessary.
    My current inclination is to stop saving the files locally on the individual machines and instead put a shortcut to a shared server folder in the scripts folder instead. In my testing it seems to work fine without any significant delay, and it automatically populates all of the files in linked folder. I basically want to be able to make sure that users are always launching the most up-to-date code and that any future scripts can be easily deployed without me walking around to everyone's desk (or worse, e-mailing instructions and hoping for the best).
    Are there any downsides/performance issues to this approach? It's a strictly desktop environment, so I don't have to worry about laptop users who are not connected to the network. Is there an alternate way that would be smoother?
    Thanks!

    We've tried it both ways. On our 12 InCopy machines (OSX), we have a symbolic link from /Applications/Adobe InCopy CS5/Scripts/Scripts Panel/ to a shared folder. This works great as long as our file server doesn't go down, and all sorts of other things would break horribly. And the User scripts folder is still available for any machine-specific customizations.
    For our 4 InDesign machines, we decided that was a little too much risk. So instead we have a script, copyScripts.jsx, that just copies scripts from the file server to the Application scripts folder. So everytime there is a change, we go around to those 4 machines and run copyScripts. This works OK.
    It's a little bit of a pain but it also insulates us a bit from bugs, and it means that whoever is using InDesign can decide to not update the scripts if they are in the middle of something critical. They can choose to defer taking the script updates.
    I think if we had to do it over, we probably wouldn't bother with the copyScripts mechanism. The centralized shared folder works pretty well. But it's not so annoying that we've gotten rid of it. And for 4 machines, it's not a huge burden.
    Also, there are some questions of development. If it's convenient to do development in the ESTK, having the shared folder means you cannot just rightclick in the Scripts panel and choose Edit Script. Or if you do, then any changes you save as you are developing the script are instantly available to everyone, potentially breaking their work if there are problems, or if there is debugging output ,etc., etc. So you need to make sure you do a development in a different place. Just something to keep in mind.

  • Script format question: Title over

    Question: In the script format when using a "TITLE OVER" is it a General, Shot or an Action format. Appreciate any input here, thanks.
    Rich

    It a good question, as it is worth thinking how the elements in our screenplays will be used down the line. So for example, although the formatting of making it a Shot certainly would put TITLE OVER in caps, and making it Action would allow the paragraph it is in to be lower and upper case, it better to think how the elements may be used as metadata when you move on from writing, rather than how they look on the page. The tags and elements will be used by others in many different ways as the script moves through the planning and shooting steps.
    Shot elements will be processed by an application like Adobe OnLocation which will create a placeholder shot for it for the shoot. That could be theoretically correct in this case as the title will need to be shot. However to answer your question I think General is the appropriate element, just as the Title and Author are General on the titlle page.
    Are there other elements of the screenplay that will need to be tagged in special ways so they are available as the right kind of metadata later in the production process?

  • [CS3:Mac]Script Runner question...

    Hi,<br /><br />I'm trying to perform a simple test  to run a javascript file in my plugin.<br />My first question is do I need to setup/register/add something in plugin to be able to run a script in plugin? the reason I ask this, i get an error in line:<br />InterfacePtr<IScriptRunner>   scriptRunner(scriptManager,UseDefaultIID()); <br />scriptRunner is always NULL.<br /><br />Does anyone know what is wrong here?<br /><br />this is my code snippet:<br /><br />           PMString      jsFullPath("Volumes/HD1/.../MyJavaScript.jsx");      // a path to my java script file          <br />        do {<br />          const IDFile outFile(jsFullPath); <br />          InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss)); <br />          ASSERT( scriptManager ) ;<br />          if(scriptManager == NULL) {<br />               break;<br />          }<br />          InterfacePtr<IScriptRunner>   scriptRunner(scriptManager,UseDefaultIID()); <br />          ASSERT( scriptRunner ) ;<br />          if(scriptRunner == NULL) {  // ******* Always returns NULL *****************//<br />               break;<br />          }<br />               ...<br />          ...<br />               ...  //set other params here<br /><br />          ErrorCode err = scriptRunner->RunFile(outFile, param,..); <br />     <br />     }while(kFalse);<br /><br />Thanks,<br />Mor

    I'm testing this code with different version of CSx, The code works fine on CS3 version but fails( in a line that I marked) in other version .
    Never mind should be OK on CS3.
    Thanks,

  • Animation question: when adding new layers...

    Using CS5. Let's say I have 9 layers in my Photoshop document, and I've successfully created an animation by making some layers visible in some frames and not others. (When making the animation, I'm using the frame view, not the timeline view.) Now let's say that for some reason, I need to add a new layer, perhaps to make the animation look better or to add some missing text. When I add the new layer (call it layer #10), this new layer becomes visible on every single one of the animation frames, and I have to go back to every single frame and remove the new layer #10 from showing. Question: is there a way to avoid this? My goal is to be able to add a new layer without it showing up on every single animation frame I've already finished.

    In the animation flyout menu, uncheck New Layers Visible in All Frames.
    more info:
    http://help.adobe.com/en_US/photoshop/cs/using/WSB8C58284-9DEB-44f2-9D8F-7F77594A8CC2a.htm l
    MTSTUNER

  • Scripting studio questions... - Help!?

    Hello, I've got two questions, both regarding applescript studio.
    Q1: How can one execute applescript code without pressing a button etc.
    Easy example: If I would like to display the default dialog with xcode's applescript, I would write "display dialog". But it doesn't display the default wanted dialog (just the app's window).
    Q2: How do I retrieve every word of a Text view interface component?
    Better asked. I would like to count all the words entered and have every word with a unique value, like the first word have the integer value of 1 the second word 2 the third 3 ...
    Help (of any kind) is dearly appreciated!

    You might be having a problem defining the Text VIew, so I will start from a blank application template.
    Double-click the MainMenu.xib file to open it in *Interface Builder*, then add a Text View to the application window and size it as desired. Clicking in the middle of the Text View will select the Scroll View part, and clicking again near the top will select the Text View part. With the Text VIew selected, go to the AppleScript Inspector, choose the script that you want to use your Text View in and give the Text View a name (for example "myTextView"). You can give names to the other user interface items if desired - in this example there is only one of each item so their indexes can also be used (e.g. "window 1"). Usually a name will be more clear, but I used a couple of different ways to specify the Text View.
    To add some delegate handlers, I selected the *end editing* event handler for the Text View, and the launched event handler for the application (don't forget to set the script). Once everything is defined in Interface Builder, I filled in the event handlers with some log statements to show what is happening (open the Console when build/running the application):
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFCE75;
    overflow: auto;"
    title="this text can be pasted into Xcode 3.1.x (Leopard)">
    on launched theObject
    log "launched..."
    tell window 1
    set contents of text view 1 of scroll view 1 to "This is some testing text - some testing text this is."
    end tell
    display dialog "This is a test dialog"
    end launched
    on end editing theObject
    log "end editing..."
    set theWords to words of (get contents of text view "myTextView" of scroll view 1 of window 1)
    log result
    end end editing
    </pre>
    A test dialog will appear when the application is first run (launched), and pressing return in the Text View (which ends the editing) will log the words of the content to the console.

  • PLEASE HELP!  Text animation question.

    Hi,
    This might be a dumb question, but it's really stumping me.  I want to animate a title using some of the text animation presets, but I can't seem to apply an animation that makes the text appear AND an animation that makes the text disappear.  I can do one or the other, but not both.
    For example, I want my title's text to appear with "FocusIn", and I want it to disappear with "DropOutByCharacter."  How do I do this?!  I've searched everywhere and wasted an entire day trying to figure this out!
    Thanks.
    - epompa03

    Along with Steve's tip on doing two Titles (probably the easiest way to handle this), would be to use Keyframed Effects to create your animation. Since Drop Out By Character, is the harder one to do by hand, I'd just add a Blur to the Title, and Keyframe it to start out heavily Blurred (maybe even with a lowered Opacity, also Keyframed) and then Keyframe the Blur out, where you wish to have the Title sharp. Then, add the Drop Out By Character.
    The beauty of Keyframing the various Effects is that you can control many at one time on a single Clip. However, the concept is not the easiest to initially grasp. Once you do, you'll likely use Keyframes in lieu of most packaged animation Effects.
    Steve has a good series of articles on Keyframing on the Muvipix site. Do not recall if they are in the "free" section, or not. Since there is a ton of great material, articles, tutorials and also Assets, like Motion Footage and Menus there, a subscription often pays for itself in one day of downloading.
    Good luck,
    Hunt

  • Animation Question

    Hello. I am try to make a simple animated pac-man. The problem is that i want it to change his position: Thread.sleep(250). And in the same time to move the mouth Thread.sleep(1000). To make it easier i just wanna make a pacm man that changes position and moves his mouth with diferent pauses.
    Now below is the script. Is written a little mixed up but if u compile it you will see that pacman changes position but doesnt move his mouth depending on which method you put first on the run method:
    PacMan() is for the mouth.
    move() is for the movement
    if you put it like that:
    public void run() {
    while(true) {
    pacman();
    move();
    It will just move the mouth.
    else if you put it like
    public void run() {
    while(true) {
    move();
    PacMan();
    It will just move.
    Below is the code . Thanx
    PS. The mouth is mad with a fillArc() that changes the two last arguments.
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    public class Circle extends JFrame {
         CirclePanel circlep = new CirclePanel();
         public Circle(){
         super("Circle");
         setSize(595,245);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setBackground(Color.black);
         JPanel pane = new JPanel();
         pane.setLayout(new GridLayout(1,1,15,15));
         pane.add(circlep);
         setContentPane(pane);
         show();
    public static void main(String[] arg) {
         Circle circle = new Circle();
    class CirclePanel extends JPanel implements Runnable {
         int k1=-35;
         int k2 = 70;
         Thread thread;
    int x = getSize().width-getSize().width-200;
         public CirclePanel() {
         super();
         if(thread == null) {
         thread = new Thread(this);
         thread.start();
    public void run() {
    while(true){
    move();     
    PacMan();
    public void PacMan() {
    while(true){
         k1 = 2;
         k2 = 2;
         x +=50;
         repaint();
         pause(1000);
         k1= -35;
         k2 = 70;
         repaint();
         pause(1000);
    public void move() {
         while(true) {
         x += 5;
         if (x > getSize().width+200)
         x = -200;
         repaint();
         pause(20);
    public void pause(int secs) {
         try{
         Thread.sleep(secs);
         } catch (Exception e){}
         public void paintComponent(Graphics g) {
    int y = (getSize().height-200)/2;
         Graphics2D screen = (Graphics2D)g;
         screen.setColor(Color.black);
         screen.fillRect(0,0,getSize().width,getSize().height);
         GradientPaint paint = new GradientPaint(0,0,Color.yellow, 200,200,Color.white,true);
         screen.setPaint(paint);
         screen.fillOval(x,y,200,200);
         GradientPaint paint1 = new GradientPaint(0,0,Color.white, 200,200,Color.red,false);
         screen.setPaint(paint1);
         screen.fillArc(x,y,201,201,k1,k2);
         GradientPaint paint2 = new GradientPaint(0,0,Color.blue,10,10,Color.white,true);
         screen.setPaint(paint2);
         screen.fillOval(x+100,50,30,30);
    }

    That should be exactly what you expected. Your run method is executed with a single thread, meaning it is sequencially exectuted line by line. Therefore when one method is call, it continues to execute until the return, then the next method is called. Here, you have a while loop inside each method that is always true, so the method is never returned from to call the next.
    public void run() {
        while(true) {
            PacMan();
            move(); //never executed since PacMan() never returns
    public void PacMan() {
        while(true){ //always true, so method can never return
            k1 = 2;
            k2 = 2;
            x +=50;
            repaint();
            pause(1000);
            k1= -35;
            k2 = 70;
            repaint();
            pause(1000);
    public void move() {
        while(true) { //same here
            x += 5;
            if (x > getSize().width+200)
            x = -200;
            repaint();
            pause(20);
    }Now what you have been waiting for, the solution. Run each animation is a different thread. Try this little test app to see what I mean.
    import java.util.*;
    public class ThreadTest {
        int k1;
        int k2;
        int x =0;
        public ThreadTest(){
            Thread pm = new Thread() {
                public void run() {
                    PacMan();
            Thread m = new Thread() {
                public void run() {
                    move();
            m.start();
            pm.start();
        public void PacMan() {
        for(int i = 0; i < 5; i++) {
                k1 = 2;
                k2 = 2;
                x +=50;
                System.out.println("PacMan: x = " + x);
                pause(1000);
                k1= -35;
                k2 = 70;
                System.out.println("PacMan: x = " + x);
                pause(1000);
        public void move() {
            for(int i = 0; i < 5; i++) {
                System.out.println("move: x = " + x);
                pause(250);
        public void pause(int secs) {
            try{
                Thread.sleep(secs);
            catch (Exception e){
                e.printStackTrace();
        public static void main(String[] args){
            new ThreadTest();

  • Another script library question

    I had a quesiotn about this and "kel" gave me this suggestion:
    put these in [external script file]:
    property var1 : "VAR1"
    property var22 : "VAR22"
    property var333 : "VAR333"
    then in the actual script, do:
    set f to [external script file]
    set s_lib to load script f
    var22 of s_lib
    This works but there is a problem. I have now hundreds of lines of code with almost 30 variables, occurring dozens of times in the text and to manually find each and every one of them and paste "of s_lib" after them would be just awful.
    So my question is: is there a way to avoid it and simply "#include" the library somehow, like in C++?
      Mac OS X (10.4.8)  

    Hello Asu,
    I'm afraid you've missed an important point on global declaration.
    The point is that the variables imported by the previous 'SCRIPT 2' become global variables in the importer script just as though they were declared as global in importer's implicit run handler. And in order to refer to those global variables from a handler other than implicit or explicit run handler, you have to declare them as global in the handler unless you have declared them as global in the top level of importer script. In this respect, the global declaration in 'handler1()' in 'SCRIPT 2' is mandatory.
    Global variable declared in top level of a script and global variable declared in a handler in a script have different behaviours in regards to their scope. Please peruse the language manual for details:
    cf. pp. 311-323
    'Scope of Script Variables and Properties'
    AppleScriptLanguageGuide.pdf
    By the way, of course you may define a new variable and set it to an imported global variable, but then I think you should lose the only advantage of 'SCRIPT 2' over 'SCRIPT 1', that is no reassignments of variables are needed in 'SCRIPT 2'.
    As for handlers in external script, you'd need more complicated device. See the codes below. 'SCRIPT 1A' and 'SCRIPT 2A' are revised samples for 'SCRIPT 1' and 'SCRIPT 2' respectively. Although I'm posting them here, I don't recommend this sort of coding practice at all. It unnecessarily complicates matters and makes debugging harder. I'd recommend instead the simple and natural approach in AppleScript, that is; to load an external script and to tell it to do its tasks (as kel has explained), that should minimize non-essential dependencies and maxmize modularity (in AppleScript's own fashion).
    Hope this helps,
    H
    PS. 'run' command of AppleScript and 'run script' command in Standard Additions are utterly two things. The latter creates a new instance of script every time it is invoked and hence cannot share the context with caller script in normal means. And I see no reason to use 'run script' where I can use 'run'.
    -- SCRIPT 1A
    (* Import properties *)
    property p1 : {} -- required if it is used in external handler with 'my' possessive. -- [*A]
    property p2 : {} -- idem. -- [*A]
    property pf1 : {} -- mandatory. -- [*A]
    property pf11 : {} -- mandatory. -- [*A]
    main()
    on main()
    set o to load script file "RAM Disk:test:properties.scpt" -- load external script
    set {p1, p2, pf1, pf11} to o's {p1, p2, pf1, pf11}
    return {p1, p2, pf1(), pf11(), handler1()}
    end main
    on handler1()
    return {pf1(), pf11()}
    end handler1
      [A] Alternatively, these properties can be declared as globals as well.
       The point is that they must not be local.
       (Also if the following code were entirely in implicit or explicit run handler,
       no declaration of properties or globals should be required, for they become implicit globals)
    -- external script "properties.scpt" contains following code
    on f1() -- [*1]
    --return f11() -- [*2]
    return pf11() -- [*3]
    end f1
    on f11() -- [*1]
    return (my p1) + (my p2) -- [*4]
    end f11
    property p1 : 1
    property p2 : 2
    property pf1 : f1
    property pf11 : f11
      [1] Handler definitions must precede the definitions of the handler name's properties.
        e.g. f1()'s definition must precede the definition of 'property pf1 : f1'.
      [2] This should fail if f1() is called (via pf1()) in a script that loads this script; e.g.
        -- code of caller
        set o to load script file "path to this script"
        set pf1 to o's pf1
        return pf1() -- this should throw error -1708
        -- end of code of caller
      [3] Always invoke other handler by its 'global' (i.e. 'property') name. cf. [2]
      [4] Possessive 'my' is required to resolve property variable properly in a handler that is
       assigned to a property by itself.
        e.g. 'my p1' is required in 'f11()' when 'p1' is a property and 'f11()' is assigned to a property.
    -- end of "properties.scpt"
    -- END OF SCRIPT 1A
    -- SCRIPT 2A
    (* Import globals *)
    main()
    on main()
    set o to load script file "RAM Disk:test:globals.scpt" -- load external script
    tell o to run
    global g1, g2 -- mandatory -- [*A]
    --global gf1, gf11 -- [*B]
    return {{g1, g2, gf1(), gf11()}, handler1()}
    end main
    on handler1()
    global g1, g2 -- mandatory -- [*C]
    --global gf1, gf11 -- [*B]
    {g1, g2, gf1(), gf11()}
    end handler1
      [A] If the code currently in main() were in implicit or explicit run handler instead,
       no global declaration should be required, for the variables become implicit globals.
      [ B] Not required for 'global' handler name (that are redefined as global in 'globals.scpt').
      [C] Always required in a handler other than implicit or explicit run handler.
    -- external script "globals.scpt" contains following code
    global g1, g2 -- mandatory.
    main()
    on main()
    global gf1, gf11 -- mandatory -- [*1]
    set g1 to 1
    set g2 to 2
    set gf1 to my f1 -- [*2]
    set gf11 to my f11 -- [*2]
    end main
    on f1()
    --return f11() -- [*3]
    return gf11() -- [*4]
    end f1
    on f11()
    return g1 + g2
    end f11
      [1] If the code currently in main() were in implicit or explicit run handler instead,
       no global declaration should be required for handler names, for the variables become implicit globals.
      [2] Possessive 'my' is required to resolve handler name properly in another handler.
       If the code currently in main() were in top level of script (i.e. in implicit run handler) instead,
       'my' possessive should not be required.
      [3] This should fail if f1() is called (via gf1()) in a script that loads this script; e.g.
        -- code of caller
        tell (load script file "path to this script") to run
        return gf1() -- this should throw error -1708
        -- end of code of caller
      [4] Always invoke other handler by its 'global' name. cf. [3]
    -- end of "globals.scpt"
    -- END OF SCRIPT 2A
      Mac OS 9.1.x  

  • Include webshop into app magazine / animation question

    Hello,
    I have a few question as regards:
    1) Webshop:
    is it possible to include webshops into an app magazine via the Adobe DPS Single Edition (or only Professional Edition)? This is the webshop I'm talking about that should be included in the app magazine: http://www.blooms.de/ShopRubriken/128143.html?UID=7F46330ACD307CB6A9DA366D9D969CEC3CCEC71A 3FC29CAC10E3AA
    I researched on the internet and saw how Lakeland did it (Adobe Digital Publishing Suite – Marketing-Materialien). They linked to the webshop on the internet what looks like the easiest (also best?) solution. But is there a good way to include the webshop directly into the app magazine rather than linking to it?
    In my research I've also come across this video: Adobe Digital Publishing Suite delivers a rich immersive commercial experience for Shop Direct | Digital Publishing Suit… It looks like a webshop too but integrated into the app. How does this solution work?
    And: How do I get analytics for the shop if it's embedded in the app magazine?
    2) Animations:
    I would like to animate text/textboxes into a full screen background picture. I've read that animations with PDF format (for crisp text on the app!) are not supported. How do I solve this problem?
    Many thanks in advance,
    Helene

    1) You can integrate it via a web overlay, but honestly it is far less complicated and much more likely to work if you just include hyperlinks to your existing web shop and have the reader do the purchasing in the in-app pop-up browser.
    2) This is pretty much impossible to do without doing a bunch of work in Edge Animate. To be honest, I don't really think it's ever worth the time spent. I'd look at doing a different design instead that doesn't rely on that style of animation.
    Neil

  • UIView Animation Question

    To all,
    I have a question about how to handle the asynchronous call when a UIView animation is created. My setup is as follows. I have a method in a view controller that get user input from and then makes external http calls. Since the calls could take a few seconds I wanted to notify the user when the call started and ended. In order to show this message I created a simple animation block in a method which I will list below.
    The animation simply slides a box up with a label on it and then slides it back down. A pop up slider if you will.
    This is my method which does the http processing simplified down.
    My problem is that since the animation call is asynchronous the and takes 4 seconds total to complete. If the HTTP processing takes less then 4 seconds (at times it does) the next displayMessage is called and my animation gets screwed up.
    The thoughts I have had were to have a check to see if the animation was running which is set true in the pop up reveal and false in the popup hide. Then I could simply sleep my thread if the boolean was true. But this wasn't working since the animation stop block was never called.
    I need to bounce ideas of you guys cause I don't know how to get past this basic problem.
    - (void)loadPostViewController:(id)sender
    [self displayMessage:@"Parsing address"];
    //Actual http processing code here which invokes external service
    [self displayMessage:@"Address processed"];
    - (void)displayMessage:(NSString *) inMessage
    CGFloat PostListViewXOFFSET = 20.0f;
    CGFloat PostListViewYOFFSET = 20.0f;
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    self.transitioning = TRUE;
    self.view.userInteractionEnabled = NO;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect messageFrame = CGRectMake(0,0,messageWidth, messageHeight);
    roundedRectangle *view = [[roundedRectangle alloc] initWithFrame:messageFrame x:0 y:0 Width:messageWidth Height:messageHeight cIndex:0 radius:10.0f positionIndex:0];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    UILabel *mylabel = [[UILabel alloc] initWithFrame:CGRectMake(PostListViewXOFFSET, PostListViewYOFFSET, messageWidth-40,20)];
    mylabel.font = [UIFont fontWithName:@"Helvetica" size:12];
    mylabel.textColor = [UIColor blackColor];
    mylabel.text = inMessage;
    mylabel.backgroundColor = [UIColor clearColor];
    self.messageLabel = mylabel;
    [view addSubview:mylabel];
    [mylabel release];
    view.frame = frameOut;
    self.messageView = view;
    [self.view addSubview:view];
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    CGRect frameIn = view.frame; // Get the current frame.
    frameIn.origin.x = (localContainerView.bounds.size.width/2)-(messageWidth/2); // Move the view completely on screen.
    frameIn.origin.y = localContainerView.bounds.size.height-(messageHeight+20.0f);
    view.frame = frameIn; // set the new frame
    [UIView commitAnimations]; // Animate!
    [view release];
    - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    self.transitioning = FALSE;
    [self HideMessage];
    - (void)HideMessage
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(clearMessageView)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    self.messageView.frame = frameOut; // set the new frame
    [UIView commitAnimations]; // Animate!
    }

    To all,
    I have a question about how to handle the asynchronous call when a UIView animation is created. My setup is as follows. I have a method in a view controller that get user input from and then makes external http calls. Since the calls could take a few seconds I wanted to notify the user when the call started and ended. In order to show this message I created a simple animation block in a method which I will list below.
    The animation simply slides a box up with a label on it and then slides it back down. A pop up slider if you will.
    This is my method which does the http processing simplified down.
    My problem is that since the animation call is asynchronous the and takes 4 seconds total to complete. If the HTTP processing takes less then 4 seconds (at times it does) the next displayMessage is called and my animation gets screwed up.
    The thoughts I have had were to have a check to see if the animation was running which is set true in the pop up reveal and false in the popup hide. Then I could simply sleep my thread if the boolean was true. But this wasn't working since the animation stop block was never called.
    I need to bounce ideas of you guys cause I don't know how to get past this basic problem.
    - (void)loadPostViewController:(id)sender
    [self displayMessage:@"Parsing address"];
    //Actual http processing code here which invokes external service
    [self displayMessage:@"Address processed"];
    - (void)displayMessage:(NSString *) inMessage
    CGFloat PostListViewXOFFSET = 20.0f;
    CGFloat PostListViewYOFFSET = 20.0f;
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    self.transitioning = TRUE;
    self.view.userInteractionEnabled = NO;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect messageFrame = CGRectMake(0,0,messageWidth, messageHeight);
    roundedRectangle *view = [[roundedRectangle alloc] initWithFrame:messageFrame x:0 y:0 Width:messageWidth Height:messageHeight cIndex:0 radius:10.0f positionIndex:0];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    UILabel *mylabel = [[UILabel alloc] initWithFrame:CGRectMake(PostListViewXOFFSET, PostListViewYOFFSET, messageWidth-40,20)];
    mylabel.font = [UIFont fontWithName:@"Helvetica" size:12];
    mylabel.textColor = [UIColor blackColor];
    mylabel.text = inMessage;
    mylabel.backgroundColor = [UIColor clearColor];
    self.messageLabel = mylabel;
    [view addSubview:mylabel];
    [mylabel release];
    view.frame = frameOut;
    self.messageView = view;
    [self.view addSubview:view];
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    CGRect frameIn = view.frame; // Get the current frame.
    frameIn.origin.x = (localContainerView.bounds.size.width/2)-(messageWidth/2); // Move the view completely on screen.
    frameIn.origin.y = localContainerView.bounds.size.height-(messageHeight+20.0f);
    view.frame = frameIn; // set the new frame
    [UIView commitAnimations]; // Animate!
    [view release];
    - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    self.transitioning = FALSE;
    [self HideMessage];
    - (void)HideMessage
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(clearMessageView)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    self.messageView.frame = frameOut; // set the new frame
    [UIView commitAnimations]; // Animate!
    }

  • CS5 (and/or 5.5) - animation question

    Hi everyone! I have a problem that I just can't seem to work out and hoping some clever person out there will know an answer
    I have put together an example of what I am trying to do:
    I have 5 objects (the blue rectangles) that I wish to appear in sequence. To do this I selected each object and applied the standard "appear" animation option to each object. (see SCREEN_1 below).
    Then I created a button (the pink circle) and added the animations to the button and set them to play (SCREEN_2).
    After all the rectangles have appeared, I want them all to disappear so I grouped the rectangles and then chose 'disappear" from the animation options and applied it to the group (SCREEN_3)
    And then added this new group animation to the button so it would play after the earlier animations that made the rectangles appear. (SCREEN_4)
    Then I previewed my animation - the pink start button starts the animation and it previews (and exports to swf) fine and looks as I want
    BUT ONLY ON THE FIRST VIEWING!
    If I push the pink start button again, it doesn't play correctly (there is a delay and then the group just appears all at once) . And I CANNOT work out why! And have tried for so long to work this out but am COMPLETELY stumped.
    I basically want the animation (rectangles to appear and then disappear after) to repeat everytime the pink start button.
    Can anyone out there help?!
    Thanking you very much in advance!
    Lisa

    hi again!
    this is weird!
    I had the same problem, but I figured it out, here's how:
    1. do not group the rectangles
    2. select all the rectangles and give them the animation you want (pic1)
    3. make sure "Hide Until Animated" is checked
    4. make a button from your circle and animate each rectangle like pic2
    5. after doing that, do it aigain! make 5 more actions (animate) in your button panel but choose "REVERSE" at "options" (pic3)
    6. at the timing panel, link the last 5 animations (the ones you choose to reverse)
    7. that did the trick for me: http://www.jocstone.be/test/testje.html
    8. let me know if it works?
    9. sorry if my english is not always correct

Maybe you are looking for