image in clojure - swing

I made a frame give a title to it and I added buttons to the frame using clojure. I am not able to guess how to add background image to my frame.
I have a background image stored in the drive, I tried adding the background image in doto panel but it showed series of errors.
Help!

You need to go a little bit more deep than that. paintComponent of JPanel is your entry point. Inside paintComponent you can load the image in draw it.
After that, you call getContentPane().add(new YourJPanel()) of your JFrame.
One a side note. If you are planning to do Swing development in Clojure, did you consider: Seesaw?

Related

Actionscript: Make a mask follow a line (and "grow")

does anybody know/have some idea how to make a mask follow a line? Basically I have a drawing made with 1px line and I need to gradually mask this shape so it actually looks like it is being drawn. The thing is that I cannot just increase the width of the mask (it would simple draw a vertical line in one step which is not desired), it has to be a linear movement along the "guide" line, so the vertical line gets drawn in several steps. Doing this manually will/would be a major pain. This is what I am trying to achieve:
Thanks a lot!
You have to do it manually. Though there are some shortcuts you can take:
Create a Guide layer in Flash Pro.
Copy a vector of your path to this guide layer.
Create a new layer below it, put a circle on that layer at the start of the path and make a classic tween of that circle.
Dock your circle layer under your guide layer and at the last frame of your tween move the circle to the end of the path. This will make the circle go along the path.
Follow the animation and manually fill the covered parts.
Put your guide, circle animation and following animation into a MovieClip and put it above your to be masked symbol and make its layer a mask.
Here's an example I made for you if I wasn't clear enough: http://db.tt/kvaaYaLA
Note that this method is only useful if you need a static animation, not for a dynamic one.

comparing image in cocos2d-x

I'm making a game with cocos2d-x HTML5.
On one layer there are two images which is almost same but have several different area and when I click one of them, if the clicked area of two images has a different pixel, I want to add a sticker to the same location to both images.
I want to ask that how can i compare the image pixel on cocos2d-x HTML5?
and how do I make the click event to place the sticker?
Probably CCImage class will help you.
What I suggest is, as you already have 2 images, and you have know the different area,
you can create a plist Dictionary recording the area position and size.
In your game scene, you can add transparent touchable Sprite created from your config list file, and set a color to it when it is touched.

Unknown error AS3

Well, it's not an error, actually. I have wrote a game. There is only one keyframe on the main timeline (I don't mean one layer, there are lots of them, just like different MovieClips). Currently, I'm not using TextField anywhere, but I want to, because I need to display score on the screen. When adding TextField through Flash CS5 and naming it, when compiling, unknown window appears, you can see it on the picture. Not quite sure what it means. When clicking OK, window disappears but instead of my program there are three dots on the screen, you can see them also. I have no idea, neither of what is this, or how to fix it. Any hints? Thank you in advance :)
By the way, on one of the pictures, you can see what the game should look like. And as I said, it does, until I add some TextField to it.
it seems that you're using the TLF (text-layout-framework) in your textfield by accident.
this is a RSL (runtime shared library) that the flashplayer has to load before it can show your content. (and i think the dots are some kind of preloader that adobe puts in there ...!?)
but you don't need the TLF, you can just use a simple TextField.
select your score-textfield and choose "classic-text" in the properties window ... think that'll remove the TLF from your project. (if you have more than one TextField, check every one of them for "TLF text" and change it to classic).

Detect control overlapping in Flex 4 while an object is moving?

I have this small project HERE. Right now it barely does anything but make the character move.
I move the character by using <s:Move>. Now as you can see on the link to my project page, it moves to where you point the mouse and click. I want to be able to stop the character from moving if it hits another object or in this case, the "tree". Is there a script in AS3 that will let me detect collisions or controls that are overlapping each other?
If my question is a bit lacking information, please comment back here and I'll update it with more details as you need.
Please and thank you!
All DisplayObjects have a a method called hitTestObject(obj:DisplayObject) that tests when one object overlaps another. You can read about it in the Tree class, DisplayObject class, or any class that extends DisplayObject.

AS3 How to center MC + change background color?

I am quite new to AS3 and I have never worked with classes, so I am encountering a couple of problems.
I'd like to center a movieclip, have it so that it doesn't scale. And then I'd like to add a background color that stays there no matter how I scale the browser.
Can someone please explain me this in babysteps? Since I don't know how to implement a class and make it work with my fla.
Thank you so much!
J.
If I've followed you correctly, you want to have your swf file in the centre of a webpage, to change the background colour, and to stop the swf from stretching if you drag the boundaries of the web browser around?
If so, your question is a more HTML related, as none of that can be accomplished through ActionScript. If what you want to do is position your swf inside an HTML file correctly, you can make Flash export the HTML file for you (assuming you're using the Flash IDE).
Here's a link that'll guide you through the process of doing that, it's very clearly written: http://www.w3schools.com/flash/flash_inhtml.asp
To change your web page's background colour, see this site: http://www.tizag.com/htmlT/bgcolor.php
Once you've got that HTML file exported from Flash, you can check how it will align your Flash swf to the rest of the webpage. Somewhere in the code should be something like align="left", and you can change that to centre, right, etc.
Hope that helps,
debu
to center it you can do:
var toCenterMc:MovieClip = new MovieClip();
toCenterMc.x = stage.stageWidth/2 - toCenterMc.width/2;
toCenterMc.y = stage.stageHeight/2 - toCenterMc.height/2;
backgroundcolor you can add with this tag (it has to be above the class header, that means the code line that says public class example extends exampleparent):
[SWF(backgroundColor="0xec9900")]