Actionscript :: Socket Events Not Firing

Sep 18, 2011

I'm writing a SWF that I'd like to communicate with a Java process via Sockets. This is usually quite easy with standard Sockets, but for some reason the events described in the Socket documentation aren't firing when all signs say they should be.

On the Java side, I've set up a ServerSocket that's listening on port 8080. Using netcat I've confirmed it works as designed.[code]...

When I run the resulting SWF, all I get is "Called connect!" on the stage, and none of the events ever fire. Even more strangely, when I investigate the communication from the ServerSocket on the Java end, it receives and accepts a connection. When I close the SWF the code calling my Server completes as normal -- meaning it was hanging on a connection made with my SWF.

I'm left with a few questions...

With the exception of the event handlers, this is the end of control for my code (after the connection is established, we just wait for events and render them appropriately). Could the entire program be "terminating," and I'm just misunderstood about the Runtime model?Are there visibilty/naming requirements for the callbacks for them to be called? They're all public, but could it be that the Runtime isn't seeing them?Are there any gotchas with AS3 Socket programming? I kept thinking this was an issue of sandboxing, etc., but the SECURITY_ERROR didn't fire either.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Events Firing Before Listener Is Set

Nov 18, 2009

I keep running into problems where I want to add an event listener onto a class instance RIGHT after it's instantiated, like this:
Code:
storiesXML = new XML(XMLdata);
storyBook = new vStories(XML(storiesXML.stories));
storyBook.addEventListener("storyBookLoaded", storyBookLoaded);
. . .

But by the time we arrive at the third line, the "storyBookLoaded" event has very often (inconsistent) already been dispatched from my class instance:
Code:
var evt:Event = new Event("storyBookLoaded", true, false);
dispatchEvent( evt );
...

(Even though quite a lot has happened in the class before that.) To be clear, I don't want to add storyBook as a display child, and even if I did, the addChild() method would have to be called after instantiation of storyBook, so we'd have the same problem. I know I could set a timer in the vStories class to artificially delay the dispatching of the event, but that seems really hack-ish, and would have a real compounding problem if I have to do it too often as everything builds up. How to make sure custom communication events happen after their listeners are set?

View 4 Replies

ActionScript 2.0 :: Firing Events Through Methods

Oct 19, 2004

whats the easiest way to code tooltip methods to my different classes I currently have working. for example mylabel.setTooltip("text to show",true); mylabel.removeTooltip();so that any event anywhere could call a tooltip. The tooltip follows your mouse movement basically. If the method was called from an MC and the second parameter which is a boolean is set to true: mylabel.setTooltip("text to show",true);

Then the tooltip would only show while the mouse was over that label, componet or MC. If it moved away it would automatically fire the event to remove it. Due to the urgency of this help im willing to pay a small fee for anyone who can write a quick tooltip .as that does just that.

View 4 Replies

ActionScript 3.0 :: Loader Info Events Not Firing

Apr 1, 2010

This simple code:
var loa:Loader = new Loader();
loa.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loa.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
loa.loadBytes(someByteArray);
Sometimes works, but mostly doesn't. Neither 'onLoaderInit' nor 'onLoaderComplete' fire.
'someByteArray' is always a valid ByteArray, stored in a local SharedObject

View 1 Replies

Media Server :: Netconnection Events Not Firing?

Aug 22, 2011

Can anyone tell me why I would not be getting Netconnection.NetworkChange and Netconnection.Closed events would not be getting fired when I am working on Flash CS5?

I get the Success event, but when I am attempting to test my reconnection code I pull out my network cabled and I never get the closed event.

Interestingly, I do get the Closed and NetworkChange events when I am debugging, but not when I just run the movie.

View 7 Replies

ActionScript 3.0 :: Events Not Firing For Timeline Preloader In IE

May 14, 2007

This is problem is cropping up in Flash CS3 rather than Flex, but it's Actionscript 3.If you paste the code below into the main timeline on frame 1 and test it in Flash, the COMPLETE and INIT events both fire. And in Firefox and Safari it works too. INIT and COMPLETE both fire. But in IE (6 and 7, both with the latest flash player) on a PC only the INIT event fires.

Code:
var debugText:TextField = new TextField()
addChild(debugText)
var onRootLoaderInit = function (event:Event):void{
debugText.text += "INITIATED." + " "
} var onRootLoaderComplete = function (event:Event):void{
debugText.text += "COMPLETE." + " "
} loaderInfo.addEventListener(Event.INIT, onRootLoaderInit);
loaderInfo.addEventListener(Event.COMPLETE, onRootLoaderComplete);

View 9 Replies

ActionScript 3.0 :: Jpgencoder/urlloader Not Firing Any Events After Second Use?

Nov 5, 2009

I'm using the jpgencoder to save a few thumbnails out from flash. The first time I save an image it works just fine, but the second time I try, the image saves but I get absolutely no events fired off from the URLLoader that I'm using with it. If I refresh and try it again, then again it will work once, but not twice. Here is some sample code of what I'm doing:

Code:
var jpgURLRequest:URLRequest = new URLRequest("JPEGEncoder.php?path="+path);
var loader: URLLoader = new URLLoader();
jpgURLRequest.contentType = 'application/octet-stream';[code]....

View 2 Replies

Flash - Firing Events When SWF File Ends Playing?

Jun 15, 2011

What I want is to play a swf file in my site. And when that swf animation file ends that is fully watched by the User, I want to call a PHP page.

View 1 Replies

Flash :: Events Not Firing In Custom Flex Component?

Jun 24, 2011

I'm taking my first stab at writing a custom flex 4 component by extending the UIComponent class. Unfortunately, I cannot get the component to respond to any sort of mouse events.I've tried setting mouseEnabled to true is the component, as well as setting mouseChildren to true in the parent (the stage object). It seems whatever I do, my click events can be detected from the stage, but not with the component.Here is my component class:

package components {
import mx.core.UIComponent;
public class DrawCanvas extends UIComponent {

[code]......

View 1 Replies

AS3 :: Flash - StartDrag Firing Mouse_up / Mouse_click Events

Oct 10, 2011

As I started developing mobile apps for iOS/Android using Adobe AIR I encountered strange problem (or feature). If you create Sprite and make it draggable using startDrag/stopDrag inside MOUSE_DOWN/MOUSE_UP event handlers, everything works. But if you add another listener MOUSE_CLICK to the same object, it starts to fire together with MOUSE_UP. Logically this behavior is all right.

What I need is to prevent firing MOUSE_CLICK handler when user drags the Sprite (startDrag) and I need it to fire when user did not drag the Sprite. What I'm trying to create is a small thumbnail bar which is draggable and after clicking on concrete thumbnail its large version/image opens up. This is actually not possible as MOUSE_CLICK fires everytime user drags whole thumbnail bar so large image opens up everytime.

View 1 Replies

ActionScript 3.0 :: Data Limit To Sockets - Events Stop Firing

Apr 1, 2009

I have a pretty elaborate class that extends Socket and performs some serialization and data protocol stuff. It works pretty well when I send small messages. However, when I send anything over about 132KB at once, the SOCKET_DATA progress events stop firing -- or at least the function I've got listening for them does. My class is called RPCSocket and I assign the socketDataHandler function like this in my constructor:
addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);

My socketDataHandler function (with lots of comments) is attached. Is there some limit to how much data can be sent over a socket at once? Is there something wrong with my code? Here's the trace output:
Code:
socketdatahandler
bytesAvail:4380
buffer length:0
reading bytes into buffer for concat
buffer length after concat:4380
buffer state:0
[Code] .....

View 6 Replies

Flash :: Keyboard Events Not Firing After Reference The Stage To A Menu Class?

Mar 28, 2011

I'm having a problem with this menu tutorial I followed from ASGamer. I have done and used most, if not all of the tutorials from that site.Anyway my problem is their base menu class;

package com.game.scripts.menu
{
import flash.display.MovieClip;

[code].....

View 2 Replies

Java :: Are Socket's Events Queued In Flash?

Dec 1, 2009

I'm trying to implement a binary protocol between a flash application and a Custom Java Server using TCP/IP sockets, the protocol's messages are of variable length, so my idea is to add a field indicating the number of bytes I have to read before parsing a complete message, something like this:[code]if while processing a message (supossing it is complete) other data arrives through the socket, are messages of type ProgressEvent.SOCKET_DATA queued so the number of times my handler is called is equal (at least in this case) to the number of messages arrived or should I read until all data the socket has available? or simpler: are in general messages for a handler queued in flash?

View 1 Replies

ActionScript 2.0 :: Get A Client Socket Class To Work With Events?

Jun 25, 2006

I'm new here, so maybe i'm posting in the wrong channel. Please tell me if it is the case. I'm trying to get a simple client socket class to work with events. I have tried each example found with google with no luck, i just tried the "radio listeners" example from here, which worked fine until i put the broadcaster object within my class.

[Code]...

View 1 Replies

Actionscript 3 :: Handling Security Error Events On Socket Extension

Oct 11, 2010

i've created a socket extension class. the pseudo code below tries to make a socket connection using the passed parameters. if there is an security error, such as the port number not being an acceptable port number, i want to handle the security error.

however, i can't catch the security error. a popup window appears with a description of the error and my errorHandler function is never called.

[Code]...

View 1 Replies

Actionscript 3 :: Socket.readInt() And C# Socket.Send() Different Values Of Int-variable?

Nov 19, 2011

When I send number (int)52 s.Send(BitConverter.GetBytes((int)872415232));, flash show me trace(socket.readInt()); 872415232 If i send 872415232, flash show 52.Why? And how it fix?

View 1 Replies

Flex :: Actionscript 3 - Flex Socket And Erlang Socket Communication

Jun 29, 2011

I'm creating a client-server game. My client is a flex based game, and my server is erlang server. At the beginning, when I test directly my flex client in flash player, I can establish a connection easily to my erlang server through socket connection. And both can exchange data with no problem. The problem rise when I deploy my flex app at Apache http server, and running it using a browser by calling [URL] my flex socket sends message requesting for a crossdomain policy to my erlang server. So I create an xml message that represent a crossdomain policy, and send it back to my flex app as a response for that request.

Yet still I can't establish any permanent socket connection between my flex client and my erlang server. I know this because I add listener on my flex socket that will modify its internal state to CONNECTED, if a connection between client-server has established.

View 2 Replies

Actionscript 3 :: Iphone - Touch Events Vs Mouse Click Events?

Jan 11, 2012

Just wanted to ask if there is any advantage for either using mouse click event or touch tap events, when writing apps for mobiles or tablets (for the iphone especially)?

I know that both of them should work fine, but in term of performance, is anyone better? Are there any things I should be aware of when choosing either?

By the way am using actionscript3 to implement the app.

View 3 Replies

ActionScript 3.0 :: Mixing Stage Mouse Events And Children Events?

Sep 30, 2009

I have an animation that I want to start when clicking on the flash window. However, I've also have some buttons on the stage. If I add an event listener for MouseEvent.CLICK on the stage, then it 'eats up' the events and the buttons don't work.

I've tried some tricks, by adding some invisible buttons on top of the real ones, and use the MOUSE_OVER event to selectively enable/disable the mouseEnabled flag for the stage, but didn't work because it complains that the property or method doesn't exist (which I find odd).

View 3 Replies

Javascript :: JavaScript Socket Vs Flash Socket?

Apr 30, 2010

Steve Jobs just posted this article on why Apple rejects Flash... [URL] I agree that javascript and css can be used to replicate some of Flash's animation, though Flash does all sorts of scaling and tweening that is incredibly powerful, and I'm not sure that there's anything comparable in javascript, if there is, I certainly haven't seen it.

However, my question is about the socket. Flash has an incredibly powerful openSocket class that allows you to connect to a server and have the server and the client talk back and forth to one another. As far as I know there is no equivalent class in Javascript. Am I mistaken? Is there some secret mystery Ajax class that replicates the openSocket? If not, then that feature alone makes Flash an invaluable tool.

View 1 Replies

ActionScript 1/2 :: Stacked Events - Events Get Added On Top Of One Another?

Feb 24, 2011

I have noticed that using the "addEventListener" and coming back into a frame, I get multiple events tied to the same component.The design I am using jumps to an "I" frame (intermediate) and then back to the "M" frame (main) when the user performs an action.I add event listeners to several components when I enter that M frame. What I notice is that the events seem to stack up for a particular component.
 
For instance, if I enter M frame, N number of times and addEventListener("click", handleEvent) to a radio button, I get N calls to handleEvent when the user clicks on the radio button. I guess this kinda makes sense but is not what I want. I just want one event of a particular type (in this case "click") to be associated with the a particular component. I get around this issue by removing the event(s) in the I frame. Then they get reinstalled in the M frame. Only one at a time.
 
So, just wondering about this behaviour. Is there a way to check for the number of events that are currently active on a particular component? Better way to handle adding events?

View 1 Replies

Javascript :: Engage Events In JS And React To The Events ?

Dec 26, 2011

I am designing a music player using JavaScript (jQuery) and HTML5, with Flash AS3 to fall back. Basically what I want to do is to be able to click HTML control elements and have them interact with the flash in order to play/pause and skip tracks in the playlist (playlist JSON file read by JavaScript, passes file ID to AS3, AS3 reads another JSON file to get URL, then plays audio)

This enables me to only use the Flash to play the audio, thus creating the same user experience regardless of HTML5 browser support. I'm assuming I will have to 'listen' for events in AS3, however any pointers in how to engage these events in JS and react to the events in AS3

View 2 Replies

Actionscript 3 :: Write An Adapter That Maps All The LinkedSetFx Events To The Expected Flex Collection Events(As3Common-collection)

Aug 25, 2010

LinkeSetFx has its own CollectionEvent, but I don't know how to map the LinkedSetFx event to mx.events.collectionEvent(I want use it in ComboBox). LinkedSetFx is in AS3Commons-collection framework.Here is the url, choose the as3commons-collections-1.0.0.zip, you'll find LinkedSetFx in srcorgas3commonscollectionsfx

View 1 Replies

ActionScript 3.0 :: TypeError: Error #1034: Type Coercion Failed: Cannot Convert Flash.events::Event@3738fb79 To Flash.events.MouseEvent

Mar 27, 2012

iam making a game and i almost finish except one error i couln.t get it

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.

[code]....

View 4 Replies

ActionScript 3.0 :: Cannot Convert Flash.events::ErrorEvent@2bb5271 To Com.adobe.protocols.dict.events.ErrorEvent

Jul 1, 2011

I try to dispatch an error event in an AS3 application:dispatchEvent( new ErrorEvent( ErrorEvent.ERROR, false, false, "my error message"));but I get the following runtime error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::ErrorEvent@2c04239 to com.adobe.protocols.dict.events.ErrorEvent.at flash.events::EventDispatcher/dispatchEventFunction()at flash.events::EventDispatcher/dispatchEvent()at my line of code..

[Code]...

View 1 Replies

Actionscript 3 :: Type Coercion Failed: Cannot Convert Flash.events To Flash.events.MouseEvent?

Dec 18, 2011

When I placed this AddEventListener I got this "Type Coercion failed message"

addEventListener(Event.ENTER_FRAME,onEnterFrm);
Located above the mouse event:
addEventListener(Event.ENTER_FRAME,onEnterFrm);

[code]....

View 2 Replies

ActionScript 3.0 :: Why Isn't This Timer Firing

Oct 4, 2010

here's the code.
 
var zipTimer:Timer = new Timer(1000, zipArray.length-1);
zipTimer.addEventListener(TimerEvent.TIMER, onTick);
zipTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

[code]....
 
Now, I can't see, for the life of me, why this isn't firing. It's almost exactly the code from Adobe's docs...zipArray.length is at least 32.

View 1 Replies

ActionScript 3.0 :: HitTestObject Firing More Than Once

Dec 15, 2011

I'm working on a scene where the user can drag sugar, honey and syrup flavour to a cup of coffee and each time they collide, the coffee's happiness is increased by 1. I added a TweenLite so that sending any of the objects to their original positions is much more fluid. The problem is that the hitTestObject is now firing more than once (which makes sense and now happiness is increasing at more than one increment at a time) but how can I make it so happiness is increased just once?

Code:
public function hitsDecaf(e:Event):void{
if (myCounter.myHoney.hitTestObject(myCounter.decafSweetened)){
ifStartTimer = true;
stopDrag();
myCounter.steamHappy.gotoAndPlay(2);
[Code] .....

View 4 Replies

ActionScript 3.0 :: FullscreenEvent Not Firing?

Jan 24, 2008

I have the following:A document class, extending from a custom class, extending from MovieClip. In my document class, I assign a handler to the FullScreenEvent like so:

Code:
addEventListener(FullScreenEvent.FULL_SCREEN, function(e) { toggle_fullscreen(); });

Also, I've set up a SimpleButton to call that same function, toggle_fullscreen, when clicked.Here's the catch:When I click the button, my app goes fullscreen. When I press Esc, the app goes back to normal but the FullScreenEvent doesn't get fired,so I can't catch it to re-align the elements on my stage.I've also tried to add the event listener to the stage object of my document class, but that doesn't work either.

View 4 Replies

ActionScript 3.0 :: KEY_UP Not Always Firing?

Sep 20, 2010

The problem is that I've done a lot of work in my game, and there's too much code bound to shift and control keys. For example you need to hold shift key to select multiple soldiers or control key to shoot or sometimes pause the game or even call a map, a lot of stuff in GUI depends on those keys as well. Both KEY_UP and KEY_DOWN are added to the stage object. But, time after time, there happens a very annoying thing, KEY_UP event just doesn't fire for shift or control (in most cases it does, but not always). That is, I press shift, start selecting soldiers, then release shift but Flash Player keeps thinking it's still pressed, so I can still select multiple soldiers, which is not good.

I found the exact same problem here: [URL]

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved