ActionScript 3.0 :: AddChild() Moves The Child Movie Clip?
Oct 5, 2009My issue is this: When I call MC1.addChild(MC2), it moves MC2 a few pixels from the location it was originally. I don't want it to move MC2,
View 7 RepliesMy issue is this: When I call MC1.addChild(MC2), it moves MC2 a few pixels from the location it was originally. I don't want it to move MC2,
View 7 RepliesI have a movieclip that moves on the X axis. Thing is, I need to make certain areas of it clickable... I have already tried a couple of things but didn't succeed.
View 1 RepliesI am trying to make a flash game for a website. In the game, there is a large interactive map which I created. The map is supposed to scroll just by moving the mouse.
As a placeholder for the map, an ex-coworker created a gradient background, which moves along with the mouse. Here is the AS.
// Width and height of image
var w = Stage.width * 2;
var h = Stage.height * 2;
// Mock up graphic that will be the image
[Code].....
how to make the MC move and pan along with the mouse? Even if it is a completely different code?
I have a movie clip that I would like to slide to the right or left depending on which button the user clicks. When I test the movie and click on the buttons, the target movie clip only moves one pixel. I want it to slide into place. What am I doing wrong?
[Code]...
I've a movie clip in the stage that moves from left to right.
And i whant to add more instances from that movie clip
I tried:
Code:
addChild(cloud);
stage.addchild(cloud);
i am trying to use the Tween class to change the size of movie clip to certain height.the code works for me but when resizing the parent, it effects the child.i tried the height and scaleY property for the thum, but does not work.
ActionScript Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
[code]....
I have an Movie Clip in Flash that have subobject of button type which has subobject of input text and movie clips. Right after creation core Moveclip all subobject are set to null, when I expect them to be valid objects.
[Code]...
MC_Core_design was created in Flash and exported to Actionscript. I've done this for button_1 class aswell. The code was written using Flex. When I comment out both lines that result in error I get correct view of the core Movie clip with all subobject. How can I set subobject properties right after object creation?
I really have two questions: How do I affect both a movie clip and its child movie clip in the same function? and how do I pull info from one component into a function for another? My basic setup is a movie clip of font choices, one on each frame: "bodyText_mc." Each of these frames has a child clip "bodyText_mc.bodyText" with alignment choices for the font. For instance, the user picks "Script" in the first ComboBox and then picks "Align Right" in the second. (All of this text is static because I need more design control that I can get with dynamic text.)
First of all, I have a combobox "cbBodyFont" that I use to go from frame to frame on movieclip "bodyText_mc." This works nicely:
[Code]...
I'm trying to figure out how to use addChild to place a movie clip. I've got it working, but I can't get it to load in the bottom level of the movie. No matter what I do, it seems to load on top of everything else. I'm definately a newbie with AS3, and had only a little experience with AS2, but the load / unload movie seemed so much easier than this. I've found tutorials on addChild, but none of them specify how to load into a specific layer/level.
[Code]...
I want to loop through a movie clip and assign a function to each of the clip's child movieclips. when i do a for...in loop and then do a typeof() trace I get "string" and obviously it won't let me assign lets say 'onRollOver' functions to the children.
View 6 RepliesI use the method addChild() to add a Movie Clip intoa nother one.mc1.addChild(mc2);But once the Movie Clip is added (and the second Movie Clip is higher than the first one) then it's displayed outside the first Movie Clip. Is there a way to prevent to display outside the parent?
View 6 Replieswhen I use:
var a = parent.addChild(cloud);
a.x=10;
a = parent.addChild(cloud);
a.x=100;
I only get one cloud made at the position (100,y) (or, the last cloud I declare is the only one to show). How do I add multiples of a movie clip ?EDIT: I tried using addChild(new cloud) but the compiler says "Call to a possibly undefined method cloud."
var viewStack:ViewStack = new ViewStack();
viewStack.percentWidth = 100;
viewStack.percentHeight = 100;
[Code]....
Its only displaying canVas3 contents not canVas1 and canVas2
I have 2 scenes. In both scenes, I have a movie clip that moves via keyboard control. If the goto next scene is triggered by the movie clip in the first scene the keyboard control works in the second. However, if I use a button to move to the next scene then there isn't any control over the movieclip in that scene. I've traced the keyCode in the second scene and it is picked up but the switch statement doesn't run. I'm migrating to Actionscript 3.0 and updating something I created in 2.0. I would like to do it without writing a class.
[Code]...
I have a movie clip called column1_mc. when I click a button I need to move the movie clip in incremental moves consisting of 30 pixels.
column1_mc._y = 30;
Does not work because that is giving a _y coordinate.For example.I need to make the movie clip jump to _y 300 but make 10x30 pixel incremental jumps. Moving 10 times 30 pixel jumps.
I have a label I am referencing form a movie clip inside the movie clip which contains the "label_2." Here is the code I used: MovieClip(parent.parent).gotoAndPlay("return_2"); Now I need to reference a instance name of a movie clip in side the same scene.
View 10 RepliesWithin the main timeline I have a menu, which is a MovieClip. This menu is comprised of about 17 "buttons", each of which point to a different section of the site. When a "button" is clicked (2 examples: menu_bag_button, menu_trashbag_button), the menu will animate, moving left, and 2 library items (bag_container and close_btn) should appear to the right, both within "framecontainer".Then, while the menu is on the left, this specific button must not repeat the menu animation, thus I did an if statement finding which frame it is on, and if it's on the left, it simply clears the framecontainer and loads the content again.
The problem is that when another link is clicked, it needs to do one of two things: if the menu is in the center with no content loaded, it needs to animate the menu to the right, and load the content/close_btn into "framecontainer"; or, if the menu is on the left, it needs to clear "framecontainer" and load the corresponding content.I've tried a lot of things but since all of these buttons are within "menu_mc", the actionscript has to point to the root, THEN to"framecontainer" and everything gets convoluted.Here is my current code. It functions fine, except for the fact that it doesn't clear content, so it continues loading the frames so that one is closed, there is still other content behind it:
import flash.display.*;
import fl.transitions.*;
import flash.events.MouseEvent;[code].............
I have a MovieClip instance which can be moved around the stage using startDrag() and stopDrag(). The instance also has some child MovieClips using addChild(). The parent moves the children when dragging, which is fine. The children have there own startDrag() and stopDrag() which should apply only to the child object, however it also moves the parent and other children. When clicking a child the MouseEvent of the child is being called but so is the parent.
public class Component extends MovieClip {
private var nodes_array:Array = new Array();
public function Component() {
x = 60;
[Code]....
Is there a way to contain a custom cursor within a placed (child) movie clip -- changing to the custom cursor when mouse is over the clip -- and then back to a regular cursor when the mouse moves off the clip?
View 5 RepliesI have an mc called parent_mc.. inside that is child_mc... now if i do in AS2
parents = new Array();
childs = new Array();
parents = [parent_mc];
[code].....
I used AS in mc 1 works perfect but same code don't works inside mc 2.
View 3 RepliesI have a movie clip on stage with several other movie clips inside of it. How do I refer to each child so I might do stuff to it? I have done it once before by name, but I'd rather not rely on names:
private function setUpHotSpots():void {
// loop through all the hot spots, hide them, and assign event handlers
var i:int;
var numberOfHotSpots:int = hotSpots_mc.numChildren;
[code].....
I have 2 movie clips, let's call them mcParent and mcChild. mcParent is a movie clip on the stage, and mcChild is a movie clip inside mcParent.I want to listen and execute a function (which is defined on the first frame of the stage), when mcChild is clicked. So I add the following script on the 1st frame of the main clip (stage):
Code:
mcParent.mcChild.addEventListener(MouseEvent.CLICK, clickChild);
function clickChild(e:MouseEvent):void
{
trace("click");
}
The clickChild function, however, is never called. So for whatever reason I am not receiving the event.
PS: I cannot add the event to mcChild. I know, that would be easy, but I need to have it this way, because when mcChild is clicked, I want to fade out mcParent (the clip that is on the stage).
I am designing a site which has a movieclip, say parent_mc, and inside that movieclip there is a movieclip child_mc which has a 10sec animation. In the document class I have created an instance of parent_mc and added it to the display list [code]...
Now this adds makes the child movie clip play over and over so I want to stop it right at the beginning, and add eventlisteners to play it. But how can I stop it in the beginning?
I have a portfolio page with several trailer thumbnails (a portfolio list). If you click on each, the page changes and you see the trailer in a video player, plus more info about the film. I used two frames in the timeline: the first frame has the clip with the thumbnails (port_list). The second frame has a movie clip container and the video player. The idea is that pressing the respective button from port_list will load the details of that movie and the movie into the video player. I am using this script:
ZSQ_but.onRelease = function (){
_parent.gotoAndStop("por_details");
myplayer.contentPath = "videos/ZSQ.flv";
por_details_cont.attachMovie("ZSQ_details","ZSQ_de tails",0);
}
Even though the script looks alright (and works alright if at the root level), it will not work from the child clip. What am I doing wrong??
I have a movie clip on the main timeline calledbg_graphics, I want to target a movie clip within that movieclip called bg1_mc. to gotoAndPlay frame 2.The bg_graphics clip goes to a random frame within that movieclip, there are 3 frames. 1st has bg1_mc, 2nd has bg2_mc, and 3rd has bg3_mc. How could i determine which file to gotoAndPlay frame 2 in bg_graphics when i don't know exactly which frame its going to be on, let alone target a movie clip within a movie clip.I used this code to generate the random frame
function randomBg() {
//generate random BG based on random frames within the MC
randFrame = random(3)+1;[code].....
I am transitioning into AS3 and I'm working a block that I can't quite figure out. I need to add a child (external image) to a movie clip and resize it. This is what I have thus far and it loads the image just fine:
var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest(myOBJ.image));
productImage_mc.addChild(imageLoader);
[code].....
I have a flash file which uses php to manipulate a database and returns a variable (data_xml) of xml formated data from the database. This happens, along with other things, within the parent. Now I have a child movieclip that displays the parsed data but I am having trouble accessing the variable from within the child movieclip. The code related to this is:
var myXML:XML = new XML();var myXML = XML(event.currentTarget.root.data_xml);
and I get the following two errors which point to the second line as the problem:
1151: A conflict exists with definition myXML in namespace internal.
Warning: 3596: Duplicate variable definition.
I have unchecked "Automatically declare stage instances" because I've seen that suggested for the 1151: error, but I still get the same two errors.
I have a movie clip of all counties in the state of Montana (allcnt_mc). Within allcnt_mc there are individual movie clips specific to each county with name equal to the county's name. When clicking on a county, I'd like to zoom to that county and center the stage on it. I've added event listeners to all counties through querying an xml table that has demographic info I am calling into dynamic text boxes. Here is the code I have thus far to load the xml and add the listeners to the county movie clips.
//load xml
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
[Code]....
I am trying to make a photo gallery in as3. I found a tutorial for a scrolling thumbnail panel and found how to convert it to as3.
What I would like to know is how do you get the larger image to display when the user clicks on a thumbnail in the scrolling panel? (I have 8 thumbnails, and 8 larger images).
ActionScript Code:
panel.addEventListener(MouseEvent.MOUSE_OVER, panelOver);
function panelOver(event:MouseEvent):void {
[code]....