Flex :: Get The Reference To A Newly Created Button With Actionscript?
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
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
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
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
May 5, 2010
I am loading some external images, that bit is sorted. What I cant seem to figure out is how to reference the newly loaded image.
Here is the snippet of code I have
ActionScript Code:
public function loadImg(img:String):void {
loader.load(new URLRequest(img));
myHolder.addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
} private function loaded(event:Event):void {
//How do I reference the new image here so I can do stuff to it? }
I know how to do it in AS2 but cant seem to get at it here. Is it passed through the event?
View 5 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
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
Jun 19, 2010
I created a Button in MXMXL. On button click, I create a Menu as a child of the Button. I am using an XML datasource. The reason for creating it this way, was due to the amount of custom skinning involved. A popupmenubutton was not an option. Anyway, so my question is this: when clicking the button, the menu is displayed. However, if you click the button again, the menu reopens. I want the menu to close if the user clicks the button a second time. Now, I got it to work by setting a var after opening the menu, and then I check that var on each click to make sure that the menu isn't already open. If true, then it will close the menu, instead of reopening it. This works, until the user clicks away, in which the HIDE event gets dispatched and the menu closes. My hack no longer works.
View 1 Replies
Jan 20, 2010
[code]My code will:
- loop through the Grid array and place each tile on the stage
- assign RedBall a random Grid coordinate and places it on the stage at that coordinate
I want to be able to click RedBall, which will create a border around the tile beneath RedBall, and create borders around the tiles above, below, to the left and to the right. BUT, I don't want to reference the tiles by their distance in pixels from RedBall or from each other; I want to reference the tiles by their coordinates in the Grid array. So I want to:
- get the coordinates of RedBall
- use those same coodinates to reference the tile at the same coordinates in the Grid array
- use the tile's coordinates to reference the tiles above/below/left/right
- apply a border to all these tiles
What's the best way to reference an instance of a tile? Should I apply a name to each instance as it's created in the loop? like myTile.name = "tile"+i+"_"+j; ? If so, how do you reference that instance later? Just tile1_3 ? Do you have to prepend it with root, or stage, or the class it was originally created in? Do you have to use getChildByName? OR, can you still reference it later without having given it a name?
View 1 Replies
Jul 8, 2010
I have:
Code:
// a class
package
{
[Code].....
how to get the instance of AA that created this mc the_class.big_function( ) ;
View 9 Replies
Nov 2, 2010
I've got some buttons that have toggle set to true. I'm trying to re-set the button's state to unselected. But, I can't access the button directly like:
button.selected=false.
I'm accessing the HBox's children which are the buttons. UIComonent doesn't have a selected property.
So, how do I de-select the toggle in this bit of code below?
for (var j : int=0; j < theHBox.numChildren; j++){
var child : DisplayObject = theHBox.getChildAt(j);
var myButton:UIComponent = child as UIComponent;
myButton.setStyle("borderColor", "blue");
myButton.visible = true;
}
View 1 Replies
Jan 20, 2010
My code will:
- loop through the Grid array and place each tile on the stage
- assign RedBall a random Grid coordinate and places it on the stage at that coordinate
I want to be able to click RedBall, which will create a border around the tile beneath RedBall, and create borders around the tiles above, below, to the left and to the right. BUT, I don't want to reference the tiles by their distance in pixels from RedBall or from each other; I want to reference the tiles by their coordinates in the Grid array.So I want to:
- get the coordinates of RedBall
- use those same coodinates to reference the tile at the same coordinates in the Grid array
- use the tile's coordinates to reference the tiles above/below/left/right
- apply a border to all these tiles
What's the best way to reference an instance of a tile? Should I apply a name to each instance as it's created in the loop? like myTile.name = "tile"+i+"_"+j; ? If so, how do you reference that instance later? Just tile1_3 ? Do you have to prepend it with root, or stage, or the class it was originally created in? Do you have to use getChildByName? OR, can you still reference it later without having given it a name?
View 3 Replies
Apr 11, 2012
I need to remove the word Button from the reference to reference the actual item that will be tinted.
[Code]...
View 1 Replies
Mar 25, 2010
I've created an button object in flash. The button contains 2 layers. One is the background image and on top of it is a textField. The textfield is dynamic. I use the button inside a movieclip and I export it in a SWC. The I'm trying to use it in flex.
I'm trying to do this:
var myComponent:MyComponent = new MyComponent();
myComponent.button01.theTextField.text = "Caption";
I get and instance of the button(myComponent.button01 is not null in Flex debugger), but the instance of the textField(myComponent.button01.theTextField) is null and I'm not able to change the text(but the default text appears onscreen). The code is compiled correctly in flex.
I exported the in swc the button control as well. So the button is not the default SimpleButton from Flash, but an derived class generated by flash(with the same name as the symbol defined in flash). It contains theTextField memeber, which is null.
Here is the button timeline(Layer 2 contains the textfield, and the textfield instance is named theTextField):
View 5 Replies
Mar 2, 2012
I have some movie clips in the library of a FLash file, which has a document class. The movie clips in the library are set up (via Linkage) to have a BaseClass. The document class creates containers for the movie clips, which are created by a timer. The base class has a click event that removes the movie clips. My problem is, how to reference the container that's created in the document class, when i want to do so from within the base class.
View 9 Replies
Aug 21, 2011
I have this main (document class) in a Flash project:
package {
import flash.display.MovieClip;
import flash.events.Event;
[Code]....
Now: if I pass a reference (ref) of the main class to Other and I add clippo as you can see in the first case, I can reference the movieclip clippo from the main (getChildAt(0) is "clippo" from the main). But, is there any way to use the second method (no ref) and do the same from the main class? I can see clippo onstage when Other creates it but I can't understand where clippo "lives" into the DisplayList.
View 2 Replies
May 6, 2010
package uk.co.bigroom.utils
{
import flash.utils.Dictionary;
/**
* Class to create a weak reference to an object. A weak reference
[code]....
In this Class, how they denote one as Weak Reference and one as Strong reference.
View 1 Replies
May 29, 2008
i have a set of buttons cranked out from and XML file. how can i emulate, in code, a press on one of those buttons? i'd like to 'press' one of them for an initial state so that the list it controls will load first off instead of waiting for the person to click it manually and THEN show the list it's connected to. thing is, the first loaded list is going to be random, so i need to 'press' what on another day/load would be a button that the user would press themselves.
in other words, i have 3 buttons. on random, i have to 'press', say button 2, to start. users can press 1 or 3 and then 2 again if they like. another time, it's button 1 that gets 'pressed' on load, etc. make sense? i have a sneaking suspicion it might be easy... or stupidly convoluted.
View 5 Replies
Aug 3, 2009
I am building a Gallery/Case Study application and I am running everything off of XML, and I need to be able to add images/text to the application whenever, without causing any problems. On the sideshow portion of the application, I am putting dynamically generated textfields under the picture viewer, with the number of the current image, highlighted. Similar to the one here:[URL] the first slide haha this was one of the best examples I could find. Anyway I've created the textfields, that display the correct numbers (that is, from "01" until say "07" depending on the .length(); of the XML tag <image>), but that is all they do so far. I am setting the type in the textfields by doing this
Code:
_tf.text = "0" + myIndex as String
myIndex is a varibale incrementing as long as var i:Number is less than the length property of the XMLList I'm using to store the image URL's. I am adding the _tf var to the stage using addChild(); and multiplying i by like 20 or something to make the x values different for every _tf. My problem is that if i try to reference the myIndex value when the textfield is clicked, it says the value of myIndex is 7, which is what it was set to when the last iteration of the loop executed. Basically I need to be able to store a value somewhere, that is unique to each textfield so I can load the corresponding image from my XMLList. I've tried messing around with the .name property of MovieClips, but I'm not exactly sure how it works. I use it earlier in the code with my Loader instance, but I don't know how to use it with MovieClips.
View 2 Replies
Sep 15, 2006
I am extracting some filenames thru php in my flash movie. this is a pt of the code: ...
$envelope.sendAndLoad("login.php", $envelope_received);
...
file_name = $envelope_received.filename;
[code].....
View 4 Replies
May 22, 2010
One last thing to do to finish a project and it turns out to be difficult and I can't figure out why. I'm loading in a jpg and when it loads I want to fade it in with a tween effect using tweener. The problem is that it's showing up on the screen as soon as it loads.[code]...
View 1 Replies
Mar 18, 2011
I'm maintaining a Flash site for a client, and I received all the fla files from the original programmer. Now it's time for me to make some changes, and I'm finding that when I generate a new swf from one of the files, it doesn't behave the way the currently live file behaves.
The main file is titled flashindex.swf. On load, it loads home.swf. home.swf contains an image that slides out and a video player that fades up.
It works fine on the current live site - lisahaisha-dot-com (not enough posts to post links)
But if I use the fla file the developer provided and generate a new swf, the video player fades up, but the image doesn't slide out.[url]...
There are a few other external files that get pulled in (an .as file, and another .swf), and I've made sure that they're all in the right place. I get no compiler or output errors when I publish. I have combed the code, and can't figure out why her picture doesn't slide out. It seems there's something going on in the actionscript in flashindex.fla that is telling home.swf to behave differently. [code]...
View 9 Replies
Jun 9, 2004
I want to add a "progress meter" whenever the user goes to the next question (whether the question was answered correctly or not). I want to attach movieclips along the bottom line, and I want the user to be able to specify some color and shape preferences for these "progress meter" elements. I'm bilingual, so I included my original, french comments (pour tous ceux qui sont francophones).
English:
Code:
function ajouterBalle(couleur, etat) {
var posX = (quelleQuestion*(640/ballesTotales))-(640/(ballesTotales*2));
this.attachMovie("mc_balle", "balle"+quelleQuestion, quelleQuestion);
this["balle"+quelleQuestion]._x = posX;
[code]....
mc_balle is actually just a movie clip with 3 keyframes, with shapes made of a fill (and no border).
I call upon the ajouterBalle function this way, which is supposed to create a "balle" or "progress meter node" using the right shape and color:
Code:
ajouterBalle(0xFF0000, 2);
The balls position themselves in the exactly right fashion and shape...but the color doesn't apply! So I'm wondering where is the problem. Perhaps with the dynamically created color contructors? Or the line just after, when I set the color?I am able to change the color of a background movieclip (read: non-attached) with no problem, but the dynamically created ones don't work...
View 3 Replies
Nov 15, 2009
I have a movie in witch i duplicate a MC several times.
Example:
MC1 (template mc)
Duplicated to:
Movieclip1
Movieclip2
Movieclip3
I want to attach different action script codes to each of the newly duplicated movieclips. Each Movieclip should have different on(release) scripts.
View 1 Replies
Nov 21, 2010
Does anyone know how to assign an external class to a newly added child to the stage.
What I'm doing is using a button to pull in a Movie Clip from the library.[code]...
View 5 Replies
Sep 16, 2010
When I deploy a new .swf file in an HTML file as shown below, I have to clear the browser cache before the new .swf file loads in the browser. Is there anyway to force the browser to load the .swf file when I replace it with a new one on the server.
<embed type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.adobe.com/go/getflashplayer" allowscriptaccess="sameDomain" name="Prototype" bgcolor="#869ca7" quality="high" id="Prototype" src="/flex/Prototype.swf">
View 3 Replies