I am stuck with a Flex 3 legacy application and I need to be able to dynamically apply generated Sprites containing different gradient fills as well as Embedded SVG images to the icon of a button. Can anybody help with how I cast the Sprite to the button icon? Do i have to copy the image data out of the DisplayObject and cast is as a Class somehow?
thanx,
Related
I have a custom banner maker program in which the following can be done:
Different banner shapes can be selected (Buttons clicked to place the corresponding movieclip onto the stage)
Different banner colors can be selected by using a ColorTransform that is linked to buttons i.e. a red button turns the banner red
Textfields can be added to the stage, dragged and dropped using startDrag and stopDrag, and the text color can be changed with a ColorPicker as well as being able to change the font size and font itself
Pre-loaded images can be selected from a panel and added to the banner (Buttons that are clicked to add a corresponding movieclip to the stage)
Images can be uploaded directly onto the stage and can be resized
I need to figure out a way of being able to essentially add undo and redo features to do things like remove an image/textbox that was placed, change the banner color back to whatever color it was previously, reset the position of an object that was dragged from its default position etc.
I'm not sure how to best go about this using AS3?
Not hard. Use removeChild(instance name of Child here) to remove an object from the stage.
Atriace's idea is sensible. You didn't say if you'll want to remember the positions of things after you stop running your program. Or is it only while you're running?
If the latter I'd create an array for each banner or textfield, and store in that array the current values of the properties you want to record. So, for instance:
var A:Array = new Array
A.push(textfield1.text)
will put your current text in textfield1 into the first index position in array A. You can call that little bit of code when you initially add the text (on a button click or whatever). Later, if you want that text back you'd do it like
textfield1.text = A[0]
assuming that your old text was in the first index position in the array.
If you want to remember values between runs of the program use a SharedObject to write the value to disk. Too much to write about that here -- look it up!
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.
I want to load the image dynamically in Flash actionscript, like this :
When the user select the image it should contain inside the frame instead of black plane box. I am thinking If I can apply that image as background image for that black plane box (which I draw separately inside the frame) that would be great. Because over here the issue is the image should look like 3D inside the frame, so maybe the background or texture method will solve this problem. Please friends give me suggestion...
Thanks.
I don't know if the title is misleading as the image I'm loading is actually a sprite image consisting of a multi-state button. I want to load this image and split it into several display objects (sprites?) in AS3, to create a SimpleButton with an over and down state.
Right now I'm just loading the image with Loader and URLRequest, and then creating a sprite from the loaded content.
Is this possible or is there any other way of doing this, without having to load two separate images?
Thanks in advance,
Pierre
There is. You can use the mask function of the Sprite class. First you set the mask to normalstate button part of the image,, and on mouseover you set the mask to the other state and on mouse down you set the mask to the clickstate button part of the image
Please mark as answer if this helped.
I have a function that displays an image on top of a movie clip but when you click another image, it of course replaces the current image. I don't know how to stop it from replacing the image, that way I can make an image appear and drag it over somewhere on the stage and then make a different image appear and drag that somewhere else, too. and what is the drag event for Actionscript 3.0.
Sprite or MovieClip startDrag() and stopDrag() methods.
also i don't understand the following:
function that displays an image on top of a movie clip but when you click another image, it of course replaces the current image
how do images get inside of your swf (library, embed, loader)?
why are they replacing each other on MouseEvent.CLICK?
according to my current vision of your problem Event.stopImmediatePropagation() or Event.stopPropagation() in MouseEvent.CLICK handler function may help