AS3 different image when a button is in use - actionscript-3

I have an application for kind of like a homemade microsoft paint made completely in AS3, I am not that advanced in actionscript, but I will ask you my question and thank you in advance!
So I have buttons, each button is a drawing tool, and I want the icon for the drawing tool(button) to be something different than when it is up, down, roll, hit. A compleletley different image to appear ontop of the current button so the user knows what tool is in use while they are using it..
What would be the easiest way to do this with AS3, the timeline and use of movie clips?
Thanks!!

You want to define your button as an instance of SimpleButton, then set the images directly. Kind of like this:
var clearBtn:SimpleButton = new SimpleButton();
clearBtn.upState = mc2;
clearBtn.overState = mc2a;
clearBtn.downState = clearBtn.upState;
clearBtn.hitTestState = clearBtn.upState;
Which I took from a similar question / answer posed on the adobe forums.

If you have these buttons as MovieClips - just change their type to Button in the library. Each button has four keyframes 1- default state, 2 rollover, 3 hit and 4 hit area.
That's the easiest solution without coding.

Related

How to change the color of a rectangle border in actionscript 3

I am currently following an online programming class at my school. We are studying Flash and therefore actionscript 3 and I am having difficulty in one of my projects.
I want to easily be able to change the border color of my button when the user clicks on it but I can't seem to find how. Until now, I used to change the entire button's color, but I want to try a new effect. To change the entire color I used this code :
var ctAvance:ColorTransform = btnAvance.transform.colorTransform;
ctAvance.color = 0x00CCCC;
btnAvance.transform.colorTransform=ctAvance;
Thanks a lot in advance!
its a possible duplicate of this question
its impossible in that way (using ColorTransform) however:
you have another option, if your btnAvance is a Movieclip or something else, convert*1 it to a Button instead, then inside your object, you have 4 frames in the names of Up Over Down Hit, under Over frame press F6 (insert keyframe) and simply change your button border color
Edit:
*1 : you must convert it in library, not only your instance in stage, find your btnAvance in library list, rightclick on it then select properties and change its type.

User interface flash AS 3.0

since the Site seems to be pretty buggy i have to post my question below. Sorry for the inconvenience.
Hi guys
I'm new to flash and i want to create a GUI for my little game.
How can i create a start window where I can select stuff like how many objects to spawn or move speed of my character.
My first idea was to hide everything else on the stage until I click start.
Would that be right. Is the a better way. how to do this anyway.
And where do i put my GUI script. Stage or extern class.
Place your start button in the first frame and put your other elements in second frame. On click of the start button gotoAndPlay to next frame.

How to detect HOVER/CLICKS in Starling button with LeapMotionAS3

I want to click on Starling buttons using the LeapMotion SCREEN_TAP gesture.
This is possible? To click the Starling button and see the regular push/shrink effect on it using this gesture?
If not...what is the best approach to achieve this?
Any help is welcome!
Regards.
I assume you could do this (I have never done it but I think it should work):
Check whether the tap's coordinates are over the button
If they are, swap the button's texture: var up:Texture = btn.upState; //save reference
btn.upState = btn.downState;
After X milliseconds swap them back: btn.upState = up;

Flash CS3 (AS3) is giving my graphics (buttons and movieclips) outlines

So, I'm pretty much a beginner in Flash and Actionscript (using AS3, as I said in the title), and I'm trying to make a basic escape the room game. I haven't gotten far, and right now that's because every time I test my game (or publish preview it) the graphics get this annoying outline. Here it is when tested: http://i305.photobucket.com/albums/nn228/chokingondrama/flash.png
Every outline corresponds to some object present in the game, most of which have an alpha component of 0 since they're on different sides of the room. This didn't happen before, but once I added the code that allowed the player to change their view with the arrow (each viewpoint/wall is a different frame) these appeared.
It's a little different when published to HTML, basically it just gives each image a white background: http://i305.photobucket.com/albums/nn228/chokingondrama/html.png
Also, it would be nice if somebody could give me advice on how to make sure importing to flash won't result in lower quality.
Thanks in advance. If needed, I'll post any part of the code.
Some tips:
Don't set alpha to 0, instead use the visible property, setting movieclip.visible = false will make it a lot more efficient.
As for the importing and quality, after you import to stage or library, bring up the library (ctrl + l), and right click on the file you imported, go to properties. If it's an image, set compression to lossless, and allow smoothing.
For audio, go to file-> publish settings, and change audio stream and audio event (whichever you might use) to 128kbps.
As for your main question, I need more info, if you want you can post your source. It might be because of how you are placing your graphics on the stage.
For each of your MovieClips in question:
Try disabling button mode and see if the rectangles go away.
movieClipName.buttonMode = false;
If that doesn't help, or you really want button mode, try setting
movieClipName.tabEnabled = false;
There's a chance that since you added keyboard interaction each of your MovieClips are now expecting to be selected by the user when they press the tab key, much like any normal web form.
tabEnabled in the docs
You could also try
movieClipName.focusRect = false;
focusRect in the docs

How to click through a display object in Flash with AS3?

I am creating a photo editor app where, at some point, the photo you edit is supposed to be dropped between two layers of DisplayObjects (a background image and an image mask.)
There is a problem, though. When the image you are editing is dropped between the background and the image mask layers, it becomes unclickable, and therefore gets stuck there, with no chance of dragging it again. (The photo editor uses TransformManager library.)
I am looking for a way to allow you to select the image you are editing no matter if there is another DisplayObject on top of it. And that probably means finding some way to click through the image mask.
Is there a way to do that?
I tried setting mouseChildren = false on imageMask, but that didn't have the desired effect.
Many thanks.
I had similar problems and I managed to solve it by using both
displayobject.mouseChildren = false;
and
displayobject.mouseEnabled = false;
on the object that you want to click through.
How about this?
mask.mouseEnabled = false;
You can always attach a Mouse Click listener to the container, and then either use GetObjectsUnderPoint and check for your object or do a hit test and see if the mouse position is over your intended object.
The hit test would look something like this !this.YourPhoto.hitTestPoint(stage.mouseX, stage.mouseY, false)
b
If I understand your problem, this handy class should solve it:
http://www.mosessupposes.com/utilities/InteractivePNG.html
Take a look at what senocular does here, specifically in the handleUpdate method. Basically: getting a list of everything under the mousePoint to find your object.
I think I stumbled upon similar problem, although in as2.
In flash when you position movie clip over movie clip, and the movie clip on the top has any mouse events implemented, it captures all mouse events so they never reach occluded movie clip.
The solution is not to have any mouse events for the top movie clip and have the movie clip positioned at the bottom capture mouse event and redirect some of them to the top movie clip (you can check mouse position with hitTest to determine if they should be redirected).
i had a strange bug i used;
movieClip.mouseEnabled = false;
but wasn't working for some reason.. was driving me crazy!! as i have used it so many times before. tried lots of different things nothing worked then i deleted the MovieClip and the created a new one and worked.. so the MovieClip's contents must have been corrupt or something as it had a old dynamic Text Area box embedded within the MovieClip.
hope this helps someone out there..