ActionScript 3.0 :: Target Of EventListeners - Possible To Change MovieClips Image
Nov 7, 2011
I've made a loop that is creating 9x movieClips that is loading external images and I have also added eventListeners to those movieClips to make it possible to change the movieclips image. My problem is that i can't access the target of the "first eventListener". Here is the code to browse for the new image, i want to access the movieclip of this function in a later eventListener, like this: event.CurrentTarget
Code:
file.addEventListener(Event.SELECT, onFileSelected);
function mUp(event:MouseEvent):void{
file.browse(new Array(new FileFilter( "Bild (JPG och JPEG)", "*.jpg;*.jpeg;")));
}
The second eventListener. This function is called when the new image is selected
Code:
function onFileSelected(event:Event):void{
file.addEventListener(Event.COMPLETE, loadCompleteHandler);
file.load();
}
The third and last function, this function is called when the image is loaded and is ready to be used.
Code:
function loadCompleteHandler(event:Event):void{
file.removeEventListener(Event.COMPLETE, loadCompleteHandler);
var loader:Loader = new Loader();
loader.loadBytes(event.target.data);
// Here is the problem!
event.target.addChild(loader)
}
If if put this code, it will target the second function's event.
Code:
event.target.addChild(loader);
I am searching for a code looking like this to replace the old image with the new one
Code:
event.target.target.addChild(loader);
View 5 Replies
Similar Posts:
Aug 13, 2009
im trying find out a value of a var from a mc called from an eventlistener.
//////////// as2 oldSchool ////////////
function loadPlayer() {
trace("myScene: "+this.myScene)
[code]...
View 3 Replies
Nov 14, 2009
I'm trying to create a series of scripts that will create some custom event listeners. I have three movie clips on my stage. One is a movieclip who's sole function is to hold array's and the event listeners. A second which moves around the screen. And a third that is motionless. The problem is that the argument I want to test (which activates the custom event) is held within a string. What I want to know is, how do you test to see if the string argument is true?
Is it something similar to this:
var myCode:String="1<0";
if(myCode){
trace('one is smaller than 0'); //Strangely apparently one IS smaller than 0!!!
}
I think I'm going about this in the wrong manner, however this is the only way I can think of this working... (since I need to be able to dynamically create these events).
View 5 Replies
Dec 8, 2008
I have a mc (changeColorMc) and three movieclips. The three movieclips are created on the fly (so there could be more movieclips) and filled with a color from an Array. This works fine.
Now I want to add an eventlistener for each movieclip, so when someone push one of the movieclips the movieclip with the name "changeColorMc" gets that same color from the colorArray.
My question is: How can I pass the color value from the colorArray to the buttonPressed function? Is this possible?
I was also thinking that I had to create three buttonPressed functions ie. buttonPressed1, buttonPressed2 and buttonPressed3 and attach these to the created movieclips.. but how? Because I don't know up front how many movieclips there will be..
View 5 Replies
Mar 2, 2011
I am creating an image gallery and the images change but change right back to the original image. I had it working yesterday but today it doesn't work.
[Code]...
View 1 Replies
Feb 13, 2012
i basically have some images of logs (for a bridge) setup inside a movieclip called log_mc, inside log_mc each log has its own movieclip log1_mc, log2_mc and so on
[Code]...
View 29 Replies
May 31, 2011
I think this solution should be simple but I think I am missing something about using event.target.name.I have multiple (over 30) MovieClip images on stage with alpha of zero and I would like to have them fade in on MouseEvent.CLICK while removing the current image showing. While I can code it to work for a single image I want to use this.target.name to have more efficient code.
[Code]...
View 3 Replies
Aug 27, 2007
i have an array called movieList that's made up of nine movieclips ("one_mc" for example). when something happens in my timeline, i want to send each of the movieclips to their fifth frame. i tried the following code and it didn't work:
[Code]...
View 2 Replies
Nov 19, 2007
in a actionscript file, is there anyway to have different codes target different movieclips? For example, if i want one movieclip to tint to red and another to tint to blue, can I do that in the same actionscript file or do I need to do that in separate actionscript file?
View 3 Replies
Nov 16, 2009
I did this:
Code:
var mc_array:Array;
mc_array = new Array(3);
mc_array[0] = mc1;
[code]....
I want to use arrays to shorten things, but I don't know how to get and set the properties of individual entries of the array (with a mouse click).
View 2 Replies
Sep 23, 2010
I have a bunch of movie clips in my main timeline with at least 2 nested clips inside them, MyMc.nested1.nested2 etc. I have given the top most movie clips that sit on the main timeline instance names. In a document class I created a private variable typed as an array and placed all those MC names in that array. I then looped through the length of the array and assigned 2 event listeners to each instance. Example:
for (var i:uint = 0 ; i < _activities.length ; i++){ _activities[i].buttonMode = true; _activities[i].addEventListener(MouseEvent.MOUSE_DOWN, pickUp); _activities[i].addEventListener(MouseEvent.MOUSE_UP, dropIt);}
in the event pickup() is were my trouble seems to come in.In the pickup function I have the following:
event.target.startDrag()
This seems to work, but only on the lowest nested Movie clip......nested2I can use event.target.parent.parent.startDrag() and that seems to work.... Except when I place another movieclip in the second layer of the of the MyMC , if that is accidently clicked, it will now drag the Stage.I attempted to use the event.target.mouseChildren = false but that only seems to work on the lowest nested object... nested2 as that seems to be the one I am clickingIs there something I am missing to say, click only the top level mc then ignore all nested mc?
View 3 Replies
Sep 5, 2011
I have been working with AS2 for a long time, but are a total newbie when it comes to AS3.On my stage I have placed an empty MC with instance name "holder".In my library I got a MC linked by the name "sektor".
"sektor" has several movieclips and buttons with instance name, e.g. "corner1", "corner2", "corner3"....
I have nested "sektor" inside "holder" by writing this code:
Code:
var newClip:sektor = new sektor();
newClip.name = "sektor1";
holder.addChild(newClip);
What I want to achieve is to control those movieclips inside "sektor" by turning dem on/off.I have tried to do this with this code:
Code:
holder.sektor1.corner1.visible = false;
but I keep on getting this error:
"TypeError: Error #1010: A term is undefined and has no properties."
I have figured out that by tracing holder, I know it�s excisting (Result: [object MovieClip]) but if I try to trace holder.sektor1, I got the result "undefined". So it seems like "sektor1" is not excisting. Why?
View 7 Replies
Jan 3, 2007
I have a script that loads images and text from an XML file into movieclips.The following code is what creates the movieclips that contain the elements:
Code:
var thumb_mc:MovieClip = _root.mc_conteudo.createEmptyMovieClip("thumb"+(1+i), _root.mc_conteudo.getNextHighestDepth());
var img_mc:MovieClip = thumb_mc.createEmptyMovieClip("img", 0);
I can't seem to find a way to target the thumb_mc or the img_mc so they have rollover effects and actions (they are created for each set in the xml file, so there are multiple mc's)mc_conteudo is the content mc that scrolls.The swf is here: http:[url].....
View 13 Replies
Dec 8, 2008
I want to redirect the following code when the target isn't
available.
function buttonClick(event:MouseEvent):void
{
gotoAndStop(event.target.name);
[Code]....
The code works great but I'm building a large site and would like to have a default swf that loads when the target isn't available. I tried various if statements when event.target.name == null but haven't been able to get any of them to work.
View 7 Replies
Mar 22, 2009
Can I change an event target's name? or it's an only-read property? I've been googling it but to no avail... For example, say this is my button code:
[Code]...
if trace the event target's name, you get buttonOne. But what I need to do is have the event's target's name to become buttonOne1. because I already have a button with the instance name. That's my setup, not the way I would do it OF COURSE, but this is the way the unique file is setup for my aunt, to have two set of buttons that calls the same image...(not the thumbnail issue I had before)... so the Question: is there a way to add a letter or remove a letter from the event target's name? You know how you can add a letter to the beginning of an array like buttonsArray.unshift(newButton)....can you do the same thing with an event.target.name?
View 3 Replies
Feb 9, 2007
is it possible to change the target level of a MovieClip? So I have two instances of the same MovieClip, both on level0.[code]Basically, now btn2 will disappear, and btn1 will remain visible.
View 1 Replies
Apr 28, 2010
I have gallery which I want to modify. Now, I load big image on the stage by clicking thumbnail menu. I can see a small preview of that thumbnail on mouse over. Thumbnail preview is done by cloning thumbnail image and nest that image into thumbnail preview window.
[Code]...
However, it did not work yet. I do something wrong. I am wondering if someone can help me to figure it out. I spent a lot of time to modify it as It looked like a simple thing but without any success. I will provide more information if needed. The project consists of many classes I can explain more if the information I provided is not enough.
View 0 Replies
Feb 29, 2012
I've created a simple drag 'n' drop game and I want the color of the target to be changed only when the user puts inside it all the text frames.
The instance name of the target is "targetCircle" and that of the text frames is "circle_mc", "circle1_mc"....."circle5_mc".
View 0 Replies
May 26, 2010
i have my nave bar as my main swf then i load each page as an external swf in a mc container. each button should be marked when you navigate to the respective page. how would i load a current pages icon over the generic one when i navigate to that page then unload it when i navigate to another page?
View 5 Replies
Aug 11, 2010
How to get general id (or) name from xml loaded images. bcoz, i want to drag and drop that images in generic method. Now, i currently used the event.target.name for each one.[code]
View 1 Replies
Dec 17, 2008
I've read that the best way to "comunicate" with dynamicly created movieclips is by pushing them into an array.
For example:
Code: Select allvar itemArray:Array = new Array();
for (var i = 0; i < 5; i++)
{
var newItem:MyItem = new MyItem();
[Code]......
View 7 Replies
Aug 2, 2009
im messing with a movieclip symbol and i want to make a button, what'd i mean on Mouse over display/change this image in this X,Y cords or replace this image, something close to what buttonSymbol does but i want to make it using movieClip symbol...
and i have no idea how to do it.. i started like this:
[Code]....
View 0 Replies
Sep 19, 2011
I need to change the color tone of the image without changing the structure of the image.
for ex: I like to change the skin tone of my head part of image. Is it possible to change the skin tone color.
View 2 Replies
Sep 10, 2009
I am am not a developer but have bought a template which I am modifying to suit my needs. I have made most of the modifications but and stuck on how to change the animation for the image gallery. When I move from one picture to the next the animation effect is something like a bubble burst. This is too flamboyant for me. I would like to change it to something more sleek but have no clue where to start.
View 1 Replies
Jan 28, 2012
I have this code which allows me to replace the mouse cursor with an image but i would also like to change the image when the mouse is clicked down using a different image. the code i am using for just replacing the mouse cursor is[code]...
i tried using a different code which i found but it failed to work with my project can anyone help me please
View 9 Replies
Aug 24, 2011
I'm trying to makedress up game using flash cs5 (i'm new to all this so bare with me), and i have the body but i want to change the skin colour with a click of a button, i have 4 skin colours that i have ready but i'm not entirely sure how i can do this,
View 2 Replies
Jun 17, 2010
i am trying to make a animation in which Image change in slice while the mouse over the image and its come back to original image with slice yani reverce
View 1 Replies
Jul 10, 2011
I am making a new flash website and i stack on the as3 part.My site have a menu like all the site do.Now on the site load there is a background picture.When you press one of the menu buttons, the background image will change to this button specified image.But all that in an animation of fade in and out.My problem that i have everything but i cant know which image was before it changes to the buttons specified one. It maybe require as3 which i dont know.I cant upload here my work. its personal.But i ask you the professionals, please make a short fla file which will have the code and animations i need.(if you cant understand me)Please, make a fla file, which contains random 3 images.At the start it will have main background and a menu on it(just text-for fast and short work)The menu is 3 text ine(main,about,contact)now, make that when you press about(for example) it will change the main image(background) to the image of the about page.
View 2 Replies
Jun 8, 2009
I have 2 arrays i.e.:[code]Is it possible to set the color of the moviceclips (mcclipsArray) to the relevant colors from the second array (mcclipsColorArray), so movieclip a becomes blue, b becomes red etc.
View 2 Replies
May 12, 2011
In my movie i can change the color of some movieclips. But when im opening the movie after some it reverts to the older color. What i want to do is save my movieclip's color and load it whenever im opening the movie.
View 1 Replies