Wednesday, April 23, 2008

Using Multiple Points in a Flash Movie

For the most part a single point id is all that is needed to run a flash component, but what if you want to make a more complex component that say compares 2 point values to change a background- color. This can be done by adding more then 1 connector to you flash movie. A connector can only have 1 point id associated with it, but there is no limit to amount of connectors you have in the movie.


To add more connectors is easy it is the same steps as the first connector, just need to add a unique instance name and pass the point id with a unique POST variable. For example I will show how to compare a space temperature to a space setpoint and change the text box background color based on the difference. For simplicity I will assume the reader has done the exercises in the flash SDK and has a working knowledge of flash and the connector component.


  1. Setup a flash movie with a Text Input box and give the box the name of status_txt

  2. Drag and drop 2 instances of the connector component on to the movie

  3. Name the first connector conn

  4. Name the second connector conn2

  5. Add the following code to the movie to pass the point id's from the POST variables to the connector's

conn.ID = PointID;

conn2.ID = PointID2;

  1. Then add a timer and point it to a function

  2. Add this code inside of the timed function. This code will compare the 2 values and update the

    background color of status_txt

var pointValue = Number(conn.output);//assign the space temperature

var pointValue2 = Number(conn2.output);//assign the space setpoint

if (((pointValue-pointValue2)<=1) || ((pointValue2-pointValue)<=1)){

status_txt.setStyle('backgroundColor',"0xFFFFFF");//even

}

if ((pointValue-pointValue2)>1){

status_txt.setStyle('backgroundColor',"0xFF66CC");//1deg hot

}

if ((pointValue2-pointValue)>1){

status_txt.setStyle('backgroundColor',"0x00FFFF");//1deg cool

}

if ((pointValue-pointValue2)>2){

status_txt.setStyle('backgroundColor',"0xFF0000");//2deg hot

}

if ((pointValue2-pointValue)>2){

status_txt.setStyle('backgroundColor',"0x0066FF");//2deg cool

}

    status_txt.text = pointValue;

  1. Publish the flash and drop it on a web page

  2. Assign the POST variables PointID=the space temperature PointID and PointID2=space setpoint PointID. The above code is functional but not finished. Proper coding should be added for error checking and null values.


Now you have a movie that can assign more then 1 point id for any number of reasons. At this point you can see a trend happening. If you need a 3rd point just add a new connector give it a unique name and assign the point id to it, and so on for as many point id's needed for your movie.

Labels: ,

3 Comments:

Anonymous Anonymous said...

Very nice writeup! Now, can you give an example of using the 2 PointID's to change the text color of the textbox instead of the background color? I have not been able to do this after multiple attempts of modifying the status_txt.textColor.

Adem Erturk
Solidyne Corporation

April 23, 2008 7:28 AM  
Anonymous Anonymous said...

You use the Flash SDK do do this work . How do we get the SDK???

Inet GURU

June 11, 2008 5:02 PM  
Anonymous Todd said...

You can download the Flash SDK from the InetSupervisor download section http://www.inetsupervisor.com/public/InetSupervisor/

September 1, 2008 12:00 PM  

Post a Comment

<< Home