ActionScript 3.0 :: Accessing Newly Created Childs T
Jul 20, 2009
I have a script that randomly pops out circles all over the stage. However, I want them to disappear once I roll my mouse over them (and only the ones I roll over, not all the instances).So if I have code like this in a function:[code]And then I have a mouse_over function in the same class, how do I tell it to removeChild? Since the stars are instances of the object, they are giving instance names like instance67, which makes them hard to remove.
View 2 Replies
Similar Posts:
Dec 30, 2003
I created a MC with a simple createMovieClip, in which I load a movie. This works.
[AS]
_root.createEmptyMovieClip("pmpPlay", 2);
loadmovie("play.jpg", pmpPlay);
[code].....
View 9 Replies
Jun 16, 2011
I am completely new to actionscript although I do come from a OOP background. I have been asked to trial Flash and Actionscript 3 in particular - so I do come with a few preconceptions on how I expect actionscript to behave. I have a problem I donot understand. I have created a new class and to test it I use a simple test harness in the form of a .fla file.
The issue I have is when I create a new instance of the class and assign it to a variable, subsequent background changes to that instance of the class are not 'picked-up' when referenced through the variable. I would expect that given instance of class could be assigned to many different variables and any updates using one variable would accessible using any of the other variables.
[code]...
View 1 Replies
Mar 11, 2010
I have a MXML button:
<mx:Button id="myButton1"/>
How do I create N number of Buttons with Actionscript: myButton2, myButton3, myButton4... myButtonN ?
And how to get the reference to the newly created buttons right after they are created? Like I should be able to do myButtonN.x = 100 right after it's created.
View 1 Replies
Jul 14, 2003
How flash setup a variable to handle the newly created movieclip?
Example:
this.createEmptyMovieClip("mymovie",2);
this.clientscroller.setScrollContent(mymovie);
Where did I set it up as a variable? I tried this and didn't work either:
this.createEmptyMovieClip("mymovie",0);
mymovie.createTextField("mytext",1,100,100,300,100 );
View 5 Replies
Aug 24, 2004
In the code I'm writing, I use a with block to reference a newly created object thus:
[Code]...
I tried doing this.xot, xot, and other stuff, but it just keeps sliding under _root.xot instead of ArrowL##.xot.
View 2 Replies
Jan 29, 2007
I've started getting to grips with using the BitmapData class and a Transformation Matrix in the hope that I can start making some interesting image effects. However, at the moment Im having trouble figuring out how to shift the newly created bitmap so that any scale transformations are applied from the center rather than the top left corner. See here for example: [URL] The flower on the left is the original, the flower on the right is the new image created using "bitmapData.draw()". It has been scaled up to twice the size, but I want this to happen from the center of the image.
[Code]...
View 5 Replies
Nov 15, 2009
Image's paths are in the xml file. I make a loop to load images to the Display List.
So if i have a loop:
ActionScript Code:
for(var i:int=0;i<xmlList.length();i++)[code]....
after it is done i would have access only to the last imageLoader instance. How to get access to the rest of images, which were added to the Display List with the same name "imageLoader".I tried to call it with the imageLoader.name property,but surely i do something wrong, as only errors appear in the output panel.
View 1 Replies
Jun 1, 2011
Do I need to create all objects which i will possible use with itemRenderer in createChildren function, even if the current item must not show some of them ?
View 2 Replies
Feb 2, 2005
I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.
var xml:XML;
var xmlReq:URLRequest = new URLRequest("xml.xml");
var xmlLoader:URLLoader = new URLLoader();
[code]....
View 2 Replies
Oct 22, 2010
So, you have a sprite, you draw some graphics, you set cacheasbitmap=true... I can't seem to access the newly created bitmap data, to access the dispose() method.
[Code]...
View 6 Replies
Jun 6, 2010
I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.
var xml:XML;
var xmlReq:URLRequest = new URLRequest("xml.xml");
var xmlLoader:URLLoader = new URLLoader();
[Code]....
It dies every time on that last line. How do I refer to that vidThumbn instance so I can add the imageLoader? I don't know what I'm missing. It feels like it should work.
View 2 Replies
Oct 13, 2009
The following code adds 10 instances of circleMC to the stage. Inside circleMC is a dyn text field that increases in number from 1 - 10 so I have numbered circles on the stage.Each circle needs to open an infoBox which will contain variables unique to that box. I can't figure out how to address each infoBox. How would I say something like on circle1 set infoBox1.visible=true?
code:
var jurNum:uint = 0;
addBtn.addEventListener(MouseEvent.CLICK, onAdd);
function onAdd(evt:MouseEvent):void {[code]........
View 8 Replies
Mar 17, 2009
If objects are created dynamically in AS3, using code like this:
for (var num:Number = 0; num<10; num++){
var txtFld:TextField = new TextField();
txtFld.text = 'This is the original text';
this.addChild(txtFld);
}
then later, i want to changet the text of one of the TextFields, how can I do that? The only instance listed in the variables is a single instance of "txtFld" and it is the last one that is created. How can I access the others?
View 1 Replies
Nov 21, 2008
I have an application that I am adding movieclips to a container movieclip through a for loop and repeatedly calling myClip.addChild(theNewClip). Now I have a dozen clips in my container and it seems like the only way to access the clip is to use the getChildByName() method and cast it into a temporary clip so I can get at the its properties.
Is this the best and/or only way to do this? Does the old AS2 myContainer["theName"].property not work with dynamically created movieclips? It doesn't seem to work for me anymore.
access a dynamically created movie clip.
View 1 Replies
Nov 21, 2008
I have an application that I am adding movieclips to a container movieclip through a for loop and repeatedly calling myClip.addChild(theNewClip). Now I have a dozen clips in my container and it seems like the only way to access the clip is to use the getChildByName() method and cast it into a temporary clip so I can get at the its properties.
Is this the best and/or only way to do this? Does the old AS2 myContainer["theName"].property not work with dynamically created movieclips? It doesn't seem to work for me anymore.
access a dynamically created movie clip.
View 1 Replies
May 11, 2010
I created a canvas in a function, and in his function I have a CLICK eventlistener. On the click I want to manipulate what's inside the canvas. Will referencing the canvas using the Dictionary class work?
View 1 Replies
Dec 15, 2009
I am able to dynamically create an object on the stage with a function, but I am at a loss for how to access and manipulate the properties of that object from my Main Class.
in my Main Class I have:
ActionScript Code:
NLP_addChild.addObject(stage)
// NLP_addChild is the other class addObject() is the function
in NLP_addChild Class appears the following:
ActionScript Code:
public static function addObject(stage:Stage)
{
var myCircle:MovieClip = new circle()
[code]....
myCircle displays correctly on the stage, myCircle is correctly assigned an x of 300. But myCircle x property cannot be assigned from my main class.
View 2 Replies
Oct 16, 2011
I have a MC with 2 children in library:
myParent1 -> myChild1
-> myChild2
when I put it on stage in editor and run following script, both trace are valid and give response "true":
ActionScript Code:
trace (myParent1.myChild2.visible); // true[code]....
but when I put MC on stage dynamically via addChild, the first trace gives
compiler error while second trace works(error: Scene 1, Layer 'Layer 1', Frame 1, Line 81120: Access of undefined property myParent1)
[code]....
View 3 Replies
Mar 14, 2012
If you have a series of sprites created in a loop:
ActionScript Code:
for (var i:int = 0; i < numItems.length(); i++) {
var mySprite:Sprite = new Sprite();
}
Which you added event listeners to, in the same loop:
ActionScript Code:
for (var i:int = 0; i < numItems.length(); i++) {
var mySprite:Sprite = new Sprite();
mySprite.addEventListener(....
}
How can you remove those listeners, then add them again? I need to kill and re-enable the listeners of many sprites which were created that way.
View 4 Replies
Jan 7, 2009
I am creating a text scroller and am having problems with clearInterval - the text starts scrolling, but it won't stop after I try to clear it upon a button click.
1. I declare a var (uint) equal to a setInterval() call within a function (if the text exceeds the width of the textField)
2. I have a button that "turns off" the mp3 player (swf) and resets all the text fields.
3. I can't seem to access the setInterval ID var from within the click handler.
I have declared the var (uint) at the root level, then set it to setInterval() within the function. Then I tried to access it from the click handler. I thought this would work since it's global at that point, but it doesn't.
Here's a link to the page so you can see how it doesn't work [URL] (you have to click on the last link with the long client name)
Here's the code that's involved with this function (of course this is only the relevant code, but I would post the fla when done for anyone who wants to use it):
Code: Select all//::: SCROLL DISPLAY TEXT
function scrollDisplays():void
{
(trackTextField.textWidth > trackTextField.width) ?
[Code].....
View 8 Replies
Feb 4, 2010
basically what im trying to do is create a jigsaw game, simple eh! i have nothing on the stage at compile time, only four items in the library. these are four different puzzle pieces with export names of "piece01" "piece02" "piece03" and "piece04". my AS goes like this:
ActionScript Code:
var puzzlePieces:Array = ["piece01","piece02","piece03","piece04"];
var len:int = puzzlePieces.length;
var pieceList:Array = [];
[Code]....
how do i or what name do i give the addEventListener to? (if that makes sense)
to be able to drag them.
View 5 Replies
Aug 23, 2010
I'm trying to build a relatively simple photo gallery where the images are loaded via XML into thumbnail movieclips that have been dynamically generated, positioned and added to the display stack. I used a simple for loop to generate the thumbs and traced the thumb.name to make sure they all had unique instance names. I then added a listener to the thumb mcs in the for loop and created a function that traces the instance name of each thumb mc, to see if all is working, however, every thumb mc traces the same instance name. My question is how can I create the thumbs dynamically in a loop and, essentially, make them buttons that would display the big the full size photo.
Here is my prototype code:
ActionScript Code:
for (var i=0; i<12; i++) {
var thumb_mc:MovieClip = new thumb();
// Positioning: The xy coordinates are in an array outside the for loop.
[Code]......
View 4 Replies
Sep 27, 2007
I have generated a series of buttons using this:
Code:
duplicateMovieClip(sign, "sign"+z, z)
while still inside the loop that is creating the buttons I can get to each sign:
[code].....
View 3 Replies
Mar 9, 2011
how to access the properties of the movieclips which are created during runtime.
Ex:
var dotCount:uint = 0;
for(var i:uint = 0; i<=10;i++)
{
var circle:MovieClip = new MovieClip();
[Code]....
How can I access a property (say .alpha or any other property) of "circle6"??
View 2 Replies
Sep 17, 2009
Im dynamically creating an instance of a movieclip, call it a game piece. This game piece has 4 frames, each with a movieclip called base(although one is red, one blue, one green, one yellow). When the game piece is created I set the frame to indicate player color. Im also changing the alpha of base to 1.0 when its being dragged, 0.5 when its dropped.
Using the following code, everything works fine if the game piece color is set to the base in frame 1 (red). If the game piece is created and the timeline moved to a frame other than 1, I throw an error when trying to access base.alpha (this would be the second, third, and fourth instances of base in the game piece timeline). Heres the strange part, this is only a problem when the game piece is first created and added to the display list. Once created, even after the error has been thrown, I can access the alpha of bases 2, 3, and 4 in the drag start/stop listeners. Heres a link to the work in progress, and the relevant sections of code (shortened for brevity, t1 is the top left piece on the pallet, others just repeat the same code):[URL]
[Code]....
View 3 Replies
Mar 18, 2010
I've used the GUI to create a rectangle that I turned into a button symbol (SimpleButton). I then edited the button so that it had 4 different button states and a text layer on top. I then created a class definition file for this object so that I could dynamically change the label text (the text layer) when adding instances of this button to the stage.
I was able to create and link a class file (DynamicButton.as) just fine, but when I try to access the text field that I created on the button, I get the error:
"Access of possibly undefined property btnLabel through a reference with static type com.examples:DynamicButton."
when i couldn't get that to work, I decided I'd try adding the TextField directly within the class definition file, using the following code:
package com.examples
{
import flash.display.Sprite;
import flash.display.SimpleButton;
[Code].....
The problem is that I can't seem to add the TextField to the SimpleButton, as it's not a display object. So, I tried adding it to the parent of the simple button (and I figured, I'd just place it exactly above the button). But then I get a "null object reference." error.
is there a way to access GUI-created elements from w/i a class definition file? How would I add the TextField to the button using only AS3 inside of a my class definition file?
View 1 Replies
Jan 7, 2011
I need to export the gradient settings of a rectangle created with the Flash editor. Our artist creates a rectangle with the gradient in a .fla. Is it possible to retrieve the gradient parameters from the .swf or from a flash plugin I could write?
View 3 Replies
Sep 23, 2010
I am having problems while creating object with actionscript, I am new to it and I am getting some errors. I am creating my object this way
Code:
var myMC:MovieClip = new MovieClip();
myMC.x = 50;
myMC.y = 50;
myMC.name = "hunterToken";
tCursos.addChild(myMC);
And it is created, so far everything's good
Later I try to access the visible property, and I get an error
Code:
tCursos.hunterToken.visible=false;
And I get this error:
Code:
TypeError: Error #1010: A term is undefined and has no properties.
at newSiteHTR_fla::mCursos1_1/go()[newSiteHTR_fla.mCursos1_1::frame1:157]
View 3 Replies
Jan 29, 2008
the variables listHeight and maskHeight won't populate. they come up 'undefined'.
here's the code essence:
Code:
xml.onLoad = function(success:Boolean)
{
var stuff:Array = xml.firstChild.childNodes;
if (success)
[Code]....
View 4 Replies