Donovan H main header graphic Art, Graphics, Development, and other things creative... Art, Graphics, Development, and other things creative...
left menu top

Catagories

#Actionscript #Art #Blender3D #Charity #Cooking #Design #Flash #Free! #Games #IT #Java #Javascript #Life #Music #PHP #Programming #Video #Web #Work

Posts

CSS/JS 3D Cube

FeedMeComics Beta Launch

Shadowrun: The Anarchy Wars

J-B Weld a Bicycle Peddle to the Crank Arm

Introducing PolySure

Cyber Monkey 3D

Famous Artists in Modern America: Raphael

Arts Shows and Photography

Controling the Google Map Iframe

The Dark Lord Rises

Custom Form Check Boxes - JavaScript Class

HTML Color Selector Class

Styling Snipt Code Embeds

Simple Accordion JavaScript Class

I Stand with Rand

Glen Bradley for NCGOP Vice-Chair

CSS 3 @(at) Rules and Font Embeding

Happy New Year, New Site!

Making a Simple House with Blender 3D

Happy, Mic Check 121212

Making Mountains with Blender 3D

Bash ~ indexOf

Ana's Corner

ConstitutinalWar.org

Midwife Advocates Website

My Own City - Part 2

Virtual Box VS. VMware

My Own City (In Blender 3D)

The Return of DonvanH!

Geishas and Watercolor

More Vector Cartoon People

Basics of Graphic Optimization for Flash

Veterans for Ron Paul 2012

Dynamic Draggable Divs

AK Donovan Sole Brutha ~ Time Lapse

Disengaged Reality ~ Time Lapse

HTML5 Canvas Drawing

AnimatedImg - Javascript Class

CyberMonkeyDev.com Up

Charlotte, Photography, and Penguins

North Carolina CPM Rally

DJ The Sypher @ Heaven and Hell

Making a World... Map

TDI Site Complete

AS3 vs HTML5 Drawing

Poked in the Face ~ Time Lapse

WeAreChangeDC.org BETA up!

Jordan

Grendel Babies

SamMenkmeller.com is GO

Prince of the Pavement

Speed cooking for 100

AS3 to Clipboard to JAVA communication

Lighten Up ~ Time Lapse

AmbieMac.com is Up

Revisiting Design

Howl's Moving Castle

End the Fed 2009

Chicago!

Timer Tools AS3

Free Wallpapers!

Flash to PHP communication

Dynamic Timer Event Handling

JavaScript XML node array

XML to JavaScript structure return

Appalachian Trail

AS3 XML class [dXML]

Let Oklahoma Vote

MurderOne Shirt App

Stelor Games

Universal Click Handler

R,G,B, to HEX and back

Snipt.net

Kirupa Art Contest, 2nd!

AS3 Preloader Class

Purple Cauliflower

Paul is FREE!!!

Wallpaper tutorial

My First C++ App

Vigilant Logos

Free Paul Jacob

XML picture displayer

Flash Web Site Template

Afterdeployment.org

Easy Effects AS3

Election Judge

Attack of the Frownies

Gootropolis On-line World

Ohio Valley Recovery Inc.

Symphony City

Challenger Learning Center Site

CLC, E-Missions Site



Click to show the previous background image. Click to show the next background image.
blog title



AS3 to Clipboard to JAVA communication

2/26/10
Java and Flash icons connected conected by circuts.
After having trouble finding a good example of how to pass information between an ActionScript module and JAVA module I came up with the fallowing solution; Instead of using direct communication (which I was having all kinds of problems with) I simply used the clipboard as a median between the two modules.

You will need the fallowing:
1 = something that can compile ActionScript as .exe applications. I'll be using Adobe Flash CS4.
2 = something that can compile .jar applications. I'll be using NetBeans.
3 = YOUR BRAIN! I had to use mine :)

What we will do:
We are going to build a simple AS3 application that sends data to the clipboard and then runs a .bat file. This .bat file executes a .jar file that grabs clipboard data and tries to make a file out of it.

Ok, let's get started. First thing, lets build our flash interface. I'll be naming the flash module AStoBatch. Make two input text boxes, call one _file and the other _content. Make sure _file is set for single line only, otherwise it sends some funk to the clipboard that will confuse our JAVA app later. Make a MovieClip (this will be our button to send the data) and name it _build. Ok, now lets add our functionality, put this in you main class package:



Now we need to export our flash module to an .exe, using Flash CS4 all you need to do is check the box in your Publish Settings and then Publish the project. Why do we have to make it an .exe? Well the AVM will not let .swf files execute/run our important fscommand. This can only be done from .exe for security reasons. Sweet! Let us move on to building our simple .bat file. Now the important thing to know here is, any call from an AS3 module to fscommand must reffer to a relative folder called fscommand. So in the same folder you just published your AS3 app to, make a folder called fscommand. Ok, now make a new text file in our fscommand folder and rename the file to RunJar.bat. For those of you unfamiliar with .bat(batch) files, they are terminal files (command prompt) that execute a series of commands. In our RunJar.bat file drop this line.

java -jar "../dist/BuildFromCBD.jar"

Ok, so all we are saying there is: go back to the root folder, go to the dist folder (will be made later) and execute the BuildFromCBD.jar (will be made later). Now is that time to make our .jar file. Open NetBeans (freeware) or what ever your pleasure for JAVA scripting is. Make a new project called BuildFromCBD. And drop this code in your main project file:



Now compile the .jar and you will have (if using NetBeans) a folder called dist (the one our .bat file points to) and in it will be the BuildFromCBD.jar file. Super sweet! Now I'm not going to explain every piece of code for you, but If you would like, DOWNLOAD THE EXAMPLE PACKAGE and there you will find the proper files all commented for your understanding. So, please feel free to e-mail me if you have questions!