|
-
Main.swf event handler, close netStream in impoted swf
Hi FK,
I import a external SWF into a UILoader, the SWF contains a netStream that I need to close from a Main.swf event handler, slideShow_btn.
Basically from Main.swf when/if slideShow_btn event happens I need to check and close the nsStream in videoplayer.swf
Here are my event handlers in Main.swf: All good info Aprreciated!!!!
slideShow_btn.addEventListener(MouseEvent.MOUSE_DO WN, mouseDownHandler1);
function mouseDownHandler1(event:MouseEvent):void {
var swfrequest:URLRequest = new URLRequest("slideshow.swf");
myLoader.scaleContent = true;
myLoader.load(swfrequest);
}
videoLow_btn.addEventListener(MouseEvent.MOUSE_DOW N, mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
var swfrequest:URLRequest = new URLRequest("videoplayer.swf");
myLoader.scaleContent = true;
myLoader.load(swfrequest);
}
-
Senior Member
-
Thanks for your reply! Ive looked into local connections and have setup a data send and receive, but i need to send the btn event to pause netStream, and hope you/someone can help out. Many thanks Paul
This is my send AS:
var mLocalConnection:LocalConnection;
mLocalConnection=new LocalConnection();
mLocalConnection.addEventListener(StatusEvent.STAT US, onLocalConnectionStatus);
sendButton.addEventListener(MouseEvent.CLICK, onClickedSend);
function onClickedSend(localConnectionMessage:String):void
{
mLocalConnection.send("myLocalConnection", "messageHandler", messageTextField.text);
}
function onLocalConnectionStatus(statusEvent:StatusEvent):v oid
{
if (statusEvent.level=="error")
{
trace(statusEvent.code);
}
}
This is Receive AS:
var mLocalConnection:LocalConnection;
mLocalConnection=new LocalConnection();
mLocalConnection.connect("myLocalConnection");
mLocalConnection.client=this;
mLocalConnection.addEventListener(StatusEvent.STAT US, onLocalConnectionStatus);
function messageHandler(localConnectionMessage:String):void
{
trace("Received message:\n"+localConnectionMessage);
messageTextField.text="Received message: "+localConnectionMessage;
}
function onLocalConnectionStatus(statusEvent:StatusEvent):v oid
{
if (statusEvent.level=="error")
{
}
}
-
Hi I got it sorted, needed to declare onClickedSend event as below, for anyone who cares!
//send script:
var mLocalConnection:LocalConnection;
mLocalConnection=new LocalConnection();
mLocalConnection.addEventListener(StatusEvent.STAT US, onLocalConnectionStatus);
sendButton.addEventListener(MouseEvent.CLICK, onClickedSend);
function onClickedSend(e:Event):void
{
mLocalConnection.send("myLocalConnection", "streamHandler");
}
function onLocalConnectionStatus(statusEvent:StatusEvent):v oid
{
if (statusEvent.level=="error")
{
trace(statusEvent.code);
}
}
//receive script:
var mLocalConnection:LocalConnection;
mLocalConnection=new LocalConnection();
mLocalConnection.connect("myLocalConnection");
mLocalConnection.client=this;
mLocalConnection.addEventListener(StatusEvent.STAT US, onLocalConnectionStatus);
function onLocalConnectionStatus(statusEvent:StatusEvent):v oid
{
if (statusEvent.level=="error")
{
}
}
function streamHandler():void {
// stops publishing the stream
nsStream.pause();
// deletes the source stream connection
ncConnection.close();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|