ClipControl

The ClipControl widget controls any movieClip object in Flash, changing the properties of the clip (e.g. width, x or y position, alpha, frame number, etc.) based on input values from another widget. For example, the output value from an ../AnalogInput widget monitoring a proximity sensor can control the left/right (x property) position of a graphic across the screen to reflect the position of a person in relation to a wall. In addition, more than one property of a clip (scale and alpha for example) can be controlled by having multiple ClipControl widgets control the same clip.

Since the values used by ClipControl are directly translated into the property of the clip, be sure the widget or code sending values to ClipControl are in the appropriate range. For example, if you are using ../AnalogInput as the inputSource, and you are controlling the horizontal position of a graphic, you should set the MIN of ../AnalogInput to 0 and the MAX to the width of the Flash movie. In this case, an incoming value of 0 would put the graphic at the left side of the screen, and if the screen is 640 pixels wide, then an incoming value of 640 would position the graphic at the right side of the screen (note that the registration point of the clip the exact positioning). See the individual properties listed below for their appropriate ranges.

On-screen Features

Parameters

netFeed Explanation & Code Examples

If you use the netFeed capability, the clipControl will send the actual sensor value to the indicated movieClip. For this to work, a function needs to be associated with that movieClip. An example of this is where you want the movieClip to rotate to the left for sensor values less than 50, and rotate to the right for values 50 or greater. Placing the following code on the movieClip named in the parameters would accomplish this:

onClipEvent (load) {
   function netFeed(feedValue) {
      if (feedValue<50) {
         this._rotation -= 10;
      } else if (feedValue>=50) {
         this._rotation += 10;
      }
   }
}

In a more complex example, it is possible to target the _root timeline as the movieClip in the "clip" parameter, and thus cause a function defined in the first frame to be executed. This example changes the color of a movieClip on the stage called "clip1". It assume there are three ClipControl widgets on stage, with instance names of "red" "green" and "blue".

import flash.geom.ColorTransform;
redMultiplier = 0;
greenMultiplier = 0;
blueMultiplier = 0;
function netFeed(feedValue, feedID) {
   if (feedID == "red") {
      redMultiplier = feedValue/100;
   } else if (feedID == "green") {
      greenMultiplier = feedValue/100;
   } else if (feedID == "blue") {
      blueMultiplier = feedValue/100;
   }
   _root.clip1.transform.colorTransform = new ColorTransform(redMultiplier,greenMultiplier,blueMultiplier,1,0,0,0,0);
}

Documentation/Interface/ClipControl (last edited 2007-10-10 17:57:38 by PhilipVanAllen)