ActionScript 3.0 :: Accessing Instance Name In Play Button?
Jul 31, 2011
I created a button on the stage and made it a movie clip and called it's instance name "play_btn" then i made a document class "main.as" and a second class "play button.as". How is to access the instance name in the play button.as file like this...
public class login_page extends MovieClip {
public function login_page() {
play_btn.addEventListener(MouseEvent.MOUSE_DOWN, onPlayDown);
} public function onPlayDown(evt:MouseEvent):void {
trace("Test");
}}
And then I want to call the function in the main.as.. but the general problem is that I want to access the instance name "play_btn" in the "playbutton.as" file. I tried to link it to the class but i get this error: 1120: Access of undefined property play_btn.
View 4 Replies
Similar Posts:
Apr 16, 2011
I placed a movie clip instance inside a button, and I want this movie clip to play when the button is released. I'm using this code on the frame containing the button:
function playMovie(event:MouseEvent)
{
this.theButton.theMC.gotoAndPlay(3);
[code].....
View 2 Replies
Jul 30, 2011
i created a button on the stage and made it a movie clip and called it's instance name "play_btn" then i made a document class "main.as" and a second class "play button.as".so what i want to do but can't figure out how is to access the instance name in the play button.as file like this...
public class login_page extends MovieClip {
public function login_page() {
play_btn.addEventListener(MouseEvent.MOUSE_DOWN, onPlayDown);[code]...
and then i want to call the function in the main.as.. but the general problem is that i want to access the instance name "play_btn" in the "playbutton.as" file...
View 3 Replies
Jun 15, 2009
I'm using flash CS4. I am trying to make a piano. It will be the header of a web page when the mouse rolls over a key the appropriate note plays- ideally the key would appear to be pressed as well. I have a jpg of a piano keyboard imported as a graphic. On a new layer I have made a button whos over state has a blank keyframe. I have imported that button to the stage and given the instance a name. I have attached a sound to the over keyframe (middle C).
I have dropped a second instance of the button onto the stage and given it a unique name. When I attach the next sound (D pitch) to the over state it changes the original middle C. How can I get each instance of a button to play a unique sound? I have tried using a new layer for each button but that didnt work. Do I have to make a brand new button for each note? I have reduced my design to include only 16 notes (I originally wanted 32 but I thought that may take too long to download)---
View 7 Replies
Jul 31, 2011
i created a button on the stage and made it a movie clip and called it's instance name "play_btn" then i made a document class "main.as" and a second class "play button.as" what i want to do but can't figure out how is to access the instance name in the play button.as file like this...
[Code]...
View 9 Replies
Sep 27, 2011
What I want to do is have one movieclip that has many frames and turn that into a button and then make different instances of the button and have those instances display a certain frame of the underlying movieclip.
View 17 Replies
May 11, 2010
I have a symbol (of type movie clip) which is exported for action with AS3 as, say clsAux. From an AS file, I extend this class to program some methods to interact with it The movie clip has, inside, an instance of another symbol, and the instance is called objAux2. The problem I have is that, from code, from the class which is extending clsAux, I can't figure out how to access objAux2. I have tried, from clsAux, to make the movie clip gotoAndStop the frame where objAux2 is instantiated (where the keyframe where it is created is) and then access it like this.objAux2 (error), this[objAux2] (error)... is there any way I can access the instance of a symbol from code?
View 1 Replies
Aug 11, 2011
I have a movie clip which animates out and then places an input textfield on the last frame for the user to type in to. The main movie clip is controlled from external ActionScript. Once the last frame hits and the input field shows I want to focus the users cursor with focus(); but I can't figure out how to call to that TextInput from the time line. mytext.focus(); ???
View 3 Replies
Jun 5, 2009
I have a really peculiar problem that relates to the old question of how to best access the instance of the document class from a different class. I usually add a 'this' as parameter when I create an instance of another class inside the document class. Then I save this 'this' in a class property of the type 'Object'. It usually works just fine but lately I have encountered a really bizzarr error.
When my movie first starts I have to load 2 xml-Files. I do that in another class - that calls upon the document class instance when it is finished. I use 4 methods for that, each calling the other, when it is finished.
(like one doing loader.load(urlRequest),
then loader.addEventListener
(Event.Complete, nexthandler) and so on
Now, when I call back to my document class from the last of these 4 methods it works just fine. But when I try skipping the first two methods (since I now need only one xml-File) - my try/catch-statement suddenly complains: TypeError: Error #1010! Like it needed more time to establish the instance of the document class or something similar strange.
View 4 Replies
Dec 19, 2010
I have a main document class with another class instanciated (mouse follower.as) within it. I want the mouse follower class to access a stage instance. How is this done?
View 1 Replies
Feb 27, 2012
I have an xml and it has items, you can trace the items in Flash, but how do I call them to allow me to identify that object getting clicked on the stage?
<?xml version="1.0" encoding="UTF-8"?>
<menus>
<menu id="1">
[Code]....
View 4 Replies
Apr 11, 2011
I've added a movie clip dynamically using the following code:
var apie=new cPie()
apie.x=100
apie.y=100
stage.addChild(apie)
I now have a pie on my stage. Yum. Assuming this works like a movie clip placed on the stage by dragging and dropping, I added this in to change an instance in the pie.
[Code]...
View 2 Replies
Aug 13, 2011
i have never actually got the flash-actionscript code execution order.in flash pro i have an instance of a moveiclip on stage in frame one named tree1 and on frame 3 i have on the stage tree3.in the document class i have this code:
stop();
var scaleFactor:Number = tree1.scaleX;
gotoAndStop(3);
tree3.scaleX = scaleFactor;
while this works when testing on the desktop, this app will go mobile at the end.is this the correct way to go or should i register for a frameComplete event before accessing instances on a certain frame
View 1 Replies
Jun 14, 2007
access one instance of a MovieClip on the stage (blue_mc) from within the class file of another MovieClip (red_mc).e.g. One instance of "Blue" on the stage called "blue_mc", and one instance of "Red" on the stage called "red_mc". Both symbols are linked to class files (Blue.as and Red.as).In Red.as, I set up a function to listen for a mouse down event. When this is triggered, I want to move the instance blue_mc. At the moment, though, I can't seem to get a reference to blue_mc.I've looked into the new stage and root properties, but even though blue_mc is on the stage, it cannot be accessed using stage.getChildByName( "blue_mc" ) either.
Code for Red.as:
Code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
[code]....
View 6 Replies
Jul 21, 2010
I have a "MainSWF", that loads and places other SWFs "LoadedSWF". The LoadedSWF has buttons that are supposed to make some layers in the MainSWF visible/invisble. These layers are in a placed navigation bar that is defined as a symbol, was placed on the Main Stage and given the instance name "FlashStageMainNavigation". I have a hard time figuring out how to address the layers in the MainSWF, because it seems I am missing something.
When I use a loop to trace all the child instances on the stage of the MainSWF with:
this.getChildAt(i).name
I get the following info:
instance1 this.name=0
FlashStageMainNavigation this.name=4
When I trace stage.getChildByName(this.name) in MainSWF I get "FSMain", which is the name of my main Class
My assumption was, that I could (from the LoadedSWF) address the Navigationbar in the MainSWF by using something like:
stage.FSMain.FlashStageMainNavigation.visible = false; //or
stage.getChildByName("FSMain").FlashStageMainNavig ation.visible = false; //or
stage.getChildByName("FlashStageMainNavigation").v isible = false;
neither of that worked.
To sum up/rephrase my question: How can I find out, which object instances are placed on the stage and how do I address them from the LoadedSWF?
View 4 Replies
Dec 13, 2009
I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!
inside snow_mc I am trying:
PHP Code:
if(this.hitTestObject(this.parent.bauble_mc)){
}
to which flash says:
1119: Access of possibly undefined property bauble_mc through a reference with static type flash.displayisplayObjectContainer.
View 1 Replies
Nov 15, 2010
I have declared a object in my 1 st frame of application.
ActionScript Code:
var objTest:Test = new Test();
I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error
ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);
1119: Access of possibly undefined property objTest through a reference with static type flash.displayisplayObjectContainer.
How to access a object instantiated at root from a movie clip.
View 1 Replies
Feb 25, 2010
I have declared a object in my 1 st frame of application.
ActionScript Code:
var objTest:Test = new Test();
I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error
ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);
[code].....
View 4 Replies
Jun 22, 2011
I have created some (TextInput, ComboBox, CheckBox) Component instances (created as a public objects) in a Document class and added them to the stage.
Now I have created a custom class for a movieclip in library and instantiated it in the document class (also a public instance).
I need to access the component instances in the custom class. How to do this ?
Also, Is it a good practice to use ENTER_FRAME event frequently ? because if I can't access the above components instances in the custom class then I will be left with no choice but to use ENTER_FRAME event in the document class every time I need to change some value in the components...
View 7 Replies
Jul 21, 2010
I have an s:List with a custom itemRenderer and a dataprovider. What I would like to do is access the generated instances of the item renderer but I have no idea how.
Here is the code for the list:
<s:List id="layersList"
borderVisible="false"
allowMultipleSelection="true"
[Code]....
layersList.renderers[selectedIndex] or layersList.selectedItems[0].renderer. In order to access some of its internal objects. Like in the event I would want to listen events dispatched in the renderer instance from the List's parent.
View 1 Replies
Oct 7, 2009
I'm with a doubt that is crashing my project over here.
Example: I have my class....
Code:
package {
public class SoundPlayer extends CheckVersion{
public static var saveId:Object = {};
public function SoundPlayer($url, $vars):void{
trace(saveId[$url]) // here the class return to me the first call
[Code] .....
If I access SoundPlayer.Init(), I pass my URL and my variables, I got the first access, but for example, when I save this variables on my constructor and want to access again with a different call, the flash output returns like "null", like... SoundPlayer.PlayInit("myId");
take a look bellow
Code:
public static function PlayInit($url :String):SoundPlayer {
trace(SoundPlayer.saveId[$url] as SoundPlayer);
return SoundPlayer.saveId[$url] as SoundPlayer;
}
How I can access this variables in second time?
View 1 Replies
Aug 18, 2010
Currently I have two classes which are "bullet" and "enemy".There are two instances of the enemy class.Code from an ENTER_FRAME event in the Bullet Class:
ActionScript Code:
try
{
for(var k:int=0; k<getEnemys.length; k++)
[code]....
The Enemy Class has a private variable called "hits".What do I have to do in order to reduce the hits of the instance of the enemy that was hit by the bullet?
View 5 Replies
Nov 16, 2010
I have declared a object in my 1 st frame of application.
ActionScript Code:
var objTest:Test = new Test();
I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error
ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);
[code].....
View 3 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 1, 2011
i like to know how to declare a global variable in FMS, so that i can access it from different application instance of a same application.
View 4 Replies
Nov 17, 2010
I have the Dynamic Text field that has an instance name on a mid-timeline frame in Flash CS4. I have a class that inherits from Sprite, and which is always added to the stage on instantiation. How can I get a reference to my Dynamic Text instance from this class?
Example:
My Main class (linked in Flash's publish settings) goes like this:
protected function beginGame(e:MouseEvent){
gotoAndStop(8);
var game:GameContainer = new GameContainer(41,8);
addChild(game);
game.x=36;
game.y=128;
}
Game Container extends MovieClip, and draws some pretty gfx. On Frame 8, in the Flash IDE, there is a Dynamic Text element instance named "scoreText". I want to access this from the GameContainer class. Possible?
View 2 Replies
Jun 23, 2006
I'm building a photogallery base on this tutorial http:[url]....I'm trying to add a play button, so the gallery would play the pictures onRelease of the button at interval of 3s.It's not working. my code is:
playBTN.onPress = function() {
this._alpha = 50;
setInterval(this, "nextImage", 3000, 1);[code]....
View 5 Replies
Mar 23, 2010
I'm trying to access a movieclip so I can see when it play a certain framelabel. The code: if (this.solMC_.currentLabel=="nextScene"){ trace("HELLO"); this.imgIntroCont_.gotoAndPlay("start");} Nothing happens when my movie play (it should at least trace "HELLO"). I've read the parts in Flash CS3 Professional Advanced about currentLabel and currentFrame but it still doesn't solve my problem. I've also checked and made sure that the instance-names for the movieclips are right.
View 1 Replies
Jun 8, 2010
i have a mc in wich timeline i put (manually) a mc called joe_mc. The first one (the container) holds all the code: A timer function slows down joe_mc and when it reaches its last frame its suppossed to play the next frame on the container mc timeline. Here�s the code:
[Code]...
View 5 Replies
Oct 26, 2011
I am creating a game in Flash CS 5.5 and would like to include support for the Sony Xperia Play - which has a built in dPad style controller and fire/start/etc. buttons.how to access those capabilities in AIR for Android? I haven't been able to find any documentation at all on the subject.
View 3 Replies