06-19-2009 11:07 AM
Hi,
I have the layout of an assembly line and what to simulate in CVI the asset tracking in the different stations. I designed the layout in Flash AS2.0, asigning each station to a movie clip.
What i want to do is according to the asset, change the background color of each movie clip. For example if we have "model 1" in station "L4NX" it should have a blue backgroud, if it has "model 2" an orange background, and so on...
What i want is to be able to use a function like setColorOrange(stationName)to change the color. stationName is a string that i receive through a TCP/IP server already stablished. In fact, the whole project was working but we were using a .gif image for the .uir and they asked me to make in flash...
Im gonna show yo some code so get an idea of what im doing:
In flash i wrote the actionscript:
var stationName:String;
stationName = "L4NXT"; // just to initialize stationName
var setColorOrange:Color = new Color(stationName)
setColorOrange.setRGB(0xCC3300)
Then in CVI:
#define L4NXT "L4NXT"
void setColorBlue(char *szStat_Id)
{
ShockwaveFlashObjects_IShockwaveFlashSetVariable(flashHandle, NULL, "stationName", szStat_Id);
ShockwaveFlashObjects_IShockwaveFlashPlay (flashHandle, NULL);
}
.
.
.
int WINAPI event_load(int argc, char *argv[])
{
char moviePath[260];
int app=0;
char error[5000]="";
engShell("getapppanel", &app);
panelHandle = LoadPanelEx (app, "DisplayLine.uir", PANEL, __CVIUserHInst);
if( (status=GetObjHandleFromActiveXCtrl (panelHandle, PANEL_SHOCKWAVEFLASH,
&flashHandle) ) !=0)
ReportAppAutomationError(status);
strcpy(szLine,"4000");
strcpy(szStations,"USK#ICT#FLASH#HFT#WELDING#LOAD#VT#LEAK#PACKING#CLEANING#");
SetCtrlVal(panelHandle,PANEL_LINE,szLine);
GetProjectDir (moviePath);
strcat(moviePath,"\\Line.swf");
DisplayPanel (panelHandle);
if ( (status = ShockwaveFlashObjects_IShockwaveFlashSetMovie (flashHandle, &eInfo, moviePath))!=0)
ReportAppAutomationError(status);
//RunUserInterface();
//DiscardPanel (panelHandle);
return 1;
}
int WINAPI event_start()
{
return TRUE;
}
/*****************************************************************************/
int WINAPI event_stop()
{
return TRUE;
}
/*****************************************************************************/
int WINAPI event_connect()
{
return TRUE;
}
/*****************************************************************************/
int WINAPI event_disconnect()
{
return TRUE;
}
.
.
.
.
setColorOrange(stationName)
Does anyone know how can i get to change the color? Because when i use this function it only assings szStat_Id to the var "stationName" created in Flash (already checked with ShockwaveFlashObjects_IShockwaveFlashGetVariable(flashHandle,.....) but doesnt change the color
I'd appreciate any help
Greetings,
06-19-2009 02:03 PM
I've never put flash into a cvi program so it is cool what you have done, if you are just looking to change the background color I would make seperate flash file for each background color then when CVI gets the command to change colors just load a different flash file. I am assuming that the background color is within the flash itself and not just the color around the flash, because then you could create a blank picture of different colors and put it behind the flash then change that background image which is one layer below the flash whenever you get the command. Does this make sense or am I missing your point?
Cheers!
06-19-2009 02:49 PM
Hello Douglas,
Thank you for your response.
I didnt get to explain myself completely: There are 52 stations, 1 movie clip per station, everything is in only one frame in one .fla. (at least this is what I've
done according to the idea that I had but I can change if someone suggest another way of doing it)
I need to change the color of each station dinamically according to the model of the asset that it has in certain moment, not the background of the whole layout.
We can only have one asset per station. The purpose of this is to have a "visualizer" showing the asset tracking in the whole line.
Everything's done so far, except for the communication with flash, i have the .uir with the .swf of the layout. My problem now is to call somehow from CVI the setColorXXX.setRGB(0xXXXXXX) function
I thought of using this actionscript in flash:
var stationName:String;
stationName = "L4KY";
var setColorGreen:Color = new Color(L4KY
setColorGreen.setRGB(0x00FF00)
And to call it on CVI like this
char *test;
void setColorGreen(char *szStat_Id)
{
ShockwaveFlashObjects_IShockwaveFlashSetVariable(flashHandle, NULL, "stationName", szStat_Id);
ShockwaveFlashObjects_IShockwaveFlashGetVariable(flashHandle, NULL, "setColorGreen", szStat_Id);
ShockwaveFlashObjects_IShockwaveFlashPlay (flashHandle, NULL);
}
so in the main program i can use just setColorGreen(szStat_Id); (there are 52 stations, 8 different models -> 8 different colors) but it doesnt work
Any idea?
I help any help or suggestions!