Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page >

JavaScriptを使用してコンポジションを操作する

Quartz Composer Web Kitプラグインでは、Listing 7-2に示すように、JavaScriptを使用してコンポジションを操作することが可能です。

Listing 7-2  JavaScriptを通じてコンポジションの値を変更する

var composition = document.getElementById("myComposition");
if (composition.playing() == true)
{
    composition.pause();
    composition.setInputValue("aPublishedInput", aValue);
    composition.setInputValue("anotherPublishedInput", anotherValue);
    composition.play();
}

Listing 7-2のコードでは、コンポジションをDOM (Document Object Model)から取得し、その再生ステータスを問い合わせています。コンポジションが再生中の場合は、再生を一時停止し、コンポジションの入力値の一部を変更して、再生を再開します。

注: コンポジションの入力値はコンポジションを一時停止しなくても変更できます。

DOMからコンポジションを取得する必要があるのは、操作が可能なコンポジションオブジェクトが返されるからです。要素の識別子は、Listing 7-1に含まれているコンポジション用のid属性の値と同じです。それ以外の操作はJavaScriptのメソッドを使用して実行します。Quartz Composer Web KitプラグインのJavaScript APIについては、『Quartz Composer Web Kit Plug-in JavaScript Reference』を参照してください。



< Previous PageNext Page >


Last updated: 2006-12-05




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice