Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.96 KB | None | 0 0
  1. import bb.cascades 1.3
  2.  
  3. Page {
  4.     Container {
  5.         layout: StackLayout{}
  6.        
  7.        
  8.         Button{
  9.             text: "attach animation"
  10.             onClicked: {
  11.                var ac = animationscomp.createObject();
  12.                //ac.rem.anim.fadeFrom = 1.0;
  13.                //ac.rem.anim.fadeTo  = 0.0;
  14.                ac.moveFrom = 0;
  15.                ac.moveTo = 500;
  16.                //ac.createObject();
  17.                
  18.                node.add(ac)
  19.                console.log("CONTROL ADDED");
  20.                //anim.play();
  21.             }
  22.         }
  23.         Container{
  24.             preferredWidth: 1440
  25.             preferredHeight: 1440
  26.             background: Color.Red
  27.             id: node
  28.             layout: DockLayout {
  29.            
  30.             }
  31.             onControlAdded: {
  32.                 //anim.play();
  33.             }
  34.         }
  35.         attachedObjects: [
  36.             ComponentDefinition {
  37.                 id: animationscomp
  38.                 content: Container{
  39.                     id: rem
  40.                     property alias moveFrom: mF.text
  41.                     property alias moveTo: mT.text
  42.                     preferredWidth: 1
  43.                     preferredHeight:1
  44.                     background: Color.Transparent
  45.                     verticalAlignment: VerticalAlignment.Top
  46.                     Label {
  47.                         id: mF
  48.                        
  49.                     }
  50.                     Label {
  51.                         id: mT
  52.                         onTextChanged: {
  53.                             //move.fromX = parseInt(mF.text);
  54.                             //move.toX = parseInt(mT.text);
  55.                             //anim.play();
  56.                             anim.play();
  57.                         }
  58.                    
  59.                     }
  60.                     animations: [
  61.                         SequentialAnimation {
  62.                             id: anim
  63.                             target: node
  64.                             //property  alias fadeFrom: fade.fromOpacity
  65.                             //property alias fadeTo: fade.toOpacity
  66.                            
  67.                             FadeTransition {
  68.                                 id: fade
  69.                                 fromOpacity: 1.0
  70.                                 toOpacity: 0.2
  71.                             }
  72.                             TranslateTransition {
  73.                                 id: move
  74.                                 fromX: parseInt(mF.text)
  75.                                 toX: parseInt(mT.text)
  76.                             }
  77.                             onEnded: {
  78.                                 node.translationX = 0;
  79.                                 node.opacity = 0.0;
  80.                             }
  81.                         }
  82.                        
  83.                     ]
  84.                     onCreationCompleted: {
  85.                        
  86.                     }
  87.                 }
  88.             }
  89.         ]
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement