adobe connect custom pods - apache-flex

I'm trying to make a custom pod for Adobe Connect using flex.
I am trying to modify the basic chat window described in the video here: https://www.youtube.com/watch?v=oz4vRIBTy3k
I am aiming to create some buttons to update the status of a person.
I have tried to use the method setMyStatus(status:String):void as outlined in the SDK documentation but I can't get the application to actually make the function run.
Any help appreciated.
I have added the SyncConnector.swc to the resource library provided in the SDK.
Full code here:
<mx:Script>
<![CDATA[
import com.adobe.sync.events.SyncSwfEvent;
import flash.events.MouseEvent;
protected function syncMessageReceived(event:SyncSwfEvent):void
{
if (event.data.msgNm == "statusUpdate")
{
setMyStatus(event.data.msgVal);
}
}
protected function sendMessage(event:MouseEvent):void
{
var customStatus:String = "status";
setMyStatus(customStatus);
connector.dispatchSyncMessage("statusUpdate", customStatus, false);
}
public function setMyStatus(status:String):void
{
status = "speechAgree";
}
]]>
</mx:Script>
<components:SyncConnector id="connector" syncMessageReceived="syncMessageReceived(event)" />
<!--<components:ConnectionEmulator bsyncConnector="{connector}" />-->
<mx:Panel title="Status" top="5" right="5" bottom="5" left="5" layout="vertical">
<mx:Button id="btnAgree" label="Agree" click="sendMessage(event)" />
</mx:Panel>

Related

Fxcomponent: Flex video player issue

I'm using the fxcomponent: Flv video player to play my flv/mob files.
You may get it from here.
Now, player works perfectly as shown in their site, but when I try to use the FXVideo control in popup window (popup manager help is here), the component gives mirror image!, strange, I didn't change any code in that.
So can any one help me out to fix this issue, as I'm novice to action script?
Image:
For quick set up, I'm putting my code here:
FXVideo_Example.mxml file (No change at all except variable)
[Bindable]
private var source:String = "http://localhost/greatcatches.flv";
]]>
</mx:Script>
<controls:FXVideo width="480" height="360" source="{source}" autoPlay="false" bufferTime="10" />
MainPage.mxml:
import mx.core.IFlexDisplayObject;
import mx.managers.PopUpManager;
private function showW():void {
// Create a non-modal TitleWindow container.
var helpWindow:IFlexDisplayObject =
PopUpManager.createPopUp(this, FXVideo_Example, false);
}
]]>
</mx:Script>
<mx:VBox width="480" height="360">
<mx:Button click="showW();" label="Show"/>
</mx:VBox>
Ended up by using spark component!
<s:VideoPlayer id="videoPlayer"
source="http://localhost/greatcatches.flv"
autoRewind="true"
muted="true"
horizontalCenter="0"
verticalCenter="0" />

Why wouldn't a flex remoteobject be able to work within a custom component?

Please enlighten this flex noob. I have a remoteobject within my main.mxml. I can call a function on the service from an init() function on my main.mxml, and my java debugger triggers a breakpoint. When I move the remoteobject declaration and function call into a custom component (that is declared within main.mxml), the remote function on java-side no longer gets called, no breakpoints triggered, no errors, silence.
How could this be? No spelling errors, or anything like that. What can I do to figure it out?
mxml code:
&#060 mx:RemoteObject id="myService"
destination="remoteService"
endpoint="${Application.application.home}/messagebroker/amf" &#062
&#060 /mx:RemoteObject &#062
function call is just 'myService.getlist();'
when I move it to a custom component, I import mx.core.Application; so the compiler doesn't yell
my child component: child.mxml
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" >
<mx:Script>
<![CDATA[
import mx.core.Application;
public function init():void {
helloWorld.sayHello();
}
]]>
</mx:Script>
<mx:RemoteObject id="helloWorld" destination="helloService" endpoint="$(Application.application.home}/messagebroker/amf" />
<mx:Label text="{helloWorld.sayHello.lastResult}" />
</mx:Panel>
my main.mxml:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" xmlns:test="main.flex.*" >
<mx:Script>
<![CDATA[
[Bindable]
public var home:String;
[Bindable]
public var uName:String;
public function init():void {
//passed in by wrapper html
home = Application.application.parameters.appHome;
uName = Application.application.parameters.uName;
}
]]>
</mx:Script>
<test:child />
</mx:Application>
The child components are calling creationComplete before the parent (so home is null). A solution is to throw an event (like InitDataCompleted) from the parent after you read the data, and in the child components listen for this event (so don't rely on creationcomplete in the child).
However more important than that is how can you diagnose in future this kind of problems. A simple tool like a proxy (eg Charles) should help.
For your endpoint value you've got
endpoint="$(Application.application.home}/messagebroker/amf"
Why are you using $( before Application.application... This should be a { as in:
endpoint="{Application.application.home}/messagebroker/amf"

flex 3 passing data from modules to parent application to switch views in the viewstack

Hello Fellow stackoverflowers,
I´m stuck writing a piece of code.
I have application with a viewstack witch load 5 modules.
each module is loaded via the moduleLoader tag and they all have an id.
Every loaded module has a context menu. the context menu has 5 menuItems.
one menuItem for each view for the viewstack.
The context menu is loaded via xml.
this is my application file.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
backgroundColor="#b1b1b1"
backgroundGradientColors="[#b1b1b1,#252525]">
<mx:Script>
<![CDATA[
import mx.core.Container;
//change viewstack views via modules context menu
public function switchView(viewId:String):void
{
var container:Container = Container(tops.getChildByName(viewId));
if (container != null)
{
tops.selectedChild = container;
}
}
]]>
</mx:Script>
<mx:ViewStack id="tops" width="100%" height="100%">
<mx:ModuleLoader id="admin" url="view/admin.swf" width="100%" height="100%"/>
<mx:ModuleLoader id="tv" url="view/tv.swf" width="100%" height="100%"/>
<mx:ModuleLoader id="community" url="view/community.swf" width="100%" height="100%"/>
<mx:ModuleLoader id="shop" url="view/shop.swf" width="100%" height="100%"/>
<mx:ModuleLoader id="communicator" url="view/communicator.swf" width="100%" height="100%"/>
</mx:ViewStack>
</mx:Application>
and this is my switch statement in my Module
public function changeView():void{
switch(action) {
case "admin":
parentApplication.switchView("admin");
break;
case "tv":
parentApplication.switchView("tv");
break;
case "shop":
parentApplication.switchView("shop");
break;
case "community":
parentApplication.switchView("community");
break;
case "default":
parentApplication.switchView("communicator");
break;
}
}
and this is my context menu xml
<mx:XML id="appMenu">
<root>
<menuitem enabled="false"/>
<menuitem label="Administration" action="admin" icon="adminMDI"/>
<menuitem label="Television" action="tv" icon="tvMDI"/>
<menuitem label="Community" action="community" icon="communityMDI"/>
<menuitem label="Shopping Mall" action="shop" icon="shoppingMallMDI"/>
<menuitem label="Communicator" action="default" icon="communicatorMDI"/>
</root>
</mx:XML>
What i would like to do is switch the views in the viewstack by clicking on one of the menuitems in the context menu.
i can't communicate from my module to the application.
What am i doing wrong?
what must i do?
Can anybody help me out?
Oyeah before i forget
the xml of the context menu is in the module but, the context menu is in a as file that extensiate a button.
please can any body give me a good example how to accomplish this.
Thank
DJ
I see a couple issues before getting into the multi-module communication.
First, in your changeView() function, you are declaring the variable action and then switching on it.
public function changeView():void {
var action:String;
switch(action) {
// action will always be null here.
}
}
Because you don't have a 'default' case in your switch statement(s), parentApplication.switchView will never be called.
Also, for the sake of brevity, you can write switch statements like this:
switch(action) {
case "admin":
parentApplication.changeView("admin");
break;
case "tv":
parentApplication.changeView("tv");
break;
case "shop":
parentApplication.changeView("shop");
break;
// ... etc ...
default:
// this gets called if action doesn't match anything.
break;
}
Finally, you could save yourself even more typing because your action and module ids are the same, you could do this:
public function changeView(action:String):void {
parentApplication.changeView(action);
}
Maybe try those things and then updating your question (also, the XML for your context menus didn't render correctly in your question). That may help the community solve your issue a little easier.
UPDATE
I don't think the problem is in the module communication. I built a simple project that does what I think you're looking for. I've posted the source below.
mmodules.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" implements="interfaces.IApplication">
<mx:Script>
<![CDATA[
import mx.core.Container;
public function changeView(action:String):void {
viewstack.selectedChild = viewstack.getChildByName(action) as Container;
}
]]>
</mx:Script>
<mx:ViewStack id="viewstack" width="100%" height="100%">
<mx:ModuleLoader id="module1" url="views/module1.swf" />
<mx:ModuleLoader id="module2" url="views/module2.swf" />
</mx:ViewStack>
</mx:Application>
interfaces/IApplication.as
package interfaces {
public interface IApplication {
function changeView(action:String);
}
}
views/module1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import interfaces.IApplication;
import mx.events.MenuEvent;
import mx.controls.Menu;
/**
* Dynamically builds a menu.
*/
protected function showMenu():void {
var m:Menu = Menu.createMenu(null, menuData, false);
m.labelField = '#label';
m.addEventListener(MenuEvent.ITEM_CLICK, onItemClick);
m.show(10, 10);
}
/**
* Handles whenever an item in the menu is clicked.
*/
protected function onItemClick(e:MenuEvent):void {
if(e && e.item && e.item is XML) {
changeView(e.item.#action);
}
}
/**
* Tells the parent application to switch views.
*/
protected function changeView(action:String):void {
var app:IApplication = parentApplication as IApplication;
switch(action) {
case 'module1':
app.changeView('module1');
break;
case 'module2':
app.changeView('module2');
break;
}
}
]]>
</mx:Script>
<mx:XML format="e4x" id="menuData">
<root>
<menuitem label="Module 1" action="module1" />
<menuitem label="Module 2" action="module2" />
</root>
</mx:XML>
<mx:Button label="Show menu" click="showMenu()" />
</mx:Module>
Hope that helps.

Calling Application.application.enable from a TitleWindow in a different mxml component

I have a Flex RIA App, and in the application tag there is a button when it's pressed calls upon a TitleWindow from another .mxml file, and sets
application.enable = false
That way the user can't use any of the components in the application, and still can use the components in the TitleWindow.
The problem is when the TitleWindow is closed I want it to restore the application back to
application.enable = true
Which enables the application once again. But I can't call that code from inside the TitleWindow .mxml
How can I do it?
Here is the Source:
Loja.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="585" height="450" xmlns:ns1="com.*">
<mx:Style source="theme/simplicitygray.css" />
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
private var clientid = 0;
public function openWindow() : void
{
if (clientid == 0)
{
PopUpManager.createPopUp(this,Login,false);
application.enabled = false;
} else {
PopUpManager.createPopUp(this,Conta,false);
application.enabled = false;
}
}
]]>
</mx:Script>
<mx:Panel x="10" y="40" width="565" height="400" layout="absolute">
</mx:Panel>
<mx:MenuBar x="10" y="10" width="565" height="22"></mx:MenuBar>
<mx:Button x="508" y="10" label="Aceder" click="openWindow();"/>
</mx:Application>
And one of the title windows. Once they are the same.
Login.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="350" height="200" creationComplete="centerWindow()" showCloseButton="true" close="closeWindow()" title="Login">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
public function centerWindow():void
{
PopUpManager.centerPopUp(this);
}
public function closeWindow():void
{
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
</mx:TitleWindow>
application is a static property of the Application class and can be called from the TitleWindow
public function closeWindow():void
{
PopUpManager.removePopUp(this);
Application.application.enabled = true;
}
BTW, There is another easier way to achieve the following:
That way the user cant use any of the components in the application, and still can use the components in the TitleWindow.
That is to use a modal popup. Set the third parameter of the createPopUp to true and that's it - you don't have to enable/disable the application manually: flex will take care of it.
PopUpManager.createPopUp(this,Login, true);
application will automatically become functional once you call removePopUp.
You can use custom events to enable this functionality, as described here.
Essentially, you set up a custom event in the class you are calling, then create a function that runs when the event is consumed. That way your 'Loja' will know when the 'Login' is done.

Binding a Flex component to a class function

I have several components where I want to enable buttons based on passing a username to a function. I want to dynamically bind the "enabled" property on a button so that if the "somethingChanged" event fires, a button may become enabled or disabled.
But, I'm not sure where to fire the "somethingChanged" event. It's possible that I may need to fire the "somethingChanged" event from several places in the application. Is this possible with a bound static function?
Am I going about this the right way or is there a better solution?
EventManager.as
public class EventManager():void
{
[Bindable(event="somethingChanged")]
public static function hasAccess(myVal:String):Boolean
{
}
}
testform1.mxml
<s:Button id="testButton1" enabled="{EventFunction.hasAccess("john")}" />
<s:Button id="testButton2" enabled="{EventFunction.hasAccess("mary")}" />
<s:Button id="testButton3" enabled="{EventFunction.hasAccess("beth")}" />
testform2.mxml
<s:Button id="testButton4" enabled="{EventFunction.hasAccess("tom")}" />
<s:Button id="testButton5" enabled="{EventFunction.hasAccess("bill")}" />
<s:Button id="testButton6" enabled="{EventFunction.hasAccess("jerry")}" />
Something like this would work.
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
public class EventManager extends EventDispatcher
{
[Bindable(event="somethingChanged")]
public var hasAccess:Boolean = true;
public static var instance:EventManager = new EventManager();
public static function setHasAccess(hasAccess:Boolean):void
{
instance.hasAccess = hasAccess;
instance.dispatchEvent(new Event("somethingChanged"));
}
}
}
Which would be used like so:
<?xml version='1.0' encoding='UTF-8'?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo">
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
EventManager.setHasAccess( false );
}
]]>
</fx:Script>
<mx:Button click="button1_clickHandler(event)" enabled="{EventManager.instance.hasAccess}"/>
</s:Application>
I don't know that this approach is a good one. This type of functionality would probably be better served inside a proper MVC structure. This is essentially creating a singleton. To implement it as you describe, you'd probably want some sort of instance per user I suppose. You aren't going to be able to bind to a static function though.

Resources