Flash :: Find The Parent Of A Deep-nested Sprite From The Stage?
Jan 21, 2011
I'll give a complete explanation of what I'm trying to do. I have a video player as a separate SWF. In this video player I have a VideoContainer class extending Sprite, which contains the video and a control bar with specific video buttons.
This SWF is loaded in another main SWF, which has a menu that is on top of everything else. When I click "Fullscreen" in the video SWF, everything goes smoothly, except the menu remains on top of the VideoContainer object.
I need a way to change the display order of the loaded SWF, to put it on top of everything else on Fullscreen and change it back when Fullscreen goes off. All this needs to be made inside the video player. Also, the configuration of the children can change (the video player can be loaded in different places in the main SWF), so I can't use a certain unchanging path.
View 2 Replies
Similar Posts:
Oct 6, 2009
I have a movieclip, which attaches to another movieclip, which scrolls.On click I want to be able to drag that movieclip away from the one it was attached to. When I just removeChild it, it's position changes. I want it to stay in the same spot until it's dragged.Any suggestion, on how I can give it that same position, when not attached?
View 1 Replies
Apr 8, 2011
Tried applying different AS that I've found online but none has worked.
View 1 Replies
Jul 10, 2009
I'm currently making a platform game and when the player shoots i want to add the bullets to the stage. The players gun class is in charge of adding bullets. The "players gun" is a child of "players gun holder" which is a child of "player" which is a child of the stage. is there a better or more dynamic way for the "players gun" to add bullets to the stage rather than using parent.parent.parent.addChild (bullet);
View 2 Replies
Aug 5, 2009
I am creating a Flash training app that includes a glossary. You click a button and the glossary opens. The glossary loads thus:
PHP Code:
var request:URLRequest = new URLRequest("glossary.swf");
var loader:Loader = new Loader()
loader.load(request);
swfCont.addChild(loader);
The glossary has a scrollbar, and that scrollbar has this listener (among other things):
PHP Code:
scrollbar.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
Once the glossary is loaded into my app, if I do a MOUSE_DOWN on the scrollbar and then drag the mouse away from the glossary, onto the parent stage, then when I do a MOUSE_UP on the parent stage, I need to dispatch a new MouseEvent.MOUSE_UP event to the scrollbar in the glossary swf.
How do I access the scrollbar of glossary.swf in my dispatchEvent? In other words, in the following code in the parent:
PHP Code:
stage.addEventListener(MouseEvent.MOUSE_UP, glossarySBMouseUp);
function glossarySBMouseUp(me:MouseEvent):void {
xxx.dispatchEvent (new MouseEvent(MouseEvent.MOUSE_UP));
}
View 2 Replies
Jan 12, 2012
I'm looking to create an animation loop in Flash. The base character animation I have is 27 frames. However to have the background move at the correct speed, the entire animation is 432 frames.
Since I am making the animation so long anyway, I want the character to blink halfway through the animation loop. I went into the head symbol and extended its animation from a single frame to 432 frames. Halfway through that animation I swap out the image for one that is blinking (3 new images added for the blink).
So, now the symbols are nested like: 432 frames -> 27 frames -> 432 frames
But it doesn't seem like Flash is smart enough to animate it as I would expect. It only repeats the first 27 frames of the child symbol.
The next thing I tried was extending the 27 frame character animation out to 432 frames. I did this by copy-pasting the character animation 16 times. But this also does not work because copying the keyframes also copies the position of the child animation's playback. This causes the animation to constantly reset and never reach the blink.
I also tried using the copy motion option, but it didn't seem to do anything different than copying keyframes.Is there an easy way to make this animation work? I can't possibly need to manually position a total of 576 keyframes (there is actually another level to the nesting which does not use any tweens, just keyframes) could I?
View 1 Replies
Sep 11, 2010
if I add a clip to the stage as a child and remove the parent and set the parent equal to null, does the child get collected and removed from memory? What if the child has an image loaded into it as its child?
In my application I'm loading a series of png images as overlays that can be tinted for customizing in this app. When I trace my memory, the basic app idles at 64,000 k. The exact second I load those overlay images it goes up to 205,000k. If I remove those clips and "clear" the stage I should go back down to 64,000 k if everything is removed and collected correctly, right? It's not, it's hanging at 215,000 k. Are my images being cached and that is the reason for the memory staying up? If so, how do I prevent that. Or upon removing the parent of the image how can I un-cache the image.
If a user switches between models and loads several different items then the application actually crashes the Flash environment because of too much memory usage. It also does the same to browsers.
View 29 Replies
Jul 30, 2009
I have tried to create nested Sprite objects. But I see only the bigger square.
var square:Sprite = new Sprite();
square.graphics.beginFill(0xFFCC00);
square.graphics.drawRect(0, 0, 100, 100);
[Code].....
View 1 Replies
Aug 8, 2009
I once needed to pan a sprite full of movieClips (picture 1) which were draggable with no bounds so you could drag them up and left (higher than sprites registration point).
You could also drag them down and right and expand a sprite that way (as well) but that didnt matter.What did matter was how much is 'up' and 'left' from the sprite registration point so i can include that in my formula for panning.
This was easy to find, i just sorted my array of movieClips, sorted on x and sorted on y after each drag, and thats how i got my up and left points.
Now I am trying to do that same thing, exept my movieclips inside a sprite have a custom rotation (picture 2), so i also have an up and left point, except this time up and left are caused by rotations of movieClips inside a sprite... (and these are dragable as well with no bounds)
View 1 Replies
Feb 27, 2012
I have a "wrapper swf" that loads a remote flash player that in turn loads video preroll ads from various advertisers.
So my wrapper is the parent and the remote swf is a child and the video ad is a grandchild.
I am looking to capture the url that the grandchild will navigate to when clicked.
I am trying to trace it in the parent (wrapper) mouseUP and mouseDOwn event.
Is there a way to traverse ALL children until I get to the "bottom/last loaded" swf and get the URL?
I wish to save the url to a variable so I can launch the url in another player of my own as opposed to having it launch an external IE browser.
View 0 Replies
Nov 15, 2010
PHP Code:
var MapBtnArray:Array = [];
var MapBtnSprite:Sprite;
var i:int;[code].....
I'm using to code above to create several sprite on the stage, but when I click on the sprite, the index of each trace work just fine (output of J is according to the target i click); however MapBtnArray[j].x keep equals to "0".I want the coordinate of the sprite on stage, how come what i get is "0" instead?
View 3 Replies
Jul 23, 2009
I need to find out the parent of the current element.The trace statement gives me the Screen Number.What do I need to write if I want to find out the Topic Title for the traced screen No.
Code:
var myData:XML = <data>
<Lesson No = "2" Name = "LessonName">
[code].......
View 5 Replies
Oct 28, 2010
I'm sort of jumping in headfirst to some Flex/AIR stuff. I have a pretty solid background with AS3, but given the inherent hierarchal complexity of Flex (compared to regular Flash), I'm running into an issue.
Let's assume that you have an app where pretty much everything is event driven (common). Accessing elements in the near vicinity of the event target, or the event target itself, is trivial. I'm trying to find, however, the most practical (read: best, most efficient) way to find children that are far removed from the current context.
[Code]...
View 3 Replies
Jul 27, 2010
Given this:
PHP Code:
var container:Sprite = new Sprite();
var _myriad = new _Myriad();
var tff:TextFormat = new TextFormat(_myriad.fontName, 24);
[Code]....
...why is it that I can see my text when I do this:
PHP Code:
addChild(tf);
but I can't see my text when I do this:
PHP Code:
container.addChild(tf);
View 2 Replies
Dec 4, 2009
I am working on a tool for use in our office which creates XML. At this point I am working on getting an error message to appear when the user enters incorrect data in one of the textfields. I have a MC which contains my error message as well as a button. The button will move the MC back off of the stage. Everything works up to the point where I click the nested button. I suspect there is a problem in referencing the parent MC from the button.Here is the code for the entire project. I am sure there are more than a few errors since I am relatively new to AS
import fl.controls.RadioButtonGroup;
import flash.display.*;
load_file.addEventListener(MouseEvent.MOUSE_UP, do_load_file);//load file button click.
[code]........
View 0 Replies
Jan 15, 2010
Ok im rather new to flash so ill do best i can to describe this. I have a HealthBar movie clip with 3 layers, bottom layer is just a red rectangle, middle layer is a green rectangle that is a movie clip, and the top layer is just a border. the green rectangle movie clip has an instance name of bar. i put my HealthBar on my stage with an instance name of healthBar and i change it when the players health goes down by calling _root.healthBar.bar._xscale = health where health is 0-100.
this works all fine and dandy. now i have a movie clip of MiniBoss with an instance name of miniBoss# where # is a number of the layer depth when it is created. in the MiniBoss movie clip i have an instance of the HealthBar with an instance name of bossHealthBar. i tried to call from within the MiniBoss class bossHealthBar.bar._xscale = health but i get an error that there is no property of bossHealthBar.bar._xscale. how do i access the bar in the HealthBar in the MiniBoss clip from the MiniBoss class in its onEnterFrame() method?
View 2 Replies
Jan 22, 2007
I have 2 child movieclips nested into one working parent movieclip, then the parent movieclip is animated. The nested working parent movieclip should move to the side once a child movieclip is clicked. Currently, the parent is unaffected by clicking on a child movieclip. What gives?
Below is a layout of the movieclip:
Button List Box
| |
v v
Subparent(groups btn and list box)
|
v
Parent(animated)
I need the parent to animate once the child Button is clicked.
View 4 Replies
Jan 31, 2009
i have a nested swf that functions just fine.i have a parent swf (that holds the nested swf) that has a button (not related to functions of nested swf) that no longer works when combined.the button is simply a link button to a url... is there a very simple solution to this?
View 2 Replies
Oct 29, 2011
I'm making an action game and I'd like to know what should be the maximum size of the stage (mine is 660 x 500).Also I'd like to know how big a game-sprite should be. Currently my biggest sprites have a size of 128 x 128 and I read somewhere on the internet that you should not make it bigger because of performance issues. If you want to make e.g. big explosions with shockwaves even 128 x 128 does not look very big. What's the maximum size I can definitely use for sprites?
View 3 Replies
Oct 25, 2009
I can't seem to use removeChild. Basically this is what happens.From the Document class, or another movieClip class, I can addChild (movieClip) fine but when I go to remove them I get ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
even if I go: myMov.parent.removeChild(myMov) or (getChildByName(MyMov)) or anything it always either gives the above error or in the case of using .parent: Cannot access a property or method of a null object reference.
Also using trace() to find out what the parent is it always says [ object DocClassName] and the docClass seems to return the right amount of child MovieClips. Heres my code snippet:[code]....
Do I need to create some sort of Stage for all child MovieClips to belong to?
View 2 Replies
Feb 6, 2009
i'm having trouble trying to get the parent object (target movieclip) of a tween.example:
Code:
myTween.addEventListener(TweenEvent.MOTION_FINISH, doStuff);
function doStuff(e:TweenEvent):void {
[code].....
View 2 Replies
Apr 1, 2010
I have a sprite A which has a child, sprite B.Sprite B has a variable, instance of class C which only extends EventDispatcherIn class C, I dispatch a custom Event. The eventlistener in sprite B reacts on the event.The same eventlistener in class A doesn't respond.If I dispatch the same custom event in the eventhandler in class / sprite B, this event is seen in class / sprite A.Is there a difference in events going through the displaylist and those who are from an EventDispatcher?
View 6 Replies
Oct 25, 2009
From the two .as files below, I get the following error when I run: 1119: Access of possibly undefined property importantNumber through a reference with static type flash.display:Sprite.
[Code]...
View 2 Replies
Jul 9, 2009
I have setup a video interface with a stock video player in the parent mc. In the same swf next to the player, I have a mc which is a video thumbnail chooser. The thumbnail buttons are located two levels down within this mc (nested within two mc) in order to facilitate the scrolling independent of the player. In the parent, where the video player lives, I placed a function:
function vid1(event:MouseEvent): void{
pubPlayer.source = 'Steve480.flv';
}
In the child mc where the thumbnail buttons are, I want to call the parent function like this:
vid1_btn.addEventListener(MouseEvent.CLICK, vid1);
None of my clips are externally loaded, just nested in the same swf. How can I talk up or down the movieclip ladder?
View 0 Replies
Jul 9, 2009
I have setup a video interface with a stock video player in the parent mc. In the same swf next to the player, I have a mc which is a video thumbnail chooser. The thumbnail buttons are located two levels down within this mc (nested within two mc) in order to facilitate the scrolling independent of the player. In the parent, where the video player lives, I placed a function:
function vid1(event:MouseEvent): void{
pubPlayer.source = 'Steve480.flv';
}
In the child mc where the thumbnail buttons are, I want to call the parent function like this:
vid1_btn.addEventListener(MouseEvent.CLICK, vid1);
None of my clips are externally loaded, just nested in the same swf. How can I talk up or down the movieclip ladder?
View 2 Replies
Oct 22, 2010
Is there a way to find the location a clip in the library is used?
View 0 Replies
May 12, 2010
I know about Flash's localToGlobal and globalToLocal methods to transform coordinates from the local system to the global system, but is there a way to achieve the intermediate? To transform coordinates from an arbitrary system to any other arbitrary system?
I have a clickable object inside a Sprite, and the Sprite is a child of the stage. I want to retrieve the clicked point in the Sprite.
View 2 Replies
Dec 10, 2010
I'm trying to simulate some fade in/out effects in Action Script 3 programmatically, using Timer class and controlling alpha property of the specified DisplayObject in time. In general it works and looks great. As I was expecting. But after I add some more child DisplayObjects to the parent Sprite it starts to behave weirdly. Children seem to not fade at the same rate as parent object and it visually noticeable, and ugly. There seems to be a short lag after parent already started to fade out and before children actually follow. Are there any additional measures I should take to avoid that? I do alpha manipulation only on parent object. I thought that'd be logical...
View 2 Replies
Jul 18, 2010
I'm switching from as2 to as3 and everything was going swimmingly with my new site until i tried to use a _root call to a function on the main timeline by a loaded movieClip that is loaded nested into 2 other movieclips. the movieClip needs to tell the _root when it's done playing so the root knows to load the next one in line through a php call. Everything works except for the _root call. In as3 there's no such thing as root anymore so I figured no big deal, i'll just find out what the new thing is and holy crap wtf! I can't figure this out!! I've read from doing stuff like custom eventLisnters (which i am trying now) and casting the root as a movieClip and then I read this whole crazy tutorial on building an event structure and the proper MVC way of coding and blah blah blah ALL I WANT TO DO is tell the _root that the loaded MC has reached the end of its timeline. Basically if it were as2 i could just go _root.loadNext(); and it would work.how to make a loaded MC talk to the _root timeline and call a funciton from there?
View 19 Replies
Dec 2, 2011
I have a very specific AS2 parent/child movie clip issue. I have a main Character movie clip which contains as nested frames each profile of the Character (front,back,left,etc). Within each of these child profile MC frames, animations for those profiles are further nested in frames. Then, essentially I have movement code as part of the key listener:
Code:
switch(Key.getCode()){
case 87:
Character._y -= 10;
Character.gotoAndStop('Back');
Character.gotoAndStop('walk');
break;
[Code] .....
And later code to reset to the character's resting frame after key release:
Code:
switch(Character._currentFrame){
case 5:
Character.gotoAndStop('Back');
break;
[Code] .....
The problem is that when I try to Character.gotoAndStop('Front'); after key release, flash thinks, you're already on the Front frame (because the walk animation is a child of that MC and is already playing). Therefore the walk animation just keeps playing after the key has been released.
View 1 Replies