Add Swing objects in Play 2.0 framework - swing

Good afternoon,
I want to know if it will be possible to add Scala Swing objects (especially JFrame objects) in a Play 2.0 application, I look for something like this but I haven't found nothing.
I need a Text Area that the user can write, and after that when he/she submit, I need to create an instance of a Scala class which after that it will show in a JFrame are (if I can) something related with the textarea input.
I can do the textarea form with HTML but the other part I don't know how to do it if not with JFrames.
Are many other ways to do this?
The example of what I can do is (it's a App related on Lambda Calculi):
x ---> create a Var elemnt and display it in a JFrame
\x.x ----> create a Abs(Var,Var) element and display it in a JFrame
...
Can anyone help me?
Thanks in advance

Piotr's comment is correct; the two technologies (HTML and Swing) are very separate. I'm not sure exactly what you're trying to accomplish; however, it sounds like what you want to do is possible via Javascript. A good tutorial for Javascript can be found here: http://www.codecademy.com/tracks/javascript. Javascript is also very easy to integrate into a Play project; you can place your Javascript files in your project's /public folder and reference them from your HTML files using <script> tags.

Related

Anyone know a list of flash.includes? (as3)

I'm looking for a list of flash.include.whatever.whatever for as3.
If no one knows a list then can someone tell me the flash.include to use for drawing rectangle with the startFill and endFill things? Thanks for any help.
I didn't find anything on either of these googling, and the place I got the code for drawing a rectangle of course didn't have the flash.includes included in the example code... is their a reason so many people do that? Any way I can get around it?
Do you mean you want a list of the packages and classes that come with AS3? That is typically called the documentation and can be found here:
Adobe ActionScript® 3 API Reference
For drawing a Rectangle, you can start at flash.display.Shape. It has a graphics object with the methods .beginFill() and .endFill().
you can using a Graphics.
The Graphics class contains a set of methods that you can use to
create a vector shape. Display objects that support drawing include
Sprite and Shape objects. Each of these classes includes a graphics
property that is a Graphics object. The following are among those
helper functions provided for ease of use: drawRect(),
drawRoundRect(), drawCircle(), and drawEllipse(). You cannot create a
Graphics object directly from ActionScript code. If you call new
Graphics(), an exception is thrown.
The Graphics class is final; it cannot be subclassed.
here is a sample
import flash.display.*;
this.graphics.beginFill(0xff0000);
this.graphics.drawRect(0,0,100,100);
here is a Adobe Tutorial
AS3 all display class list here
You do not necessarily need to default AS3 include. fine compile. But include only the code you can see the hint. perhaps, CS4 after that if you use a specific class will automatically include. or ctrl+space is autocompletion.
As follows by default when you install the flash is because of the SWC path.
As per I know, there is not such a thing like Flash.include. May be you're trying to ask something else or may be i am still unknown about this feature.
If you found any positive thing about this, please let me know, i want to know that new thing.

Code for A Graphical User Interface window

How would someone go about coding a 'window'? I'm starting to make a GUI, and I want to learn how to code one. One that can be skinnable, and one that actually loops and creates itself at runtime. I understand that this might be a bit vague, so I'll add details.
One that actually 'creates' itself. Most GUI tutorials I've looked on depends on an 'image' that just gets added on the screen. I want to be able to use skins in my windows. One where my 'skin' is just a collection of 'borders'. Then when I insert window.create(50,50) where 50,50 is my height, width, It would just create that window, following the skin.
I understand that it probably follows just like when a language draws a rectangle, it just follows a different set of rules (maybe?). However, for all my Google-fu skills I cannot find a tutorial that teaches me this.
Please Help. I didn't include the language I used as you can see, because I believe I just need to know how to create one. Anyway though, I am using Actionscript 3. A tutorial would be just fine, or even A SINGLE CLASS THAT HAS THIS FUNCTIONALITY, I'll just study the code. Or if you know one, maybe a whole book about GUI and programming it :D
Pure As3.0 GUI coding is quite troublesome. I try to Googling, but not come out well. anyway for my case, i generate using a SWC, and Class Mapping and Customizing. but i'm not sure best way. in other way i use a bit101 library. this is gives me want Window, Charts, Componets easily of high abstraction. see the below image.
It can be pretty hard and complicated to do, or very easy, it just depends on how flexible your solution should be. You need firstly to design a structure of your program and approach to the problem.
I like to go from the image of how it should look like from API point of view. I think I would create a GUI element like this:
var wholeGui:MyGUI = new MyGUI();
var window:IGuiElement = new GuiWindow(dataObject, skinObject);
wholeGui.addElement(window);
So what would you need?
1) Object that would manage all GUI elements. Why? Simply because your GUI elements shouldn't be destroyed by themselves if user will click "X" on your little window. The wholeGui object would manage them and listen for any events including those that would destroy them. You may consider creating custom events for interaction between the wholeGui object and your window object if this interaction is going to be complicated.
2) Interface for your GUI objects. Some problem here is that AS3 actually doesn't have interface for Sprite, and you would like to interact with it like with extended Sprite. The workaround here is to have in this interface a declaration like this:
function asSprite():Sprite;
And your implementation in GuiWindow would look like this:
public function asSprite():Sprite {
return this;
}
And your GuiWindow class should extend Sprite of course. Then you would have access to it's Sprite properties and methods by writing for example: window.asSprite.startDrag();
This interface should give you abilities that you need to operate on your GUI element.
3) Class for your GUI element, in this example GuiWindow.
4) Class for your data that would be injected into your element. If you would load data dynamically, and from some location, you would need to deal with the situation when no data can be provided - but that logic would be inside your window.
5) Class for your skin - so you would be able to dynamically create a skin object and use it to create your window in a way you want.
That's just few thoughts to consider.
PS. It may be good idea to fill GuiWindow object with data AFTER creating it, and not in constructor, as you would be able to visualize loading process then.

deep linking from xml to open function in Actionscript

I have general text in CDATA in my xml which is pulling in content into Flash. This is working well and I am able to add images this way too. What I need though is to wrap that image in an tag which, when clicked on will fire off a function in my Actionscript 2 to launch a video.
Could someone please tell me how I would go about this? Is there a better way than the way I am thinking right now?
Thanks.
I recently did this in AS3 but I found the AS2 way.
Tested it:
function myFunc(arg:String):Void
{
trace ("You clicked me!Argument was "+arg);
}
myTextField.htmlText ='Click Me!';
You just use a href that is set to asfunction with a function name and something to pass along.
See:
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary073.html
Just to give credit I found the initial code at: blog.activepoison.com/?p=25.

Is editing parent html page from the embedded flash file possible?

A client wants the company I work for to build an expandable flash banner, I'm a dev, so my solution is: stack 2 flash banners, small one visible, big one on top of it, with display:none, catch the click event, animate the big one into position.
The client wants it done without javascript (their banner rotation network doesn't support additional javascript).
I'm baffled, as I have no clue how a flash file can modify it's own html embed code and the css styles and as far as I'm aware, it's not possible.
Any suggestions/ideas? Is there an api in flash to talk to the html file, is there some actionscript magic that could make this happen?
Thank you for your time
You can talk to the parent HTML file via the ExternalInterface API.
You can pass the call() method entire javascript functions to do what you need. This way, you don't have to add extra javascript to the parent HTML file.
For example:
ExternalInterface.call("function() { document.getElementById(\'foo\').dosomemagichere; }");

Is there a workaround for the missing ExternalInterface.objectID in ActionScript 2

I'm downporting some ActionScript 3 to ActionScript 2 (some ad agencies sadly still refuse to embrace the future) and I've run into the issue that in ActionScript 2 ExternalInterface has no objectID property, as it does in ActionScript 3.
The code I'm working on calls a lot of JavaScript, and some of that code requires the script to know the ID of the Flash object/embed (for example to find the position on the page, and to resize the object/embed).
Is there a simple workaround to get hold of the object/embed ID in ActionScript 2?
I have managed to write some JavaScript code that basically searches all object and embed nodes on the page until it finds one with a special method (set with ExternalInterface.addCallback) and that way managed to get the ID into the ActionScript environment, but it feels like a hacky and unsafe method to rely on. Surely there is a simpler way?
Edit: I don't have control over the code that embeds the SWF, so passing in the ID doesn't work.
Is this what you looking for?
Simple actionscript 2 class that find it owns flash html object id.
http://sourceblogg.se/lang/en/mina-projekt/isitme-get-flash-html-object-id-within-flash/
What about passing the ID to the SWF via FlashVars? You should know the ID when you embed it, so it should be easy enough to add it as one of the FlashVars variables passed to Flash. Then store that somewhere your code that calls ExternalInterface can get at it.
Try the Flash Javascript Integration kit http://weblogs.macromedia.com/flashjavascript/ .
As far as I'm aware, the ExternalInterface class in AS3 was a formalisation of this AS2 solution.