ActionScript 3.0 :: Adding A Child Using Conditional?
Sep 10, 2010
I am trying to add a Child to the stage depending on what xml string is loaded based on a button click. I created a function for buttonFeedback but it breaks my code
ActionScript Code:
/*import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
[Code].....
View 7 Replies
Similar Posts:
Nov 24, 2011
The name of my DocumentClass is Main. So, what's the difference between :
var myClass:Main = new Main();
var mcInLibrary:MovieClip ;
/////////////////////////////////////////[code]............
View 1 Replies
Mar 9, 2010
I m making a basic menu effect. Normally I would animate all this in flash on the timeline but im trying to learn as much as i can about coding. I was actually impressed that i was able to create just this simple animation, but i want to write a conditional that lets me see if a child exists on the stage, if so remove it, if not run a function. Heres where I am so far.[code]as you can see the hardware text drops down and comes in from the top but stays on screen when you mouse out.basically what i want to do in my hardwareOut function is to run a conditional to see if topText exists, if so remove it and if not then gotoAndPlay().
View 4 Replies
Mar 23, 2010
I have a video being added to a mc:
mc.addChild(video);
I need to create a conditional statement to see if "video" is loaded in my mc so I can remove it to add an image into the mc
if (mc...=="video"){
removeChild(video);
mc.addChild(image);
}
Not sure how to create the "if" part.
View 6 Replies
Jun 16, 2009
With this code, I need to determine if the xml child is null and form a conditional statement upon that info.I have it very close but something is just "un-tweeked" enough that it wont work correctly.AS3 and XML provided below...
Code:
var url = txtBox_mc.getTix.url;
var request:URLRequest = new URLRequest(url);
txtBox_mc.getTix.addEventListener(MouseEvent.CLICK, GetUrTix);[code].....
The problem now only the " if (url == null) { " is read, thus returning those results. I believe the issue is within the definition of url " var url = txtBox_mc.getTix.url; "...
View 3 Replies
Dec 17, 2009
I have this code: btn_nav.addEventListener (MouseEvent.CLICK, navPop);function navPop (e:MouseEvent):void{themIn = new Tween (btn_them,"alpha" ,None.easeOut,0,1,10,false);}I need to set up a conditional adding / removing this btn alternately on click - just not really sure how to approach that.
View 3 Replies
Mar 10, 2010
var viewStack:ViewStack = new ViewStack();
viewStack.percentWidth = 100;
viewStack.percentHeight = 100;
[Code]....
Its only displaying canVas3 contents not canVas1 and canVas2
View 1 Replies
Mar 11, 2010
I've seen some discussion on how to load a child swf using swfLoader and accessing it's variables but I am wondering if it is possible to do this without adding any code to the child swf.Either accessing public vars or listening for funciton calls would work fine
View 2 Replies
Jun 6, 2011
i am slightly confused about the parent and child relationship. lets assume we have several different instances, what would be difference of adding them all as children of the stage and creating a parent-child hierarchy between them(other than the access path).
View 5 Replies
Aug 4, 2009
However, either I'm declaring my variables at the wrong bit/way or there is another problem, as I have been able to add the child I want to from the display list (sidepoint: is it right to call the display list everything in the library on stage at runtime plus those things you have exported for actionscript usage??!)...but when I want to remove it at the next cuepoint nothing happens. I feel this is a basic principle that is alluding me here.
Code:
vid.addEventListener(MetadataEvent.CUE_POINT, cueText);
function cueText(e:MetadataEvent): void{
[code]....
View 1 Replies
Apr 27, 2010
The package code below is directly out of the Adobe flash help system: It works fine as an external .as file. However, I want to add some buttons from the library. I haven't been able to add another child, no matter where I put the code. I also tried putting the code to add a button in the internal movie frame script, but when I put ANY script there, I get this error "1180: Call to a possibly undefined method addFrameScript." The add button script, where Sub1_Btn has been exported for Actionscript and set up as a class in the buttons property window.
[Code]....
View 1 Replies
Jan 28, 2009
I am currently working on a project that has me adding and removing a notepad that is a movieclip. Initially, I put the notepad to the outside of the stage and just moved it in with a button click, but now I want to make it so that it appears and disappears from the stage.
I tried the following code and kept getting a 1010 error. Property undefined for "addNotepad".
View 1 Replies
Jan 22, 2010
I'm exercising scripting and struggling with adding a child to a object when the creation of the child is wrapped in this function
function makeBox():void {var box:Shape = new Shape;box.graphics.beginFill(0x66FF00);box.graphics.lineStyle(5, 0x6600CC);box.graphics.drawRect(mouseX, mouseY, 50, 50);addChild(box);}
Now I want to add the above shape as a child to this object
var Clip:MovieClip = new MovieClip;addChild(Clip);
if the first code was not a finction I have no problem to add the child by Clip.addChild(box); but I cant figure out how to use it if it is as a function.
View 5 Replies
Jul 24, 2009
I'm not talking about removing a child by simply using the removeChild(); method, but a more complicated (I think) way. For example, If a add a 'box' MovieClip with addChild, and I have a 'close' button inside the 'box' MovieClip, I want the 'box' MovieClip to disapear when I press the 'close' button. I tried
Code:
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {
[code]......
View 3 Replies
Feb 4, 2009
I have a MC with a sprite in it. I give it a wee tween
Tweener.addTween(mainImageBox, {height:355, time:1, delay:1, transition:"elastic"});
All fine and dandy but when I add a child
mainImageBox.addChild(loaderAnimationMC);
The child (loaderAnimationMC) is all scaled up, is there a way to prevent this?
View 1 Replies
Aug 4, 2009
I am adding a child to the stage in my first swf
Code:
addChild(new donkey());
var l:Loader = new Loader();
l.load(new URLRequest("next.swf"));
addChild(l);
in my next.swf, I have a button which I want to remove the donkey with::
Code:
removeChild(donkey);
OK - doesnt work - it doesnt let me export the swf anyhow because the next.swf has no 'reference' to donkey existing at all. What's going on?
View 11 Replies
Feb 9, 2010
I am new to flash as3, I am trying to figure out how do I remove a child after I add one into a mc.
here is my code:
[Code]...
I cant remove the child if i add a child inside a movieclip, is there something that iam doing wrong ?
View 4 Replies
Aug 6, 2009
I am working on an application that has buttons (movieClips) to set the color of user input (graphics, type, etc...). When clicked, the selected button displays a movie clip of a palette of 35 colors.I open the palette with the following function (is that the same as a method?):function openPalette(event:MouseEvent):void event.target.addChild(colorPalette);}I can then click on the colors in the palette to select the color I want.However, since the palette is a child of the button, clicking on a color within the palette triggers the same function as clicking on the parent button again. I get the following error:ArgumentError: Error #2150: An object cannot be added as a child to one of it's children (or children's children, etc.). at flash.display::DisplayObjectContainer/addChild() at design_AS3_ii_fla::MainTimeline/openPalette()
View 4 Replies
Oct 9, 2009
I'm working on building a gallery, but I've run into a slight snag. The full-size images are not all the same size, so they will overlap when loaded. In the showPicture function, is there a way for it to check to make sure there isn't a full-size image already loaded, and if there is, to remove it before adding the new one?
var imageLoader:Loader;var xml:XML;//parse XML data as an arrayvar xmlList:XMLList;var xmlLoader:URLLoader = new URLLoader();xmlLoader.load(new URLRequest("data/gallery.xml"));xmlLoader.addEventListener(Event.COMPLETE,
[code].....
View 2 Replies
Sep 1, 2010
I'm adding various movieclips to the stage with the following code:var invis_obj = new invisible_li_mc();addChild(invis_obj);However, when I try to access the movieclip such asinvis_obj.buttonMode = true;I get nothing however, something like invis_obj.alpha=0; works fine..
View 7 Replies
Jun 18, 2011
im trying to add an extra movieclip to stage with this code, i want an extra movieclip added every 10 seconds..
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);
function fl_EnterFrameHandler(event:Event):void{ addChild(movieclip); }
This error shows up:setInterval(fl_EnterFrameHandler,10000);ArgumentError: Error #1063: Argument count mismatch on Untitled_fla::MainTimeline/fl_EnterFrameHandler(). Expected 1, got 0.
View 1 Replies
Apr 12, 2012
I am trying to make a "Achtung! die kurve" - like game in Actionscript 3.0. So far I've done the movement of one of the 'worms', and it works alright. I wanna divide it into different class files, but I can't seem to get it to work. I have a .fla file and 4 .as files. So far I only have code in two of these. When I put all my code directly into the fla file, it works perfectly fine, but when I put it into my player class, it won't 'add the child' to the stage. Here is my player .as file: [URL].
The reason why I commented the addChild, is because I wanna do this in my mainFile.as. This is from the main file: [URL]. I'm not quite sure how to call it in the main file, so I'm guessing that this would be the issue. All the files are named and placed correctly in the same folder, and flash says that each of my .as files are targeting the .fla file, so this doesn't seem to be the issue. How I can change the speed of my sprite.
View 1 Replies
Mar 8, 2011
I'm having a problem when adding a child to a VBox component. Is it not the same thing?:
List Item:
<mx:Script>
<![CDATA[
public function addChildren():void {
[Code]....
I am injecting two properties (question and answer) to the FaqItem component from an auxiliar file (using BabelFX) that depends on the id of the FaqItem, but it is only working when I choose the second option. If I use the first option, I get a child but with the text in question and answer fields is empty. I need to use the first option.
View 1 Replies
May 23, 2011
Within a child, I have an XML element with the following structure:[code]I then use a repeater to list each out onto the screen. There's a button I have created that is used to create a position. So, once the user clicks this button, I call the following function:[code]The above function creates a new XML object, puts some default values in, and appends it to the list of project positions. After appending the new information, I made the height of the project larger and then check to make sure the new project height isn't overlapping any other projects... but that information is irrelevant to this post.My problem is this - once i append a new child to the XML variable, it doesn't appear on the screen. Is there a "refresh" or "re-render" option i can do to the repeater in order to make the new child show?[code]Once i make the changes, and use the XMLListCollection as the dataprovider in the repeater, the information no longer loads on the screen.
View 1 Replies
Jan 25, 2009
I want to addChild at certain frame say 130. And I used the following format
var btn1:Button = new Button();
gotoAndPlay(1);
addings();
[Code].....
put and even I can't get the trace result. how to add childs at any frame number I want
View 3 Replies
Oct 9, 2009
I'm working on building a gallery, but I've run into a slight snag. The full-size images are not all the same size. In the showPicture function, is there a way for it to check to make sure there isn't an image already loaded, and if there is, to remove it before adding the new one? [code]...
View 9 Replies
Nov 9, 2009
I have 4 separate photogalleries, they are all swfs called by buttons with UI loaders attached. The problem is when one is called the loader remains on the stage I need to be able to remove any loader on stage BEFORE calling another page weather its a photogallery or not.Easiest explanation is how I used to do it in AS2 example 2 btns /2 load separate swfs into level1 on each btn I would have
unLoadMovie(1)
LoadMovie (xxx.swf) 1
I need to do the same thing in AS3 Also, do I need to use separate loaders or can I use one loader and instance names? Below is the code I have now (btns are in two areas)
main timeline btns (all btns except photogallaries)
stop();
home_btn.addEventListener(MouseEvent.CLICK, onHomeClick);
[code]....
View 0 Replies
Jan 14, 2011
I've got a MovieClip that has 3 frames with different text content. I made another MovieClip and within its class I defined this code:
//this is the class of a MovieClip with a human face
if (something happens)
{
var dialogueBox = new DialogueBox();
this.parent.addChild(dialogueBox);
this.parent.dialogueBox.gotoAndStop("dialogue_info _01");
[Code]....
View 2 Replies
Sep 30, 2011
is it possible to add multiple children(twins) with same instance to add on different parents ?
Here we have an example showing that it fails to perform adding same child (photobg0) with instance on a new parent (page0 and page2).
My primary issue is: if i add too many objects on stage flash starts to lag especially if it is a movieClip from librarery, externaly loaded swf or image files
I am trying to duplicate child objects ,gussing this might prevent lagging?
ActionScript Code:
var request:URLRequest = new URLRequest("images/photobg.swf");
var photobgx:Number = 19.80;
var photobgy:Number = 90.55;
[Code].....
View 2 Replies
Nov 24, 2009
chat.fla
Code: Select allimport maero.entities.*;
var p:Player = new Player(1, "player one");
[code]....
There we go. What i want to do is, I want to create an instance of the Player class, which then creates an instance of the Actor class, which in the _draw() function should add an image to the stage, but I can't figure out how to do that. I want this image to be an instance in the Player's Actor instance, so i later can move it around, the same goes for the user name text. how do i add an image and a user name text field to the stage at player.__x and player.__y?
View 1 Replies