Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-06-2009, 01:55 PM   #1
whisher
Registered User
 
Join Date: Sep 2009
Posts: 5
Default List onclick go to the top

Hi.
I've got this script and
it works fine if you click on a clip
the clip goes to the top and the others change
position with a nice tweening.

I'm wondering if there is a better
way to set up the effect.

ActionScript Code:
package com{     import caurina.transitions.Tweener;     import flash.text.TextFormat;     import flash.display.*;     import flash.events.*;     //import flash.events.MouseEvent;     import com.XmlProducts;     public class Products extends Sprite {         private var _productsData:XmlProducts;         private var _active:String= 'product-1';         public function Products() {             _productsData= new XmlProducts();             _productsData.addEventListener(XmlLoader.ON_COMPLETE, _createUI);                     }         /*         public function setActive(action:String) {             _active= action;         }*/         private function _createUI(event:Event) {             var item:Object=_productsData.item;                                     var containerProducts:Sprite = new Sprite();             containerProducts.name= 'container';             containerProducts.x = 75;             containerProducts.y = 0;             var productPos:Number= 0;             for(var indexProduct:String in item.products.mcs){                 var product:Product = new Product();                 product.id= indexProduct;                 product.buttonMode=true;                 product.mouseChildren=false;                 product.name = item.products.mcs[indexProduct].name;                 product.placeholder.text = item.products.mcs[indexProduct].placeholder;                 product.label.text = item.products.mcs[indexProduct].label;                 product.content.text = item.products.mcs[indexProduct].content;                 product.x = 0;                 product.alpha = 1;                 product.y =productPos;                 product.height=50;                 product.addEventListener( MouseEvent.CLICK, _onClick);                 productPos+=product.height;                 containerProducts.addChild(product);             }                         addChild(containerProducts);                                             } /*++++++++++++++++++++  EFFECT ++++++++++++++++++++++++++*/         private function _onClick(e:Event):void{             var containerProducts:Sprite= getChildByName('container') as Sprite;             var id:Number= Number(e.target.id);             var productPos:Number= 50;//             for(var i:Number = 0; i<containerProducts.numChildren; i++){                 var product:Product = containerProducts.getChildAt(i) as Product;                 if(id==i){                     Tweener.addTween(product,{y:0,time:1, transition:"easeInOutSine"});                 }                 else{                     Tweener.addTween(product,{y:productPos,time:1, transition:"easeInOutSine"});                     productPos+=product.height;                 }             }                     }                     } }

Bye.
whisher is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:54 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.