Actionscript 3 :: Flash - Applying Mask To Multiple Images?
May 7, 2011
I am writing an application that looks into an XML file and pulls out the images within. I would like to pull out the raw images and apply a mask to them dynamically.As you can see below i create a blank movie clip and put the images into it.. At this point i want to create the mask.
var thumbLdr:Loader = new Loader();
var thumbURLReq:URLRequest = new URLRequest(galleryDir + thumb);
thumbLdr.load(thumbURLReq);
I have a mask and I want to take 12 images and put the same mask to it and then loop them.I can apply the mask to one image but would this be easier to do in actionscript or am I completely off base here?
I have a series of images I'm adding to stage from the library. I need them in separate movie clips for tweening. If I create a new layer... add a shape to the layer... mask the layer... finally, add a layer below that layer (with nothing on it) then all of the images I've added from the library are masked. No matter what I try with code however, I can only get one image to be masked. must you create a new mask for each image you would like to mask? I thought maybe if I could do it all in one go on a layer, there must be some code that allows one shape/mc/object to mask several clips.
I have a sprite called MaskSprite, and another sprite called PhotoSprite, with this relationship:
PhotoSprite.mask = MaskSprite;
Now MaskSprite contains a bunch of sprites as children...basically, what I have is a bunch of rectangles spaced apart, so that only strips of PhotoSprite are revealed. This works fine. But I want to blur each of these individual child sprites...but the revealed parts of PhotoSprite aren't blurred in any way. Isn't it as simple as:
Code:
for(var i = 0; i < 10; i++){ var s = new Sprite(); MaskSprite.addChild(s); s.graphics.drawRect(etc etc etc); s.filters = [new BlurFilter(10,10,1)];
Ive searched and found this property .smoothing = true; But since im not using any bitmap vars i dont know where to put it, or maybe is it impossible to smooth images from my code and i need to rewrite it with bitmap stuff?
PHP Code: var myXML:XML = new XML(); var XML_URL:String = "newsXML.xml"; var myXMLURL:URLRequest = new URLRequest(XML_URL); var myLoader:URLLoader = new URLLoader(myXMLURL); myLoader.addEventListener("complete", xmlLoaded); [Code]....
way to smooth my images via ac3. Ive searched and found this property .smoothing = true; But since im not using any bitmap vars i dont know where to put it, or maybe is it impossible to smooth images from my code and i need to rewrite it with bitmap stuff?
ActionScript Code: var myXML:XML = new XML(); var XML_URL:String = "newsXML.xml";
I have the following code on frame1 of my movie that I want to apply to multiple instances of the same movie clip:
mainClip_mc.subClip1_mc.specifiedClip_mc.onPress = function () { //code begins SpecifiedClip_mc exists in subClip1 through 4. Is there a way to do this once without having to say: mainClip_mc.subClip2_mc.specifiedClip_mc.onPress = function () { //same code mainClip_mc.subClip3_mc.specifiedClip_mc.onPress = function () { //same code mainClip_mc.subClip4_mc.specifiedClip_mc.onPress = function () { //same code
Essentially, specifiedClip_mc's parent clip is what's throwing me here. The code to be applied to specifiedClip_mc is identical and I'm not going the correct route by doing this the long repetitive way.
how to group objects together so that you can change their parimeters all at once. Like if I have a 7 boxes on screen with the instance name box1, box2, ect..... and i wanted to do change them via action script, like make them all partailly invisible when an event happens. How would I do that. I've tried stuff like
i need to apply one function to multiple moviclips. the problem is that every mc has different behavior. for example:
movie clip A need to change it position when condition is "true" to point 50, 250. movie clip B need to change it position when condition is "true" too but to point 75, 100.
is there anyway to define different parameters to the function according to the movieclip name?
I have a group of 16 images that I would like to load 1 of each into each movieclip. I want image1 to be inside of visual1, image 2 inside of visual2, and so on. the images are named like, 1960s_(1).png where the 1960 (year) part is coming from the rangeNum variable. The above gives me this error: 1061: Call to a possibly undefined method addChild through a reference with static type int.
I have a large amount of btn's that load full size images when clicked. I simply want to add a filter, scaleX and scaleY to each of those buttons and I know there is a better method then typing each btn name with an eventListener for the Mouse_Over and Mouse_Out events. I understand that I need to create a variable of a new filter and then apply it to the display object. Like so..
var glow:GlowFilter = new GlowFilter(0x0066FF, 1, 10, 10);function hover(event:MouseEvent):void{ pic1_btn.filter = new Array(glow); pic1_btn.scaleX = 1.02; pic1_btn.scaleY = 1.02;}pic1_btn.addEventListener(MouseEvent.MOUSE_OVER, hover);[code].....
So if I were to continue this, I would have to type out pic1_btn, pic2_btn, pic3_btn and so on to apply a filter to each object and also type out the object name for each listener.
I was just wondering if there is a way to simplify this code. I have 3 identical movie clips and I use actionscript to alter the color to the same color. Right now I use 3 different colorTransform variables. Could I just use one since its all the same color? How would it look like.
So far, naming all the movie clips the same instance name did not work. Is there a better way?
I made an mc which on being hovered makes a wave. The problem is that I can't think how to apply the code on about 15 mc's. I used the main timeline for coding purpose. Now I want to apply the same waving pattern to the other 14 mc's. I tried the for loop but couldn't get it to work because of the variables involved.
Here's my code- k = 100; t = 0; ascend = true; waver = false; waving = false; [Code] .....
I am developing a paint board application using flash builder. User can draw some shapes objects(ellipse, circle, rectangle). I want to implement grouping/un grouping feature some like ms-word in my application. I group multiple objects by putting them inside a container(UIComponent). Now i apply resizing to container and it resize well. I am using a free object handler API to apply selection handle over the container. I want to resize and reposition all children with respect to container changed size. Every thing goes well until all children inside container are having rotation = 0. But if there is any child which is having rotation >0 and <0 things goes worse. The child resize but not in a proper manner. I stretch the parent container width and it increase the height of rotated child. Is there any way using Matrix class or something else to transform all children in same direction and same ratio respective to container?
...for example, I'm trying to import a sun shaped PNG... I want the suns rays to act as the masking object... so I can see what's beneath it through the rays. Think of taking the paint brush, making a circle and then the rays are just again a paintbrush stroke.When I set up the mask however, though it's a transparent png, it ignores the actual shape & turns into a rectangle.
what i am doing is to make something along the lines of the "scriptable mask" tutorial Inigo was kind enough to put up.My idea is to have a large mask behind the whole of my flash site, this masks a colour image with a black & white one (nothing tricky). The image I am using is actually 5 separate images combined, and each is a pic of certain parts of the site.I also have a very basic set of buttons along the bottom... each corresponding to each section.
All I want is to set it up so that when I mouse over the buttons, the _x of the mask moves to correspond with the correct image... really very basic... or so I thought .If anything it should be easier to do than what is in Inigo's tut (where he uses the _x of the mouse to move the mask)... i just cant seem to get it to work with a nice easing effect (its easy to get the mask to simply snap to each coordinate, but I need it to smoothly move).
I have 6 frame labels on my stage and on each one I have a mask animation, it's the same animation but on each frame label loads a different image, basicaly the image just fade's into the mask. I was hoping to try and do this with actionscript, just not sure how. Would also like to load the images externally too if possible.
I have created a custom 3d wall gallery and I would like to mask it to give it right and left fades. I have posted the code that places the images on the stage but for the life of me I cannot mask it. Themc in the library mask_mc already has the correct gradient so now how do I add it to the top of the dynamic gallery?
Code: private function viewCarousel():void { viewport = new Viewport3D(stage.stageWidth, stage.stageHeight, false, true); addChild(viewport);[code]......
I'm trying to mask multiple shape tweens for a slideshow animation I'm working on. (the transition would look just like the main animation on this page url...)
Everything works fine when I'm only masking/tweening one shape. But as soon as I add a few more dquares to the mix everything goes to hell. Can someone tell me the most efficient way to have multiple shapes tweening, while masking an image underneath them?
im trying to use a mask on multiple sprites:[code]But the mask seems only to affect the last object, that i added to mask (righttxt). Is there a way to use the same mask for multiple sprites?
im loading multiple images but how do I make sure the program will start once all images have dispatched a complete event. like make a universal loader for all the other "small loaders" if you understand.
I am trying to load multiple images into a scene and then cycle through the images one at a time.So, here are the essentials what I've put together in AS3:First I set up a counter and a Loader
[code]....
Then, after loading a list of images from an XML file, I call a function that I called "createImages". This function then takes the list of images and creates a bunch of loaders:
[code]....
So far, so good! I now have a bunch of loaders each with a different name "img1","img2","img3" etc.
I have two MovieClips onscreen, and I want to apply the same mask to both. I set the the masks using
mc1.mask = mymask; mc2.mask = mymask;
Only mc2 receives the mask. How can I set the same mask for two different MovieClips without having to resort to putting them both in a single MovieClip?