DO With Higher ChildIndex Consumes MouseEvents Of Underlying DOs
DO = Display Object Hi there! I have simple issue i need help with.. googled for a while to no avail.. I have created an example movie with a button(type MovieClip), added CLICK event like this: Code: myButton.addEventListener( MouseEvent.CLICK, onButtonClick ); onButtonClick() triggers correctly, all good. Next i added a TextField (or MovieClip, Sprite..) above the button. Now when i publish the movie, and try to click the button (under the added DO), the MouseEvent.CLICK ( or MOUSE_DOWN, whatever.. ) doesnt trigger anymore, probably because the DO which is now above the button eats the MouseEvent. So what i wanna do is dispatch the MouseEvent into each DO that is under my mouse cursor, not only the top-most DO in the hierarchy. ..was trying and fixed this like 2 years ago (bluntly remember i used something else than MOUSE_DOWN / CLICK), but left AS3.0 programming at that time and now trying to do the same second time [aaa :] Thanks for your help!
KirupaForum > Flash > ActionScript 3.0
Posted on: 09-03-2008, 10:28 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
ChildIndex
hi i have a little problem with childIndex
i generate numbers of sprites in a loop and i put it in a container sprite after that, i set its (container's) childIndex 0 but that container stands over my other clips at stage. When i look with getChildAt(0), my container seems at 0 deep.
my code seems like that
var baloonContainer:Sprite = new Sprite();
addChild(baloonContainer);
for(i=0; i<_baloonCount; i++) {
var baloon:Sprite = new Sprite();
baloon.name = "baloon" + i;
...
...
...
baloonContainer.addChild(baloon);
}
setChildIndex(baloonContainer, 0);
what is the problem with me
thank you
[as3] Xml.childIndex()
PHP Code:
there is a xml
<webdata>
<image photo="1177321468.0.jpg" mini="1177321468.0_mini.jpg" x="13" y="0"/>
<image photo="1177379638.0.jpg" mini="1177379638.0_mini.jpg" x="0" y="16"/>
<image photo="1177380521.0.jpg" mini="1177380521.0_mini.jpg" x="18" y="0"/>
<image photo="1177381680.0.jpg" mini="1177381680.0_mini.jpg" x="20" y="0"/>
<image photo="1177381681.1.jpg" mini="1177381681.1_mini.jpg" x="10" y="0"/>
<iamge photo="1177381681.2.jpg" mini="1177381681.2_mini.jpg" x="13" y="23"/>
<image photo="1177381852.0.jpg" mini="1177381852.0_mini.jpg" x="25" y="3"/>
<image photo="1177382228.0.jpg" mini="1177382228.0_mini.jpg" x="31" y="37"/>
<image photo="1177384071.0.jpg" mini="1177384071.0_mini.jpg" x="18" y="9"/>
<image photo="1177458644.0.jpg" mini="1177458644.0_mini.jpg" x="11" y="19"/>
<image photo="1177487343.0.jpg" mini="1177487343.0_mini.jpg" x="15" y="0"/>
<image photo="1177487524.0.jpg" mini="1177487524.0_mini.jpg" x="83" y="28"/>
<image photo="1177322499.0.jpg" mini="1177322499.0_mini.jpg" x="0" y="0"/>
<image photo="1177322036.3.jpg" mini="1177322036.3_mini.jpg" x="25" y="23"/>
<image photo="1177322035.2.jpg" mini="1177322035.2_mini.jpg" x="33" y="55"/>
</webdata>
and an as reading each node
ActionScript Code:
var i:uint;
if( xml.childIndex()<xml.parent().image.length()-2 ){
i = xml.childIndex()+1;
}else{
i = 0
}
trace( xml.childIndex()+' '+xml.parent().image.length()+' '+i);
trace( xml.parent().image[i].childIndex( ) )
but since it finds 5th node traced info gets wired
0 14 1
1
1 14 2
2
2 14 3
3
3 14 4
4
4 14 5
6
6 14 7
8
8 14 9
10
10 14 11
12
12 14 0
0
0 14 1
1
1 14 2
2
2 14 3
3
can anone explain this?
Flash Consumes Memory
Hi!
I have a fairly big swf file, mainly consisting of a sequence of images. The file itself is about 14MB. However, when I run it in a browser, it consumes 300MB of memory. Even though it caches the images and so on, 300MB memory consumption seems like a major overkill. I plan to redo the image sequence to a more low-quality version, but still can't see why the browser needs to consume such extreme amounts of memory. Any ideas why this happens?
- Peder -
How To Set The Correct ChildIndex
hi, I'm having trouble updating my (Lee's) 3d carousel from as2 to as3 I'm pretty new to as3.
At this moment I'd like to keep it simple and to learn as much of as3 as possible, especially the classes.
The first steps have been made (most of it by others who also converted Lee's carousel) but I still have a problem
with the indexes of the different movieClips on the stage. I do get my carousel on the stage but the depth's are wrong.
In as2 we used swapDepths, now the function setChildIndex is called.
but if I use this function I get the following error:
RangeError: Error #2006: The supplied index is out of bounds.
at flash.display::DisplayObjectContainer/setChildIndex()
Can please someone help me
this is my code of the as.
Code:
package david.interactive
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.*;
public class Carousel extends MovieClip
{
private var numOfItems:int = 5;
private var speed:Number = 0;
public var radiusX:int = 200;
public var radiusY:int = 50;
public var velocity:Number = 2500;
var t;
public function Carousel(xx:Number, yy:Number, rxx:int, ryy:int)
{
x = xx;
y = yy;
radiusX = rxx;
radiusY = ryy;
for (var i:int = 0; i < numOfItems; i++)
{
t = addChild(new item);
t.name = "item" + i;
t.angle = i * ((Math.PI * 2)/numOfItems);
t.addEventListener("enterFrame", mover);
}
addEventListener("mouseMove", interaction);
}
private function mover(event:Event):void
{
var item = event.target;
item.x = Math.cos(item.angle) * radiusX + x;
item.y = Math.sin(item.angle) * radiusY + y;
var s:Number = item.y / (y+radiusY);
item.scaleX = item.scaleY = s;
item.angle += speed;
var index:int = Math.round(item.scaleY* 10);
trace(index);
// this is where things go wrong/////
setChildIndex(item, Math.round(item.scaleY*numOfItems));
/////////////////////////////////////
}
public function interaction(event:MouseEvent):void
{
speed = (mouseX - x)/velocity;
}
}
}
and this is my fla (I just have a movieClip called item in my library
Code:
import david.interactive.Carousel
var centerX:Number = stage.stageWidth/4;
var centerY:Number = stage.stageHeight/4;
var CarouselItem:Carousel = new Carousel(centerX, centerY, 200, 50);
addChild(CarouselItem);
ChildIndex Problem.
Hi all,
I'm with a problem to set correctly childIndex to a dropdown menu than is being shown behind a external file loaded with Loader object, and added to a MovieClip on the stage.
After loaded the content i did like this.
Code:
function onComplete(e:Event):void
{
this.menu1.setChildIndex(this.menu1.getChildAt(1), (e.currentTarget.content.numChildren + 1));
}
But not works. I see this in Help, but i'm not sure if is correct.
Thanks in advance for all help.
Cheers!!
Which Consumes More Resources (file Size)?
Hi all,
I'm a newcomer in Flash world. Recently, I just learned some Flash through some books and I know that we can manipulate and control the instances of the objects (movie clips) that we create.
But, which one is more efficient, or better? controlling through Timeline or the ActionScript panel? Is the file size gonna be the same, doing things manually in the Timeline and writing codes in the action panel?
Thanks in advance!
Flash Movie Consumes Large Amounts Of Memory
I have a problem, that i have someone else having on the forum before! After some time of playing my flash movie, Internet Explorer uses more and more memory! I have some movieclips checking for a variable all the time, could this be it?
+
Also having probs with the Javascript popup boxes! Try clicking on "TILMELD DIG SØNDAGS NYHEDSBREV HER" in the bottom left corner.!
Hope that you guys can help me
http://soendagny.soendagshjemmeside.dk
Underlying Link
hello everyone,
I have two quick questions for you in the know:
1) how do I go about adding a link to a swf file so that users watching an advertisement can click on it?
2) how do I make a swf only play twice on each page load?
thanks
Underlying Dynamic Text
I found an old post, and I responded to it, but I figure it's best to just title a new thread after this subject:
How do you underline text in a dynamic text field?
Thanks for your thoughts.
Blur Underlying Content?
is there a way to have like an invisible MC and just anything underneath it becomes blurred?
more specifically I want to have my flash movie with a transparent background overlay an html page....is there a way to blur certain points of the html page that are shown underneath the flash movie....I hope this makes sense.
Thanks.
Controlling Mouse Events On Underlying MC
Here's the situation...
I'm developing the site for a company, and they asked me to make it as close to a desktop as possible (behavior wise). So I made "windows" that can be minimized, restored, closed and loose their focus. This is where the situation starts: How can I "disable" all mouse events for the "underlying windows"? These events keep on happenning, thus making it possible for the user to click-and-change the content of a window that's supposed to be disabled. I'll apprecite any help you can give me.
thanx, francisco
Preventing Underlying Button Clicks
I have a site i'm working on that has a thumbnailed gallery for images. When you click a thumbnail it brings up a smaller window off to the side that displays the info for the image (name, description and price) When you click the link to view the full size image file, I have it making an empty clip above the site that covers everything. My problem is that the thumbnails and the rest of the links on the site are under this full view and the hand cursor comes up when you roll over them, even tho they are not visible. Is there a way to prevent this? The site is here: http://www.gusfink.com/flash_site/
Thanks in advance for any help you can offer.
Ryan - 7 Year Studios
Clicking Through MovieClips To Underlying Objects
hi i am searching for solution to click the underlying objects.
this is my actual problem.
i have some buttons on stage, which was tied to some specific functionality.
a module in my script used to create dynamic movieclips over the buttons on the stage. for eg:- some drawing over the button. these movieclips also has some mouseclick functionalities.
those parts of the button which is not covered by the movieclip should be clickable. this is my requirement.
can anybody help me. thanks in advance
Question Regarding Levels And Underlying Buttons
I have loaded an external .SWF with the following AS:
createEmptyMovieClip("movie", 1);
loadMovie("header.swf", "movie");
This works fine; However, I have several buttons on my stage that lie underneath this clip. You cannot see them when this clip is loaded, but I still want the user to be able to click them.
I'm a little unfamiliar with levels... can anyone help? Thanks!
Need Some Help. How To Create A Mask Shape Which Colors And Distorts The Underlying
Heey
I'm working on HL2 Total Mayhem. I just started out with flash a little while ago so my skills aren't that great yet.
I'm trying to create a shape which colors the underlying with a red tint(this i already succeeded in)and distorts the underlying layer.
(this part i've got no clue how to do).
So how do i distort the underlying layer?...
If it can't be done that way any other suggestions would also be appreciated.
Greetz
Thierry
SWF With Transparent PNGs Undesirably Mask Underlying Image?
Hi,
I have an application that positions a partly transparent PNG image from the library. It then loads an external swf which contains a number of transparent PNG files on its timeline to fake an animation. First the script places it beneath, later above the first image with addChildAt.
When above, these PNG files now partly mask or 'erase' the underlying first image while they are on the stage. Its boundaries are clearly stamping away pixels of the first image right until the point where I remove this external asset.
Seems to me like I'd need to manually refresh stage rendering or something. Anyone an idea? Thanks for any suggestions
MouseEvents
Hi everyone,
AS3 mouse events seem to be a vast improvement on AS2.
Mouse events in AS2 seemed to register even if you didn't directly interact with the clip, yet in AS3 it happens only if the mouse is over the clip:
AS2
Results in the clip rotating ANY time you move the mouse (a bit crap, really)
ActionScript Code:
clip.onMouseMove = move
function move():Void
{
clip._rotation = _xmouse;
}
AS3
Results in the clip rotating only when you move the mouse over the clip (great!)
ActionScript Code:
import flash.events.*
clip.addEventListener(MouseEvent.MOUSE_MOVE, move);
function move(evt:MouseEvent):void
{
evt.target.rotation = mouseX;
}
Is this as-designed behaviour in both AS2 and AS3? Or have I missed something in AS2?
Thanks,
Dave
Mouseevents Wtf?
Solved (too many }, pity the compiler/debugger isn't smart enough to catch a simple error like that lol).
MouseEvents Conflicted
Hi
I have created a movieclip.
I have implamented zoom and drag functionality in it.
when i click movieclip it scales larger and next time i click it it scales smaller.
but when i click movieclip for draging at that time i want to disable zoom function.
so is there anyway....
Thanks.
MouseEvents Outside Of Browser?
The times when I've built a Flash scrollbar, whenever the user's mouse would go outside of the browser, the scrollbar would cease receiving mouse events. Several times I've seen flash scrollbars that continue receiving events, how so?
Here's an example: https://www.masterbeat.com/#genre/electronica
Accordion Mouseevents?
hi! i'm very new at flash.. and i have a question about the accordion component :
i want to catch the onRollOver and onRollOut mouseevents when i go over an Accordion header, and my code looks like this :
ActionScript Code:
trace(accord._header0.onRollOver) //output : "type function"
accord._header0.onRollOver = new function() { trace("rolled over!!"); }
trace(accord._header0.onRollOver) //output : "undefined" (?!??)
so what i am doing wrong? i want to overwrite the onRollOver handler with my custom function, but when i call trace again - the function is gone
pleas help me i'm working on this the whole day )
MouseEvents For External Swf
Hi. I'm loading an external swf with MovieClipLoader into an emtpy MovieClip. Then I'd like to add an onRelease behaviour.
With an external jpeg this is no problem, but with a swf it doesn't react, since the swf itself already has it's own mouse behaviours.
So it seems that the mouse behaviour of the external swf overrule the frehsly assigned onRelease behaviour.
Isn't there a way to make this onRelease work, i.e. to make the swf pass the mouse events on the the main movie?
Thanks! Michael
Problem With MouseEvents
I'm currently working on a small design in Flash CS4 that I will use as part of a website, and am having troubles with some of my AS3 code. Basically, what I am interested in having my buttons do is this:
When I MOUSE_OVER the button, I would like the page information to come up directly below it. When I MOUSE_OUT from the button, I would like the page information to disappear. This part I have completed, and works fine. The next thing I would like to do is when I CLICK on the button, I would like the page information to stay, and the MOUSE_OUT to be void, so I can navigate through what is there, and then when I MOUSE_OVER another button it disappears.
I have sort of completed this. When I CLICK the button, the information stays, and when I MOUSE_OVER another button it will disappear. When I MOUSE_OVER that same button, and MOUSE_OUT the first time, it will disappear, but when I CLICK that button a second time, after I MOUSE_OUT and MOUSE_OVER again the information just stays without a CLICK, even after I MOUSE_OUT. I would like the information to only stay when I CLICK the button, and disappear after a MOUSE_OVER on another button, then only show the information on MOUSE_OVER again until I CLICK. Basically, a preview of the page on MOUSE_OVER, the full page on CLICK, then when another button is activated that all becomes void until the button is CLICKed again.
Here is my code for my first button:
Code:
stop();
btn_1.addEventListener(MouseEvent.CLICK, click1);
btn_1.addEventListener(MouseEvent.MOUSE_OVER, over1);
btn_1.addEventListener(MouseEvent.MOUSE_OUT, out1);
function click1(event:MouseEvent):void
{
btn_1.addEventListener(MouseEvent.MOUSE_OUT, roll1);
function roll1(event:MouseEvent):void
{
gotoAndStop(5);
}
}
function over1(event:MouseEvent):void
{
gotoAndStop(2);
}
function out1(event:MouseEvent):void
{
gotoAndStop(1);
}
I hope I explained that well enough for someone to understand? Any help would be greatly appreciated! It seems fairly simple, but for some reason I just can't get it.
Basic Question On Mouseevents
Hi,
thank you for reading this and for any answers.
Which mouseevents are allowed in buttons that are part of a movieclip? I have experienced that rollOut works but not any others.(Not even rollOver.) I use Flash 5 and Flash MX and are using framelables. I assume that there are no difference between MX and 5 in this matter?
That the event release don´t work may be cuz a MC are a dynamic minimovie and a button a static symbol??
regards
ikaros
___________________________________
I cannot live without dreaming, but maybe it is just a dream that I am living...
[F8] MouseEvents For _parent And Child
I have a _parent movieclip that receives mouse events and I want the clips inside the _parent clip (child clips) to receive mouse events also, but because of the _parent's mouse event handlers, the child clips are "interfered" with, or not received....
how do I make it so both the _parent and the child clips can receive mouse events?
DisplayObjects And MouseEvents Question
Is it possible to make a child of a DisplayObject not register MouseEvents?
Here's my problem...
I have 3 squares that overlap each other. I was using a DropShadowFilter on them but found that it rendered too slowly. So I replaced the DropShadowFilter with a .PNG containing a blurry black square to simulate a dropshadow.
It runs much more smoothly, but the shadow is now picking up the MouseEvent.ROLL_OVER Listener, which means the square underneath isn't triggering its ROLL_OVER event
So the goal is to trigger the ROLL_OVER event of the DisplayObject that's being overlapped by the dropshadow.png
Any ideas?
Mouse.hide And MouseEvents?
I have hidden my mouse and am using a custom cursor, but when I hide the mouse none of my "MouseEvent.ROLL_OVER/OUT", "MouseEvent.CLICK", and "MouseEvent.MOUSE_UP" events work anymore. Is there anyway to get these to work without capturing the mouse click's x/y coords and converting that to the movie?
Thanks,
maji
How To Transmit MouseEvents To Children?
Hi,
I am currently working on an improvement of a old program in AS2 for my office.
The program consists of an evolved viewer for interactive languages courses THAT ARE ALREADY MADE AND SHOULD NOT BE CHANGED.
Those courses consist of simple flash movies with simple controls (play, go back, go forward, etc...)
For this advanced viewer, I have to add new functions on the buttons dynamically when the movie is loaded. But the buttons must also keep their old effect, which will add with the new one.
I had no problems with "simple" buttons, since I just had to add a second listener for the same "on press" event to them, but...
The hard part is movieclips with buttons in it.
For some reason, adding listeners on the buttons don't work, but adding on the movieClips containing them work.
But if I do that, the event isn't transmitted to the button inside, so the "old" action doesn't take effect.
To make it short :
If I could make the click event go to the children of the movieclip, or simulate a click somehow, my problem would be solved.
Any suggestions about this?
Problem With Depths And MouseEvents
Hey all,
I was wondering if there was a way to stop all event propogation from affecting a MovieClip. Basically, I have a movieClip that is "hidden" underneath another one, but I need it to be able to be accessible. The MovieClip on top has no listeners added, and no functionality whatsoever, yet it seems to be stopping anything from getting to the MovieClip underneath it.
I've tried setting the "enabled" property to false, as well as the "MouseChildren" on the "holder" to false.
Here's the code I use to set up the MovieClips that are meant to "hide" the other movieClips.
ActionScript Code:
var bandHolder:MovieClip = new MovieClip();
addChild(bandHolder);
var bandHider:MovieClip = new MovieClip();
addChild(bandHider);
for (var i:Number=0;i<pinMax;i++) {
createHidingPin(i);
}
function createHidingPin(pinNum:Number) {
var tempPin:pin_mc = new pin_mc();
bandHider.addChild(tempPin);
tempPin.x = ((i%5)*117.5)+pinOffsetX;
tempPin.y = (Math.floor(i/5)*117.5)+pinOffsetY;
tempPin.num = pinNum;
tempPin.name = "hidingPin"+pinNum;
tempPin.mouseEnabled = false;
}
That's really it. The "pin_mc" is basically just a circle right now (will change later) that is just a single frame on the timeline of that MovieClip. There is no added functionality to it. The "class" is just the generic extension created when you click on the "export for actionscript" checkbox in the "properties" of the MovieClip. So it's basically just a graphic that I place in a grid, and it's there to hide the stuff in the "bandHolder" (which is attached elsewhere and is a clearly defined Class). The mouseEvents for that class work if I set the "visible" to false for the Pins or for the "bandHider", but otherwise, they don't....
Anyone know of a way to get around this? I'd prefer to keep the thing dynamic (as the number of pins may end up changing in the end)...
Any help would be appreciated!
Do Masks Interfere With MouseEvents?
I have a sprite, on a layer. If I set the layer above it as a mask, the sprite's MouseEvents aren't captured. If I remove the mask, they are.....
I have never encountered this before, and in fact I have several other movieclips on timeline layers, that are beneath a mask-layer, which aren't having any MouseEvent problems.....aargh!
Edited: 09/19/2007 at 06:53:48 PM by cayennecode
MouseEvents On Main Sprite
This is probably a beginners question, but I have been puzzled for a few days.
This works as expected (imports ommited):
public class Test extends Sprite {
public function Test() {
var circle:Sprite = new Sprite();
circle.graphics.lineStyle(1);
circle.graphics.beginFill(0xFF8000);
circle.graphics.drawCircle(50, 50, 10);
circle.addEventListener(MouseEvent.MOUSE_DOWN, down);
addChild(circle);
}
private function down(evt:MouseEvent):void {
trace("down");
}
}
However if I remove the circle object and directly draw on the main sprite, it doesn't work:
public class Test extends Sprite {
public function Test() {
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(50, 50, 10);
addEventListener(MouseEvent.MOUSE_DOWN, down);
}
private function down(evt:MouseEvent):void {
trace("down");
}
}
No matter where I click, I can't get the event to be fired.
I know I can attach the listener to the stage, but I'm wondering why it doesn't work on the sprite directly.
I'm sure there is a perfectly reasonable explanation, I just can't figure it out.
Can any one help?
Thanks in advance,
Peter
Accessing Childten MCs With MouseEvents In AS3
Hi,
I now have working code that creates a mask of about 2,700 children on a 650 by 450 image using a container to hold all the children's MCs.
Can anyone provide any help as to how I can access these children at once with a MouseEvent so that I could for instance change the alpha value of a child shape when the user rolls over it with their mouse.
I have attahced the code to this post.
Thanks in advance for any of the help provided as I've been learning to use AS3 from AS2.
Best,
Justin
Attach Code
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
var pixelated_mc:MovieClip = new MovieClip();
addChild(pixelated_mc);
pixelated_mc.y = 0;
pixelated_mc.x = 0;
var commaHolder_mc:MovieClip = new MovieClip();
addChild(commaHolder_mc);
commaHolder_mc.y = 0;
commaHolder_mc.x = 0;
//var commaTile_mc:MovieClip = new commaTile;
//trace(commaTile_mc.width);
var pixelSize = 2;
function pixelate(){
var bitmapData:BitmapData = new BitmapData( original_mc.width/pixelSize, original_mc.height/pixelSize, false );
var bitmap:Bitmap = new Bitmap(bitmapData);
pixelated_mc.addChild(bitmap);
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(1/pixelSize, 1/pixelSize);
bitmapData.draw( original_mc, scaleMatrix );
bitmap.width = original_mc.width;
bitmap.height = original_mc.height;
}
function tileBG() {
for(var i=0; (i/original_mc.height < .1); i++) {
for(var j=0; (j/original_mc.width < .1); j++) {
var commaTile_mc = new commaTile();
commaTile_mc.x = j * commaTile_mc.width;
commaTile_mc.y = i * commaTile_mc.height;
commaHolder_mc.addChild(commaTile_mc);
commaTile_mc.addEventListener(MouseEvent.ROLL_OVER, onRoll);
//trace(commaTile);
}
}
};
function onRoll(event:MouseEvent):void {
trace("ROLL OVER");
}
removeChild(original_mc);
pixelated_mc.mask = commaHolder_mc;
pixelate();
tileBG();
trace(commaHolder_mc.getChildAt(0));
Not All MouseEvents Supported In Flash 2?
from the actionscript language reference in mx2004:
on()
Availability
Flash 2. Not all events are supported in Flash 2.
Usage
on(mouseEvent) {
// your statements here
}
Flash 2. Not all events are supported in Flash 2. <---- !!! which ones aren't supported? i couldn't find this in the AS2 docs anywhere.
and would this mean the same thing for this usage?
target.onMouseEvent = function(){
}
MouseEvents With Bitmap Objects
I am trying to have a mouse event register when the cursor leaves an image, but the listener function never gets entered. In AS3, how does one get the MouseOver event to work for a bitmap like I have?
public class MyClass extends MovieClip {
.
.
.
[Embed(source='orange.jpg')]
public var MyOrange:Class;
.
.
.
public function MyFunction() {
var graphix1:Bitmap = new MyOrange();
graphix1.x = 70;
graphix1.y = 124;
graphix1.addEventListener(MouseEvent.MOUSE_OVER, showOrange);
}
What Am I Doing Wrong? MC Targeting And MouseEvents
Hi,
I have been frustrating with this for a while now and was wondering if maybe someone here could help me out.
I have attached a Flash File (CS3) with a movieclip inside. Lets say this movieclip is acting as a button. What i am trying to do is this. When the user rolls over the movieclip (parent) it begins the animation. The animation plays, then stops and a certain frame. On this certain frame there is another movieclip (child) i also want to act like a button. I have gotten it to when the user rolls into the child button the parent won't play its roll out animation unless you actually roll out of it as oppose to rolling into the child clip (which is technically out of the parent). The problem i am having is A) targeting the child clip, and B) getting the child to play its animation when rolled in and of.
This is the code i have used so far.
Code:
testButton.stop ();
testButton.addEventListener (MouseEvent.MOUSE_OVER, buttonOver);
function buttonOver (e:MouseEvent):void {
testButton.play ();
testButton.removeEventListener (MouseEvent.MOUSE_OVER, buttonOver);
testButton.addEventListener (MouseEvent.MOUSE_OUT, buttonOut);
}
function buttonOut (e:MouseEvent):void {
if (e.relatedObject==null || (e.target.name!="insideButton" && e.target.name!="testButton")) {
testButton.gotoAndPlay (11);
testButton.removeEventListener (MouseEvent.MOUSE_OUT, buttonOut);
testButton.addEventListener (MouseEvent.MOUSE_OVER, buttonOver);
}
}
The parent clip is named testButton and the child clip is named insideButton. I have been told that this is possible with AS3, but seem to be stuck.
Can someone here help me finish this? It has been the bottleneck of a project and is starting to give me headaches. Any help is very much appreciated. And thank you in advance.
MouseEvents For Buttons With Textfields
Hi,
Below is the code im using for a menu that recognizes which button is already selected and prevents its mouse_over/out states while it is selected.
I have two dynamic textfields on top of each button. I need these textfields to be part of the button without the text being tweened in the same way the button is.
I have tried putting the textfields inside the movieclip but then the text tweens the same way the button does (because the functions use 'currentTarget') and if I keep the textfields on top of the buttons my mouse events don't work when the cursor is over the textfields, making half of my button not function.
I have read about using mouseChildren = false but so far I'm having no luck
Any help guys.....
Code:
import gs.TweenMax;
import gs.easing.*;
// create an array of all nav buttons in group
var menuData:Array = new Array();
menuData.push(tab1);
menuData.push(tab2);
menuData.push(tab3);
menuData.push(tab4);
menuData.push(tab5);
menuData.push(tab6);
// create a variable to track the currently selected button
var activebtn = new MovieClip;
// doRollOver: start the rollover action or process,
// unless the button is currently selected
function doRollOver(event:MouseEvent):void {
if (event.currentTarget != activebtn) {
TweenMax.to(event.target, 0.5, {tint:0x0033CC});
}
}
// unless the button is currently selected
function doRollOut(event:MouseEvent):void {
if (event.currentTarget != activebtn) {
TweenMax.to(event.target, 0.5, {tint:0x333333});
}
}
function doClick(event:MouseEvent):void {
tab1.mouseChildren = false;
TweenMax.to(activebtn, 0.5, {tint:0x333333});
activebtn = event.currentTarget;
TweenMax.to(activebtn, 0, {tint:0x0033CC});
}
// assign functions to each event for each button in the group
function init() {
var i=0;
var btn;
for (i=0; i<2; i++) {
btn = menuData[i];
btn.addEventListener(MouseEvent.MOUSE_OVER, doRollOver);
btn.addEventListener(MouseEvent.MOUSE_OUT, doRollOut);
btn.addEventListener(MouseEvent.CLICK, doClick);
}
}
init();
Adding Mouseevents To Objects.
I'm setting up a menu by creating 3 new objects (I drew a basic rectangle and saved it as a movieclip + linkage).
var rect1:Rect = new Rect();
var rect2:Rect = new Rect();
var rect3:Rect = new Rect();
Next I would like to add 15 pixels to the x-property on mouseover, and go back to original x-property on mouseout. How would you add this functionality in a smart and effective way?
Coming from other programming I would probably go and edit the Rect-class and add some behaviour, but in Flash all I can figure is to add listeners like this..
rect1.addEventListener(MouseEvent.MOUSE_OVER, makeMenu1Over);
rect2.addEventListener(MouseEvent.MOUSE_OVER, makeMenu2Over);
rect3.addEventListener(MouseEvent.MOUSE_OVER, makeMenu3Over);
rect1.addEventListener(MouseEvent.MOUSE_LEAVE, makeMenu1Out);
rect2.addEventListener(MouseEvent.MOUSE_LEAVE, makeMenu2Out);
rect3.addEventListener(MouseEvent.MOUSE_LEAVE, makeMenu3Out);
.. which seems like a very wrong direction to go. I want as little code as possible. Can I write custom code for an object (like Rect in this case) so that all the mouseevents would be inherited upon instantiation?
Thanks for all smart replies!
Not All MouseEvents Supported In Flash 2?
from the actionscript language reference in mx2004:
on()
Availability
Flash 2. Not all events are supported in Flash 2.
Usage
on(mouseEvent) {
// your statements here
}
Flash 2. Not all events are supported in Flash 2. <---- !!! which ones aren't supported? i couldn't find this in the AS2 docs anywhere.
and would this mean the same thing for this usage?
target.onMouseEvent = function(){
}
Urgent Help Needed : Mouseevents & Movieclips
hello everybody,
I'm relatively new to flash but I need to make a simple portfolio in flash, instead of working with fixed titles for buttons like "atelier" theory, contact, and so on i made a REAL simple movieclip to start playing when i have the mouseevent Mouse_OVER so that the title moves and a line gets drawn, no problems there, but when i do a Mouse_OUT i want this movieclip, the title, to be in it's initial position, without the line, so in fact to reset the playhead of this movieclip but i don't know which function to use... can anyone help me?
the code for this effect:
Quote:
atelier_mc.addEventListener(MouseEvent.MOUSE_OVER, playmovieClip);
atelier_mc.addEventListener(MouseEvent.MOUSE_OUT,s topmovieClip);
function playmovieClip(gebeurtenis: MouseEvent) {
atelier_mc.play();
}
function stopmovieClip(gebeurtenis: MouseEvent) {
atelier_mc. ???? (); //what do I put here?
}
Trouble With MouseEvents And Overlapping Movieclips
I am developping a website in flash. The navigation for this site should respond to the MouseOver event no matter what else is happening on the site, updating the graphics based on mouse coordinates.
The problem is this: I want to add scrollable/clickable/.. content on the site, but because the Navigation movieclip covers almost the entire stage, All MouseEvents are caught by the navigation movieclip, so no events are triggered for underlying clips.
I'm sure this can be solved but I have no idea how.. Can anyone help, or point me in the right direction? swapping depths doesn't seem like the way to go because the menu clip should always be catching events..
Blocking MouseEvents From TextField W/htmlText
Hi again. So, I've got a TextField with htmlText that contains links. I'm using a stylesheet object to give the links an underlined hoverstate. When I create a new sprite, place it above the TextField, add event listeners for MOUSE_OVER (and even ROLL_OVER just to be sure) to the sprite, it does not block the text below from getting its hoverstate style applied.
I've tried placing other display object containers over top of the TextField as well.
Any thoughts on why this might not be able to block the html hover?
Thanks,
David
No MouseEvents Dispatched After Moving A Sprite
Hi all,
i've written a class which extends flash.display.sprite. The objects are then
added to another sprite wich is a child of the Document Class.
When i add them they are initially placed on coord 0/0. On that position,
the mouse events are dispatched correctly.
For some reason though, there are no more events after moving the sprite
somewhere else using mySprite.x = someNewPosition.
The positioning works fine, simply there are no more events dispatched from these objects.
Anyone an idea what i'm doing wrong ?
thanks for your help !
Catching MouseEvents From Siblinged Sprites
i have the following scenario:
two Sprites A and B, whereas A contains a .png file with some transparent regions,for instance a black rectangle with a hole in the middle. B is a smaller Sprite with
some Graphics. B has a DisplayList index lower than A so that A covers B and B can only be seen when it is behind the hole in A.
I turn B into a button by adding an EventListener to it.
1) When B is set as a Child of A, B can catch my MouseEvents.
2) But when A and B are just siblings, B doesn't receive any MouseEvent.
So, is there a way to make B "clickable" in case 2)
Keith
Papervision Mouseevents Througth Scene
I have a number of planes divided in rows. When clicked on a button within the plane's material, a box appears displaying content. This box has a close button. This button closes the box. However, when the close button is not over the content in the scene the buttons recieves the mouseevent(green), when it's over it does not(red). The image below shows this.
I use papervision 1.7, if required i will post additional information.
Flash.events.MouseEvents Will Not Load...need Advice
Hello,
I have a simple bit of code where I am attempting to detect a roll over. I think my code is right, but an error keeps showing that says:
"The class or interface 'flash.events.MouseEvents' could not load"
I think I am calling it correctly. Do I have to make a class and use the linkage to set the class path? I thought I could just import the class at the top of my script.
The code looks like this:
Code:
import flash.events.MouseEvent;
mc_button.addEventListener(MouseEvent.MOUSE_OVER, mouseOverListener);
mc_button.addEventListener(MouseEvent.MOUSE_OUT, mouseOutListener);
function mouseOverListener(event:MouseEvent):void{
this.arm_relaxed.play;
}
function mouseOutListener(event:MouseEvent):void{
this.arm_relaxed.stop;
}
Any ideas? I feel like it should work. Any tips would be greatly appreciated.
- JonCloud
Dynamically Generated Clips Won't React To Mouseevents...
When dynamically generating movieclips, how can you add a
myMovieClip.onRelease = function () {
what needs to be done comes here ...
};
Here's my code
for(i=1;i<=_root.artcounter;i++){
content.duplicateMovieClip("content"+i,i*1000);
this["content"+i].id = i;
if(i == 1){
this["content"+i]._y = 22;
this["content"+i]._x = 0;
}
this["content"+i].loadMovie(i+".jpg");
this["content"+i]._height = 10;
this["content"+i]._y = this["content"+(i-1)]._y+this["content"+(i-1)]._height;
}
It generates movieclips by duplicating a clip, loads a jpg into every generated clip and then places them in an _y position. But now I need to press them like they are buttons, and that won't work...
Anyone ?
thanks
MovieClip SubClass: Getters, Setters And MouseEvents
Hi folks. I am plain stumped. I am working in F8/as2.0.
I have a class that extends the MovieClip class. I have a blank_mc in the library that is linked to the class. Here is the constructor:
ActionScript Code:
public function MyMC (target_mc:MovieClip){
var _mc:MovieClip = this;
_mc = target_mc.attachMovie (.....);
}
That works all fine and dandy. Where I am having issues is basically I have properties x, y that DON't overwrite the _mc's _x & _y props. Instead, the use getter & setters that take values and then calculate the needed number to set the actuall _mc._x, _y props. This doesn't seem to work at all and i don't know why. Here is the code:
ActionScript Code:
function set x (num):Void {
__x = num;
this._x = (do some calculations based on num);
}
Of course this is really generalized. But is __x a private property of the MovieClip class and I am interfering with it?
On to issue two...
So I got this to work by NOT extending the MC. Instead I have a variable ref to a _mc prop in the class. However I am unable to set event functions to it even if I make some ref to the _mc prop. Is there a good way of approaching this by say a decorator pattern?
|