UPDATE:
Felix, the author of this tutorial has sent me an updated source file (.fla)
for it. Here is what he had to say:
"In this version the developer may now drop a single MC into his application
and only has to change the target app in the components-panel. (i.e. rtmp:/sample_lobby)."
Did
you ever come across the situation where you wanted to show a FlashCom-Application's
statistic on the frontpage of your website - and even without loading the
whole desired application? Here is how you can do it:
First of all you need to install the FlashCom Communication Components. The download-package is available at Macromedia DevNet Center for free.
In
Flash MX create a new file and save it as AdminConnect.fla within your
FlashCom environment. Goto the Components Panel and choose "Communication
Components" from the pull-down menu.
Now place the following components on your main timeline:
"Simple Connect",
"Connection Light"
and "People List".
Create
2 dynamic textfield on your main timeline and name them:
1st field = "totalUsers"
2nd field = "participants_txt".
Now
we need do set some Component Parameters to make sure we are connected
with the desired application: Mark the "Simple Connect"-Component
and fill the first parameter called Application Directory with i.e.
"rtmp:/sample_panel_presentation".
Open the application from which you want to read the data (here: Sample Panel Presentation).
Find out, what name the PeopleList-Component was given in this movie. (it is: people_fc)
Go back to your Admin-Movie and fill the second parameter of your SimpleConnect-Component (Communication Components) with "people_fc" and add another value "light_fc".
Also fill the instance name of the People-List Component with that name (people_fc)
Now what we have done here was to establish a connection with another application plus the integrated people-list component.
In our AdminConnect-Movie enter the following Actionscript in the first frame of your main timeline:
stop();
//
people_fc.watch('users', function (id, oldval, newval) {
users = newval;
lurkers = this.lurkers;
updateParticipants();
});
//
function updateParticipants() {
trace("Users: " + users + ", Lurkers: " +
lurkers);
if (users > 0 || lurkers > 0) {
var viewers = "(";
if (users > 1) {
viewers += users + " Participants";
} else if (users == 1) {
viewers += "1 Participant";
}
if (users > 0 && lurkers > 0) {
viewers += ", ";
}
if (lurkers > 1) {
viewers += lurkers + " Guests";
} else if (lurkers == 1) {
viewers += "1 Guest";
}
viewers += ")";
}
participants_txt.text = viewers;
totalUsers.text = users;
}
In line "3" we have: people_fc.watch('users', function (id,
oldval, newval) { where ... people_fc.watch ...
Connects to the correct instance of out target application.
The following code reads the specific participants of the "sample panel
presentation"
the lines: participants_txt.text = viewers;
and: totalUsers.text = users;
fill the textfield with the variables.
Our
current movie would connect us to the "sample panel presentation" and
also establish a connection back to the AdminConnect-Movie.
But at in AdminConnect-Movie we don´t want to login at all.
So we have to change the SimpleConnect-Component a little.
Choose the SimpleConnect-Component and goto the layer "actions" to
change the framescript. Goto line 94 and set a comment statement (in line
93: "/*")
End this statement in line 105 with "*/".
In our AdminConnect-movie there is no auto-login anymore and the PeopleList-Field is filled with data from the target application only.
You may want to add the following script to either the "SimpleConnect"-Component and the "ConnectionLight"-Component:
onClipEvent (enterFrame) {
this._visible = false;
}
// Remember this is the "dirty" version so feel free to optimise my code here and there as long as you know what you are doing.
Testing: Enabled your live-preview options in FlashMX and preview the AdminConnect Movie (CTRL + ENTER). Open 2 instances of the sample_panel_presentation.swf and connect as a participant.
Now you see 2 Users online (1st textfield) + 2 participants and 1
guest (2nd textfield). The "1 guest information" is a result
of the 2-sided connection running in the background. I didn´t
have the time to find a good workaround for that issue. Remember that
this is the quick'n'dirty version.
Please mail me for a solution on
this. In the movie we can also see what login-names were chosen in the target
app.
You
can now modify the movie matching your needs and import the published
movie into i.e. a html-document to show your statistics on the frontpage
of your website.
