1

フォトギャラリーに機能を追加したい-写真の親指のさまざまな種類のアニメーション。今、私は以下のコードが好きでした。すべてが正常に機能しますが、親指がステージの端で跳ね返ることを望んでいました。

そして最も重要なのは、アニメーションのさまざまなパターンが必要です。3Dカルーセルとしての動き、円を描くように回転する動き、太陽光線と背中の動きなどです。

これらのアニメーションや同様のアニメーション用の既製のコードがあれば、非常にありがたいです。

[Bindable] private var stageW:int = Capabilities.screenResolutionX;
[Bindable] private var stageH:int = Capabilities.screenResolutionY;

private var itemsVector:Vector.<Image>=new Vector.<Image>();
private var xSpeedVector:Vector.<Number>=new Vector.<Number>();
private var ySpeedVector:Vector.<Number>=new Vector.<Number>();

stage.addEventListener(Event.ENTER_FRAME, update);

private function moveSetup():void {
for(var i:int = 0; i < FlexGlobals.topLevelApplication.objects.length; i++){
    if (FlexGlobals.topLevelApplication.objects[i] is Image){
        var item:Image=FlexGlobals.topLevelApplication.objects[i] as Image;
        item.x=Math.random()*stageW;
        item.y=Math.random()*stageH;
        var randomDirection:Number=Math.random()*2*Math.PI;
        this.addElement(item);
        itemsVector.push(item);
        xSpeedVector.push(2*Math.cos(randomDirection));
        ySpeedVector.push(2*Math.sin(randomDirection));
    }
}   
}

protected function update(event:Event):void {
    for(var i:uint=0;i<itemsVector.length;i++){
        itemsVector[i].x+=xSpeedVector[i];
        itemsVector[i].y+=ySpeedVector[i];
        if(itemsVector[i].x>stageW){
            itemsVector[i].x-=stageW;
        }
        if(itemsVector[i].x<0){
            itemsVector[i].x+=stageW;
        }
        if(itemsVector[i].y>stageH){
            itemsVector[i].y-=stageH;
        }
        if(itemsVector[i].y<0){
            itemsVector[i].y+=stageH;
        }
    }
}
4

1 に答える 1

1

Greensock の TweenLite ライブラリを見てください。これは、Flash でのアニメーションのほぼ標準です (さらに、おまけとして、最近JavaScript に移植されました)。

バウンス機能を含む各種セットイージング機能をサポートしています。ライブラリの有料版には、カスタム イージング関数を作成する機能も含まれています。リンク先の最初のページの途中にインタラクティブなデモがあり、ライブラリをライブで試したり、さまざまなイージング関数をテストしたりできます。

Google 検索では、(疑似) 3D 周回カルーセルの作成方法を説明するさまざまなチュートリアルや、同じことを行うサードパーティ コンポーネントが表示されます。実際、これらはヒンジを実装するのが比較的簡単で、かなり単純な三角法で行われます。この例は、特定の要件に合わせて適応するための合理的な出発点になるようです。

3D 効果は、確かに Flex で実装できます。Flash プラットフォーム用に作成されたオープンソースの 3D ライブラリであるAway3Dをご覧になることをお勧めします。Away3D で実装された水平スパイラル効果の例 (完全なソース コードと共に) は、こちらから入手できます。

于 2012-06-06T09:26:49.237 に答える