ActionScript 3.0 :: Changing Parents Of An Object?
Mar 30, 2010I have a sprite within a movieclip that externally loads an image, how can i change the parent of the sprite to display on the main stage?
View 1 RepliesI have a sprite within a movieclip that externally loads an image, how can i change the parent of the sprite to display on the main stage?
View 1 RepliesI would like to know is there a way to iterate through all parents in a display object. I need to do this because i am loading swfs to application and swfs have different number of nested movieClips and i would like to be able to access loader properties like width and height dynamically from within any depth. How can i do that?
View 13 RepliesSo I have a bunch of objects (thumbnails) and I want every photo to be displayed on top of other photos once it's clicked. So what should I put inside the click handler inside the photo object?
View 1 Repliesok, my Digital arts class is making a flash project, and im like the only one actually making a game, so im pretty much alone. i got a lot of help from the people on the AS3 forum, but im pretty sure that my question is too easy to put there. so, i have an array, and it basicly puts a spike on the screen at a random Y, and moves it across the screen, but, when i hit a spike, and ti goes to the you lose screen, the loop keeps adding children, and putting them on the screen, is it possible to just say stop adding children, and go to the next frame? i have a break, but when i stop colliding with the spike in the next frame, the spikes start coming again. also, can i totally reset the movie? cause when i just go to frame 1, the array plays itself ontop of itself and it gets twice as hard
View 2 RepliesI want to get the full parent node on a result of a search.
XML example:
<ItemNodeCollection>
<MaxProf>1</MaxProf>
<ItemNodes>
[Code].....
How can I achieve this expected XML result?
graphicsSpace.graphicsInnerMenu.selectFolderMenu.imagesButton.addEvent Listener(MouseEvent.MOUSE_UP,imagesPage_change);function imagesPage_change(e:MouseEvent):void{
[code].....
what the most efficient method is for listening for events up and down a string of parents and children? Example:
(these are parents from left to right) Main Sprite -> Child A -> Child B -> Child C
Child C fires and Event - what's the best way to have Main Sprite listen for it?
1) Make Child B and C "public" so Main Sprite can attach a listener all the way down on C (_childA._childB._childC.addEventListener)
2) Child C's event triggers a Child B event that triggers a Child A event that Main Sprite listens for
I basically have a large bar of items that fills up dynamically, they are all added to a dispCont movieclip as a container. When you click on one it gets pulled to the front, scales up and I want all the unselected Items to blur or become semi transparent. So i figured i could just tween the dispCont object, however this affects whatever is brought to the front, so i want to switch that into a new MovieClip called centerCont. Here is the code, ive been trying different things, I could just use a little input.[code]when I click on it because i am trying to set event.target.parent = centerCont;otherwise, uncommented and that removed i get Code:1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.
View 0 RepliesSeems simple and I've searched but can't find the answer to this simple problem.
Loading map-.swf into main.swf. I want to use a variable from main inside map-1 to indicate which xml file to load.
First problem, I'm coming to AS3 and if a variable isn't declared, then errors, can't compile. So do I have to declare this variable in both swf files?
And well I've tried declaring the variable in the loaded swf and it still doesn't work.[code]...
There is the stage, the level object then the player object in the level. The player object has a sub-object that is a weapon. When I fire the weapon a bullet is to be placed on the level stage. At the moment I have this code in the weapon class when the weapon is fired.
[Code]....
(In case it helps you know my skill level, I'm currently reading Foundation Game Design with Flash by Rex van dur Spuy and am a PHP web developer, also played around with Flex - ActionScript is still new to me)
i have a shape on stage that i need to randomly change color using as3 i've tried doing this a few ways and have had no success.
View 1 RepliesI'm coming to AS3 from Director Lingo. In Lingo, a 'sprite' is vaguely equivalent to an object in AS3 and a 'cast-member' roughly corresponds to an AS3 library symbol. In Lingo I make a lot of use of lines likesprite("image").member = 25which changes on the fly the cast-member associated with a sprite, giving an instant image change when the user drags a dial, for example. This is particularly useful because the cast members in Lingo can be addressed by their sequence numbers as well as their names (giving a sort of implicit array addressing).In AS3 I can't see how to replace an image object with another image (not just a simple variation of the original). And even if I could do that, I can't see how to get the pseudo array addressing facility which I need to allow me to choose by code what image from perhaps several hundred will do the replacing.I guess what I'm asking for is maybe contrary to simple OOP.
View 0 RepliesIs there any way to do this? Say I have a global variable called yarr: _global.yarr = textbox; and I want to change that in to a string, I want to change it to "textbox" instead of textbox. Is there any way to do that?
View 8 RepliesI've got another simple question. I have a mc who's bitmap that is associated with him I want to change.
[Code]...
When BlankClip is first created, I want to tell it to either have the same image as Block_0 or Block_1. Looking it up online, it seems like I have to use BitmapData somehow, but I'm really unfamiliar with things...I've been working on this same code for about 2 hours...
Say I have a global variable called yarr: _global.yarr = textbox;
and I want to change that in to a string, I want to change it to "textbox" instead of textbox. Is there any way to do that?
I would like to know is there a way to iterate through all parents in a display object.I need to do this because i am loading swfs to application and swfs have different number of nested movieClips and i would like to be able to access loader properties like width and height dynamically from within any depth.
View 2 RepliesOkay, here is the relevant files for a game I am making and their structure: -Stage -->MainMenu.as --> NewGame.as --> beachArea -->barrel.as.................................................. ......-->player.as.................................................. ......--> pistolBullet.asSo, am trying to detect when a bullet hits a barrel. I was going to use the hitTestObject() functionI got as far as trying to actually access the properties of an instance of barrel from the pistolBullet.as and seem to be a little confused as to my findings.. Can anyone explain to me why the last trace function returns undefined?pistolBullet.as:
Code:
trace("pistolBullet.parent: " + this.parent);
trace("pistolBullet.parent.beachArea: " + MovieClip(this.parent).beachArea);
[code].....
I'm making a game in action script 3. In it, I have an actor class from which player and enemy classes will be derived. I'm doing this so that unless I need to provide specific AI or fancy behavior (such as for bosses), I can just make a new clip in the library for each enemy without making an actionscript file.
However, I've run into a problem.
Whenever I try to pass arguments to the construction of an enemy (make it spawn with more health), I get error 1136 (Incorrect number of arguments.)
This is because the constructor created automatically at runtime doesn't have the same arguments as it's parent class. Is there any way to get around this without making a class file where I copy and paste the parent constructor function for each of my hundreds of enemies?
we have java and flex projects at work. We currently have 1 base pom that contains the configurations we want to use for both projects. Problem with this is: flex projects inherit configuration for javadoc and pmd for example, which they do not want.
I want to do this a bit more clean and have a real base-pom and then a java-base-pom and a flex-base-pom. But how does this work in a multimodule that has both a flex part and a java part?
We have plugins to our own application where we use the following structure:
my-plugin
my-plugin-client (flex)
my-plugin-server (java)
The my-plugin just contains a pom.xml with section. I would use the my-plugin pom.xml as a parent to both, but then I cannot also use the java base-pom or the flex base-pom also as parent.
My parent ActionScript3 file has functions like these:
package
{
*lots of import.*
public class Tabu extends MovieClip
{
[Code]...
I have several buttons on an externally loaded swf that work fine but I'd like to clean up the code if possible. Is there an better way to target the mc other than using multiple _parents?
Code:
on (rollOver) {
_parent._parent._parent._parent._parent._parent._parent.expression.gotoAndStop (2);
} on (rollOut) {
_parent._parent._parent._parent._parent._parent._parent.expression.gotoAndStop (1);
}
The thing is I am not exactly sure if this mc is going to remain an external swf or if it will eventually stand alone, which is why I haven't targeted the root at its level. I'd like it to work either way if possible.
This may well just be because it can't be done but here goes.Does anyone know of a way that I can make a MoviecClip "visible=false" whilst stopping just one of its children's, children's, children...etc from also going invisible.I am aware that it can be done by setting them all individually but this will take a lot of code (and I like tidy code...and I'm lazy), and I am reluctant to use a loop as it will interrupt the animation that is going on at the time.
View 2 RepliesThis is my first post. I'm new to actionscript, but not to programming. I hope to learn a lot from these forums. To the point: I decided a few days ago that I wanted to create a flash game. I'm taking an object-oriented approach to the game design since that is what I know. The issue I am having is that I have a class called Hero that inherits from a class called Entity. Now my issue is that I don't want Hero to call the Entities class constructor when I initialize a new Entity.
View 5 RepliesOkay, here is the relevant files for a game I am making and their structure:
[Code]...
For the first stage, I was able to build a walk-through demo in flash pro by creating buttons that when clicked caused the flash to change to different frames. easy enough. Now for the final part of this project, I need to make the interface fully interactive, as I was trying before. ie: you can click any button and lights go on and off or a loop counter increments, etc. Since there is logic involved and too many permutations to do a frame for each possible state, I'm back to trying to do this in an object oriented way. I've got some test code here.
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
[code]....
debugger has some errors, so i don't know what exactly it will do. the errors are at the last two if statements where i'm trying to change the object property setting of the label. there is another error at the last curly bracket.
the idea is that there are two labels and a button. the first label starts out visible. when the button is clicked, a counter is checked, and incremented, then the counter is again checked and the appropriate label has it's visible property set to true. the intent is that in a list of several labels, pressing the button scrolls down them, until you press while on the last, which resets the counter and the first label becomes the visible one.
I'm having a game in which i control an MC with the keyboard arrows and when i click outside of the flash application and back in the MC loses focus. The focus changes to a button within the stage. What i've observed is that the Flash Player has a built-in control that moves focus from an item to the other with the arrow keys.
View 3 Repliesi am making this simple drag and drop game using flash cs3 using as2.i got 4 games and it has the same codes but different game type.. basically it uses drag and drop.here is the problem, when i finish the game, and press the back button to go to the selecting game scene, the last object dropped in the previous game stays and appears in the scene after that.
below is the as2 code i am using.
---
// global variablesvar tabbingON = false;var draggingON = false;var selectedPiece = 0;var totalPieces = 10;var total = 0;var mySound = new Sound();var origPos:Array = new Array();var justHit = false;var offset = 50;var counter = 0;
// function callsinitGame();
[code]....
my designer made a fla file where he has animated layers loads of them. All the images inside those animations are loaded from outside the swf.
Now, the issue is at one point in time I want some of the objects to go under another object ( current their on top) . If I do this visually the images inside the swf(loaded) are lost.
I have a string of about 5 movieclips that are tweened so that when you click left or right they slide in that direction. When you click on the movieclips themselves I want them to:
on mouse down - move to (y-5)
on mouse-up - move back (y+5)
this all works fine, however after I have clicked on one of the movieclips to make it jump, when I click left or right to slide them all over again they don't slide with the rest of the clips anymore?
okey i am making this simple drag and drop game using flash cs3 using as2.
i got 4 games and it has the same codes but different game type.. basically it uses drag and drop.
here is the problem, when i finish the game, and press the back button to go to the selecting game scene, the last object dropped in the previous game stays and appears in the scene after that.
below is the as2 code i am using.
HTML Code:
// global variables
var tabbingON = false;
var draggingON = false;
[Code].....