ActionScript 3.0 :: Referring To Functions On The Stage From A Movieclip?
Mar 2, 2010
I just started "coding" in AS3. By "coding", I actually mean trying around with features and generally trying to grasp the vast amount stuff you can do with this software of. I have some coding experience, however the way Flash likes to hide code snippets all over my project does tend to confuse me. Not knowing where I tried putting the code and/or rewrote some other stuff keeps me sorta busy.
Anyway, my issue is this:
Messing around with movieclips inside movieclips, I've keep encountering the error "1120: Access of undefined property onTimerComplete." I do realize that this error generally is caused by not having defined an instance correctly or not having it defined at all - an error beginners tend to make. Nonetheless, I'm not trying to refer to an instance/symbol, I am trying to call a function defined on the stage from within a movieclip that also is placed on the stage.
I've been reading huge amounts of text/articles and how-to 's, but they all seem to only touch the subject lightly or simply going in head-first - becoming far too complicated for me (a beginner) to grasp.
So, trying to sum my questions up into something that looks like a tl;dr:
- What's up with levels, "_root" and referring to functions like in the older versions of flash?
Flash tells me to use some display-package instead of _root, when I use that... (I do realize the article is from Flash 5.0)
- How do you refer to a function defined on the stage, from inside a movieclip? (The function is a timer, that is supposed to make the mother-movieclip continue to the next child-movieclip.)
View 7 Replies
Similar Posts:
Jan 21, 2010
've been trying to figure out how to refer to the stage from a Sprite before it is added to the stage.
I'm working on a small program in which I plan to use external classes for each "window" that comes up. I've made the window classes extensions of Sprite. I'd like to make this window add itself to the stage when its constructor is called, and then just remove it from the window class when I'm finished with it. Is this a good idea? I'll post some of my code to show you what I mean.
This code doesn't work. I get the error "type was not found or was not a compile-time constant: Stage"
From my window class:
ActionScript Code:
public class PlayerSelectionWindow extends Sprite{
var stg:Stage;
[Code]....
View 2 Replies
Jan 14, 2009
I have a movieclip on the stage in which I have some 90 movieclips also on the stage.
I created an array to hold the movieclips. But when I try to add eventlisteners to these movieclips by cycling through the array, I get a 1009 error ("Could not parse the XML. Error #1009: Cannot access a property or method of a null object reference.") Oddly, however, the application seems to work correctly, handling my listener events.
On the other hand, if I add eventlisteners for each movieclip individually, all works fine--no errors are thrown.
View 4 Replies
Jun 8, 2009
I have a simple question regarding the objects that are on stage. If you make a symbol in the Flash editor, export it for actionscript and put it on the stage, how can you refer to it in an external .as file which contains the document class? I tried using getChildAt() but that returns a displayobject, and I want to modify properties of that instance of the class of that symbol.
I need this because I am trying to make a scrollpane that adapts it's size to the screen resolution, and it's source is a MovieClip that isn't on stage but in the library. I also want the source to adapt it's width and height to the screen resolution. Is this possible? For this to work I need to refer to that source MovieClip in my as3 file, and I can't figure out how to do that...(in this situation it isn't even on stage but I guess I could make it invisible and put it on the stage if nessecary)
View 1 Replies
Mar 17, 2009
I am building a simple ToolTip-Class. In case the cursor gets to close to the stage's border's I'd like it to flip accordingly, so it won't get cropped.
For this I'd like to compare the stage width and my mouseX and then scale and wove things accordingly.
However when I try to get stage.stageWidth from inside my package it will return null.
View 4 Replies
Nov 23, 2009
i need to refere to a whole bunch of mc named a1, a2, a3, a4, a5 and var who:MovieClip="a"+3 dosnt work...
ActionScript Code:
import gs.TweenLite;
stop()[code].............
View 1 Replies
Feb 7, 2006
Code:
var l = 2;
duplicateMovieClip(button, "button"+l, this.getNextHighestDepth());
[code].....
View 4 Replies
Mar 4, 2010
I have an object that I add movieclips into when a user does something.
I'm trying to loop through the items in this object later and perform something when object.objectName = something, however I'm finding it hard to get the right code to use in place of the something.
code within a function that adds movieclip to object:
Code:
if (thisHImage==1) {
healthArray[healthIndex] = new mcCake();
}
[Code]...
when i trace(healthO.objectName) i get [object mcCake], but it won't enter the if statement,
View 2 Replies
Jul 8, 2009
I have a button located in a movieclip which I want in its overstate to gotoAndStop a particular labeled frame located in a different movieclip. How do I go to a frame of "movieclip A" by interacting with an element of "movieclip B"? Must I sever the relationship between the button and the movieclip its in which I wouldn't want to do...?
View 3 Replies
Sep 1, 2009
I've got what I think isn't a real tough one however I can't seem to get this working.
I have a MovieClip. This movie clip has 21 buttons. These 21 buttons should be forwarding the user to frames 60-81 on the maintime line.
The actionscript I've added is not providing any errors however it's working either as these buttons don't do anything unfortuanlty.
Below is a sample of the code i've placed within the MovieClip itself, as the buttons and the button names are contained in the movieClip.
AS3 Code Being Used
button1_btn.addEventListener(MouseEvent.CLICK, button1Click);function button1Click(e:MouseEvent):void{ gotoAndStop(55)}
This code is listed for each button instance and to forward the user to a frame on the main timeline (NOT the timeline in the MovieClip itself).
Again, this code is contained in the MovieClip itself and not on the main timeline, as the buttons exist in the movieClip I.E. button1_btn to button21_btn
Lastly, to provide a visual idea of what i'm expereincing, please refer to screenshot embeeded in this message or the attachment (same thing).
View 4 Replies
May 1, 2011
I am writing a program where I have used multiple movieclips (boxes) that are put into a grid using a nested for loop.
Each movieclip is in an array and I want to give them names (box1, box2, e.t.c) but when I try to trace() them i get this in the output: "[object gridBox]".
[Code]...
View 4 Replies
Apr 12, 2011
I have a nested movieclip, which I shall refer to as Menu.a.b This is passed to a MouseEvent function using e.currentTarget
I now need to run a command (indexOf) on Menu.a, however only have Menu.a.b saved. How can I refer to Menu.a as a function of Menu.a.b
I've tried Menu.a.b.parent, and that hasn't seemed to work, nor has a few other attempts involving the MC function.
View 2 Replies
Dec 29, 2002
I've got 12 MovieClips, which all have specific functions in the movie. Those MC's will appear and dissappear after a few seconds. But what I want is, that those MC's have to appear at random .If all 12 MC's have appeared, the appearance has to be stopped. So for example MovieClip number 4 has to appear just once. So 12 MC's will appear, but everytime when the movie starts, the appearance has an other sequence.What is written above I want to place in an other MC. So there is one MC which 'load' 12 MC's within it
View 2 Replies
Aug 10, 2011
I have:Stage -> SWF Loader Root -> SWF Loader -> MovieClip -> Nested MC.From within "Nested MC": I can only access "SWF loaders root" time line, I can't seem to get access to the stage's functions..[code]Im trying to call on a function which resides on the main time line.Is there any way to access the main timeline?
View 1 Replies
Apr 16, 2010
I have a .as file with a load of functions that i include using : include "myFunctions.as".They can be accessed alright.I have a custom class that extends movieclip, and i want to use a function inside that class that is located in my "myFunctions.as" file.How do i do that? Seems like the class loads before the myFunctions.as file so the functions are unavailable at this time. I get that error message :
View 7 Replies
Jan 22, 2011
There are two files in my actionscript project named "TestAPP", TestAPP.as and Draggable.as
TestAPP.as:
package {
import flash.display.Sprite;
import flash.display.Stage;[code].....
In "my actionscript theory", I'm supposed to see a circle that follows the mouse when I click it. (The draggable is not fully implemented) But the circle doesn't even budge .how to access the main class's stage property. I've googled for it, but still no progress.
View 4 Replies
Apr 19, 2004
I have declared two functions to work for one movieclip. The first one start on EnterFrame. The second one should start onRollOver and should pause or end the first one. What is the right notation to do that ?
View 5 Replies
Jul 11, 2011
How do you make a movieclip move horizontally from the start of the stage to 3/4 of the stage. Stage size is 700 px by 600 px i want just one row in the middle of the stage. i want that movieclip to disappear right after it reach the end of the 3/4 mark.
View 1 Replies
Feb 27, 2006
i saw a thread while ago .. that always position a movieclip in the middle of the stage even if the stage or window resize any1 can point me to it
View 3 Replies
Jul 10, 2011
How can I give this a dynamic name. I know this is simple but going from as2 to as3.
function Love(mc:MovieClip):void
{
var loadit = new Loader();
loadit.load(new URLRequest(mc));
addChild(loadit);
}
How do I change the "one" and "mc" to work?
View 2 Replies
Aug 18, 2009
I can't access a variable on a the stage from within a movieclip thats placed on the stage.
View 4 Replies
Sep 10, 2008
Even though i know not much of actionscripting, i like to make sites that are flash-based, so i keep on challanging myself with that. But now i stumbled into something, and i just cant find a solition! here is my problem: I have made dropdownmenu's in a movieclip and the mc works with hittest like this:
[Code]...
View 1 Replies
Aug 9, 2009
I'm almost 100% sure that I have to write an if, else statement for this. Below is the code I have for a button(movieclip) I created. It is suppose to play an animation when you click on it. Then when you click it again it's suppose to play a second animation that will take it back to the original state. What is happening is, it goes straight to the clicked state without playing the animation. However when you click the second time it plays the animation that takes you back to the original state. Am I correct in believing the only way to get the animation to play on both clicks is to use an if, else statement.
function clickPlus(event:MouseEvent):void {btn1.gotoAndPlay("clickOpen"); }btn1.addEventListener(MouseEvent.CLICK, clickPlus);
function clickX(event:MouseEvent):void {btn1.gotoAndPlay("clickClose"); }btn1.addEventListener(MouseEvent.CLICK, clickX);
btn1.removeEventListener(MouseEvent.CLICK, clickPlus);
View 3 Replies
Aug 16, 2010
This has served me well, but I've been designing a new sight and wanted to get more into Action Script to control functions to help improve both my programming and keep my file size down.
So I decided to create an instance of a block (rectangle shape as another movieclip) and have multiple layers. One which controls the actions of two other blocks. The upper most block would not be visable until I ran the cursor over it (increase its Alpha property from 0 to 100 one step at a time in a loop). This would reverse when the cursor ran off (reduce Alpha property from 100 [or less] back to 0 in a loop).
I've read and re-read every flash book I own on the subject and cannot understand why I can't control another instance of a different movieclip.
View 1 Replies
Jun 2, 2006
My question is that I have attached a movie clip using loadMovie() function.Now how do I perform functions on that movieClip such as gotoAndStop().In the sense how do I tell the movieclip to goto a frame?
View 2 Replies
Aug 1, 2006
I have built a movie which has some nested movies within. I have created a class called ButtonMc in a .as file and used linkage to connect the symbol in the .FLA file with the class code in the ButtonMc.as file . This is the code for ButtonMc class:
Code:
class ButtonMc extends MovieClip
{
[code]....
View 5 Replies
Jul 5, 2004
I made a movieclip with 5 frames inside. Well, outside, when i push a button stop, runs the code: this.movieclip_name.stop(); , but, doesn't stop.Inside these frames there is a enterframe function that call drawing api functions.
View 1 Replies
Oct 16, 2011
what I'm trying to do is accessingsnapText = scrollPane.source.textSnapshot;from an external swf. I've tried:
trace("-->: "+scrollPane.source.textSnapshot.getText(0, 1000));
trace("-->: "+myLoader.content.textSnapshot.getText(0, 1000));
trace("-->: "+mc.textSnapshot.getText(0, 1000));
[code].....
View 3 Replies
May 4, 2011
I have the scenario below. I have a movieclip on the stage (root). Inside this movieclip I have a frame with the action below:
_root.MCHappy.visible = false;
_root.MCSad.visible = false;
_root.MCNormal.visible = true;
I cant get this working with AS3. How is the correct way to do that inside a MovieClip with AS3?
View 6 Replies
Jan 18, 2009
I am making a site and have a component on the stage that is put there dynamicly through AS 2.0. When I F5 or Ctrl F5 it seems that the actionscript is read allover again?Only the script that is situated in the specific label. What if I have script in that label that creates a news reader. I f12 and the news reader is there I jump to another label with the menu. when i jump back to the home label the news reader does not appear on the stage. after a f5 or ctrl f5 it does.Do I have to attach the movieClip in each label to assure a the dynm-movieClip script is on stage for the ctrl f5 issue?
View 0 Replies