View Full Version : Interacting flashes
neo_philiac
05-12-2008, 07:29 PM
OK! I am back again!
So I have been trying to figure out a way to get two flash programs to communicate with each other. So, for example if I create a swf file and open it up in a browser, I want it to communicate with another swf in another browser (another window - same machine). Can anyone please give me an example?
Thanks
p.s. Medyman you gotta help me! Its that project I have been working on. Since I cant make it full screen I need two separate flash so that I can blow them up on each screen.
Medyman
05-12-2008, 07:48 PM
Forget what I posted before. Update below:
I was only kidding. Just wanted to scare you :p. Yup, that's it. I couldn't have been so stupid as to forget how I did this same exact thing 6 months ago. If you didn't happen to catch my previous post...I posted a solution to a non-local application (i.e. communicated between 2 different computers). You would have to use something like the $4,500 Flash Media Server or the open source Red5 Server to accomplish that. I forgot that your application was all local, so the below will work for you:
Anyway, if your sufficiently offput by the media servers...
look into the LocalConnection class which is made to do this same exact thing -- send instructions from one SWF to another. The limitation is that it has to be on the same computer. It can't be done online (as in from one computer to another via the internet). So as long as it's a local application, which I assume yours is, that will 100% do the job.
Wow, that was embarrasing. Sorry about that.
You *could* also use the External API to talk between SWFs using javascript. Since your application is unidirectional (i think), that would work too (though, might be a bit of a resource hog).
Medyman
05-13-2008, 10:51 PM
Neo...
were you able to get this to work?
If not, I just found some localConnection demos that I have laying around. If you'd like I can post them.
neo_philiac
05-15-2008, 08:06 PM
Hey Medyman sorry for disappearing! I have been crazy busy with my new file server. But dont even apologize, you have been a great help so far. I will get my hands dirty again with this one. If you can provide me with the demos, it would be great help. By the way everything is local. I dont intend to do it online.
Gotta run! I will look into localConnection also.
Thank you!
neo_philiac
05-20-2008, 01:01 PM
Hey Medyman :
Do you have the demos?
Medyman
05-20-2008, 03:10 PM
Ahh, sorry. Forgot all about posting those.
Here (http://www.mediafire.com/?9s9g8mwdg4m) they are. I could have posted them on a website, but browsers create too many variables with localConnection. Your best results are going to be if you just open the .swfs up directly.
I've included Flash 8 and Flash CS3 sources in the archive. In each case, outgoing specifies the .swf controller and incoming is the receiver.
I've included three examples.
1) Text Field: As you type in one, it gets copied into the other. Very basic example to get used to the localConnection syntax.
2) Shopping Bags: An example using MC Tween to animate the bags in the controller. The animation is copied to the incoming .swf (without the use of MC Tween).
3) Flash Folder: An example using startDrag() and stopDrag(). Click and drag around the flash icon in the controller, and the motion is copied in the receiver.
I picked these because I think they have the most relevance to your project. I tend to use the same naming convention when I build these demos...so, don't get confused between my variables and actual AS syntax. For example, I've called each instance of the localConnection class "lc". That's just my preference. You're free to call it whatever you want. Let me know if you need more assistance with this.
ReadyToLearn
05-21-2008, 12:56 PM
Vishal, could this method work online? I know it has to be local, but is that implying offline. Wouldn't these movies in a browser be on the same client so therefor be accessing each other "locally"?
Don't worry, I'm not adding this to my website! Just curiour :p
Medyman
05-21-2008, 01:26 PM
Well, yes. They would "work" when embedded within the same (or even different) web pages because as you say it's still the same client. The reason I said that browsers aren't reliable for localConnection is because each browser has it's own unique security protocol.
Some uses of localConnection fail under that. Also, the flow of data is slower when embedding into a browser -- so you might not get perfectly in-sync motion.
But yes, it's possible.
neo_philiac
05-23-2008, 02:37 PM
So I am having a new problem :( The problem is, whenever I change a monitor, the size is inconsistent. Let me explain a little bit, So what I am actually doing is drawing a rectangle 37.8 X 37.8 Px. Which is equivalent to 1(one) cm. So what I do is, I simply take a ruler and measure the size of the shape. I want the shape size to be consistent regardless of the monitor. Is there a workaround?
Medyman
05-23-2008, 05:47 PM
1. Are you using different resolutions on the monitors? Are they of the same aspect ratio?
2. Have you tried using noScale mode?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.