Actionscript 3 :: Use A Stage Instance Rather Than Calling 'stage'?
Oct 6, 2011
I would like to know if there is a reason that, within an AS3 class, I would want to do something like this:
var myStageInstance:Stage;
//within an arbitrary class
var myStageInstance:Stage = stage;
myStageInstance.addEventListener(MouseEvent, someFunction);
as opposed to something that I would normally do:
//within an arbitrary class
stage.addEventListener(MouseEvent, someFunction);
There is no particular problem that I am looking to solve right now. I would just like to know if there is a reason to use one method over the other.
View 3 Replies
Similar Posts:
Oct 5, 2011
In as3 What is the difference between calling stage.width and stage.stageWidth I read somewhere that if we have nothing on stage then the value of stage.width is 0,but what happen when I have nothing on stage but loading contents dynamically on stage?I have tried this and when i have loaded content dynamically on stage then i have got
stage.width=value; // where value is dynamic number
View 4 Replies
Feb 10, 2010
I was wondering if it was possible to call a pointer to the stage to replace the original pointer. I know the action script to replace the original pointer and to hide it but I need to know if it can be called so that I dont have to put one of the pointer on every frame I want the pointer to be replaced. Flash 8
View 3 Replies
Apr 15, 2012
I'm new with strings and arrays. I want script to calling display objects to the stage and the timer to move images up and down to appear like a scrolling numbers. I start getting sloppy, and mess up passing to Tweener.
- An explanation or strategy may be enough, "I've got pretty close on this one"
- There was confusion regarding the Containers and addChildren...looked like arrays
The code "get as far as error with NumbersView and numbers undefined etc".
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.utils.Dictionary;
import flash.events.Event;
import caurina.transitions.Tweener;
[Code] .....
The methods were proved separately. "I got a earlier version of the document going, but I need to work through this to understand it."
Symbol Properties
Class ImageView
Tweener
The "caurina" folder needs to be present
Rolling Numbers "Success loading numbers and connecting to counter".
Placed the movie clip object on stage with two dynamic text fields in it. Make sure the container is placed on stage, has the two text fields in it, and everything is given a proper instance name. Also include the caurina folder.
Seconds MovieClip symbol with instance name of seconds
firstDigit Dynamic text field with instance name of firstDigit, placed in seconds
secondDigit Dynamic text field with instance name of secondDigit, placed in seconds
Symbol
Un-tick 'Export for ActionScript'
Use 'Name, Class, and Instance' correctly
View 1 Replies
Dec 14, 2009
Hypothetically, I have a movieclip menu that's created using a class menu.as at runtime. When I instantiate that class on the stage of the main swf, how would I go about telling that stage what to do on a specific click? For instance, if I click button1 on the menu, how do I tell the stage to turn random_object's alpha down to 0?
Important note - buttons in the menu class are loaded dynamically, and there is no way (that I know of) of binding them specifically to event listeners on the main swf stage as in "menu.button1.addEventListener(...)". To summarize my question - how do I control the main stage from within a movieclip, without assigning eventListeners on that main stage?
I have managed to make it work using this method: Inside the class, I add an event listener to each button. On CLICK, the button calls e.currentTarget.root.desiredFunction() where desiredFunction is the function on the main swf stage I want to run. Is there a more efficient or clean way of doing this that anyone knows of?
View 6 Replies
Feb 7, 2010
When i call stage.addEventListener from Document Class (i.e. the entry class to the program) it works. But now i have changed the structure to something like: Document Class pulls PlayScreen (which is of type movie clip). In this PlayScreen, i call stage.addEventListener, but it gives me error saying: Cannot access a property or method of a null object reference. so how do i go about it. basically, i want to add a stage event listener for keyboard event.
View 4 Replies
Jul 1, 2006
I've just downloaded Flash 9 Public Alpha and I'm trying some new stuff. I would like to change the scale of a MovieClip instance that I've physically created and dragged onto Stage but the compiler doesn't recognize the mc instance...Do I need to do something beyond just referencing the clip? : myMovieClip._yscale = 10;
I have a haunting feeling that AS3 will be too intimidating for me to even begin to try learning, I can't really grasp AS2 yet...
View 4 Replies
Jul 7, 2011
It works perfectly in Flash Player 9 but not in FP10. I am calling 5 buttons onto the stage via linkage. These buttons are a movieClip with two frames inside - with different grafics on each frame. I want to use an array to make button 2 and 4 show the second frame in the movieClip. How can I do this! I guess I have to use FP10 since this is a small part of an AIR application. Create a movieClip with to frames, linkagename: radioButton, and why it doesn't work in FP10...
ActionScript Code:
import flash.display.Sprite;
var myArray:Array = new Array;
var box:Sprite = new Sprite;
var count:int = 5;
myArray = ["button1", "button3"];
stage.addChild(box);
[Code] .....
View 4 Replies
Jul 9, 2011
I having trouble nesting classes then calling them on the main stage.I have one AS file that contains all the functionality to create a simple button with a text field that can be customized from the FLA file. I want to use this AS file to create another AS file for a form.I have called the simple button from the AS file into my other AS using import RoundRectButton.
View 2 Replies
Mar 29, 2012
[code]This is called as part of the die() function I've created for an enemy in the small game I'm making.The idea being that when the enemy dies, it attaches a movieclip of an XP orb.And it does this perfectly well.The issue is in the last bit of the code.I'm attempting to call the setType() function within the class that the XP orb is in.However, it isn't setting the type to 100.
View 3 Replies
Aug 4, 2009
how do I call the re-size action at the first frame? It works great once you resize, but isn't called at the beginning. I've tried a few things, but I'm shooting in the dark at this point.
Code:
sizeListener = new Object();
sizeListener.onResize = function() {
if((Stage.width > 1920) || (Stage.height >1200)){
[Code]....
I'll get into AS3.0 once I have time, don't want to rewrite a bunch of sites right now for something so small!
View 5 Replies
Feb 9, 2010
I want to make 5 buttons visible after a logo has animatedI have a function called vis that successfully makes the buttons visible.How do I call this from within the movie clip (instance name 'logo'?)first frame of main timeline code:
stop();
function vis () {
webMC.visible = true;
[code].....
View 1 Replies
Feb 15, 2010
If I have a movieclip loaded with Loader and I want it to call back down to the movie that loaded it how do i do that? Referencing a root object just gets me to the root of the child not to the main stage.
View 1 Replies
Jan 19, 2010
Alright so I'm trying to call the instance named mcPac onto my stage using the addChild line, and everything I have tried personally has failed.
[Code]...
View 6 Replies
May 5, 2010
I am getting a stack overflow error when attempting what I believe is a very simple task. I have a class that extends MovieClip and I attempt to add an instance to the stage. WorkSamples is the main class in my fla.
[Code]...
The Sample object does get added to the stage, although it doesn't honor the x & y position I specify. I'm sure I'm failing to comprehend something simple,
View 8 Replies
May 22, 2011
I am having problems with a flash project I am working on (flash cs5.5, as3).I have a movie clip with some animation in it, and when it reaches a certain point, I want it to call out a function that is on the first key frame on the stage (as in on the main timeline and not in a movie clip...).This is what I have so far in side that movie clip:
Actionscript Code:
stop();addEventListener(Event.ENTER_FRAME, onTween);
but I allways get this error message:
"Symbol 'ContMask', Layer 'Layer 6', Frame 124, Line 21120: Access of undefined property onTween."
All I am trying to make it do is to trigger the function (onTween) in the main timeline from the movie clip (ContMask).
View 2 Replies
Mar 4, 2010
I have an instance of a movie clip that runs and after it runs I want it to call a frame to gotoAndStop back on the main timeline (stage). What is the code for that? When the animation ends, I am simply giving it a stop(); and then I want it to go to the next frame on the main timeline. I think this used to be _root in AS2.
View 1 Replies
Mar 21, 2011
I have a movieclip, that inside it's timeline I have a function that after loading an image into stage, call a function to fullscreen the stage. When I open my swf file alone, it just do fine but when I open it in html file, it doesn't go fullscreen. (It doesn't relate to allowFullscreen or something like that, cause if move my fullscreen command before loader complete , it goes perfect, but if i use in onComplete event , it doesn't do anything when viewing in html.
Inside my movieclip i have this that doesn't work :
Code:
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
function func1(evt:MouseEvent)
[Code] .....
All the things goes right. I used the trace command. The FullScreen command doesn't work on Loader Class , Complete Event when displayed in html file
View 3 Replies
Feb 3, 2009
I have one MC on stage with instance name "box". That MC duplicates by using this script:
Code:
duplicateMovieClip (box, newname="box2", this.getNextHighestDepth());
box2._x = xPoz;
box2._y = yPoz;
So the new MC is now called "box2".
Inside original MC "box", I have one button. After click on that button, I need to know on which MC I clicked. box, or box2. I tried to use:
Code:
trace (this._name);
But, that get me only instance name of the button.
View 4 Replies
May 11, 2010
I was just doing a menu system for a game project, as3 with Flash CS5. The navigation is build on the frame on the main timeline. When I was creating stuffs on the 3rd frame, the btns on the frame can not be called, returning "null", this is weird. With further study, I found that, if I delete a instance on frame 2, the problem on frame 3 will be solved. Then I found that giving the instance on frame 2 a name could also make things normal. What is happening? Why having a unnamed instanced on the previous frame could make the instances on the next frame "null"?
View 2 Replies
Apr 4, 2011
I'm using Flash CS5. I have some instances on my stage declared in the main class and I want to attach some events to them, however at the time of the main class constructor, these are declared as null.
What's the best practice for accessing stage instances? Is there an event listener I could add that will tell me when the stage instance properties have been populated?
Simple example:
public class bleepBloop extends MovieClip {
public var productName:TLFTextField;
public function bleepBloop() {
trace( productName ); // Here it is null
}
}
However, when I access productName later, it's defined.
View 1 Replies
Apr 30, 2011
I created four instance of movieclip on stage and named them t1_mc,t2_mc,t3_mc,t4_mc. Then I made and array and loaded them inside the array
var arr1:Array = new Array( t1_mc, t2_mc, t3_mc, t4_mc );
var names:String;
//function made to add event listener to each object
function addListner():void {
for ( var i:uint = 0; i < arr1.length; i++ )
[Code] .....
View 1 Replies
Feb 9, 2009
How can I refer to an instance on the stage if:
- I added it to the stage using the GUI
- I wrote its implementation in an external AS file
I can't assign it a instance name otherwise I get this error: Code: ReferenceError: Error #1056: Cannot create property myInstance on MyClassName.
View 4 Replies
Apr 13, 2009
From the main timeline, I am doing a menu[code]...
My scroll bar appears but when I trace stage into my ScrollBarClass this one is null trace(stage)
View 1 Replies
Nov 30, 2009
I`m having a silly problem with adding instance of an object to the stage two or more times. For example, this don`t work:
Code:
var temp0:SomeClass = new SomeClass();
this.addChild(temp0);
this.addChild(temp0);
Well, I know that one instance is one instance and two objects of the same class on the stage would be two instances, but still, it is what I need.
View 1 Replies
Feb 19, 2011
addEventListener(MouseEvent.CLICK, clickAction);
function clickAction (e:MouseEvent):void
{[code]....
for every click it will adds a new btn_mc instance on the stage..I wants to add the btn_mc instance to the stage at only once... How can I achieve this?
View 1 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 3, 2011
i'd like to count and get position of instance of the same type in the stage.
i have tried:
var target;
for(var item in _root){
if(_root[item] instanceof MovieClip || _root[item] instanceof TextField){
[Code]....
but it says access to property _root undefined, and instanceof deprecated
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
Sep 10, 2010
OK this has been a process but i have gotten to the point where i am calling a feedback image for the different categories, I just need to clear the foodfeedback and artfeedback children when music is pressed and the same for the others
/*import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
[code]......
View 3 Replies