Referencing Movie On The Stage Error
I have a movie_clip_A and a movie_clip_A on the stage. From a frame in movie_clip_A and using a mouse over event, i'm trying to control movie_clip_B.
I have referenced the movie clip both relative and absolutely: this.parent.movie_clip_B.gotoandPlay(frame); root.movie_clip_B.gotoandPlay(frame);
But I keep getting this error. When I click go to source. It jumps to an unrelated line of code all together.
The error is:
1119: Access of possibly undefined property movie_clip_B through a reference with static type flash.displayisplayObject.
What I am not doing correctly? (By the way, i have double checked my instance names and spelling)
FlashKit > Flash Help > Actionscript 3.0
Posted on: 10-20-2007, 03:33 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Referencing Stage From Class
Hello,
I am trying to make my first as3 class based game and so i was wondering if i could get some help. although the game wont have fancy graphics, i just would like to understand the way it works...currently, i am at a point where im getting :
1067: Implicit coercion of a value of type flash.display:Stage to an unrelated type Stage.
in my main file robot.fla, im using
var robo:robot=new robot(stage);
//var starenemy:enemy1=new enemy1(this.stage);
addChild(robo);
inside that robot.as
....
public class robot extends Sprite {
import flash.display.Stage;
private var _stage:Stage;
....
public function robot(stageRef:Stage):void {
_stage = stageRef;
...
}
amongst other things and i cant reference anything from the stage.
I think im going nuts trying to figure out how to correctly reference things to the stage. so can you take a look and guide me and tell me how i can proceed?
Attached is the zip file
Referencing A MovieClip On Stage Through XML
Hello.
I have a swf with several MovieClip instances on the stage at authoring time. For example, say I have mBuilding that contains mFloor, that in turn contains mAppartment.
I have an xml file that contains data so the swf knows what to do with the MovieClips.
Code:
//xml
<my_data>
<movie_clip1>mBuilding</movie_clip1>
<movie_clip2>mBuilding.mFloor</movie_clip2>
</my_data>
//flash
//xmlMovies is the variable contaning xml data
trace (this[xmlMovies.movie_clip1]); //correct
trace (this[xmlMovies.movie_clip2]); //"... null object or reference..."
I've been trying different things, but I'm still stumped. Can anyone give me some advice?
Thanks in advance.
Problem Referencing The Stage
I'm having a problem that's got me completely baffled. I've got a swf file in which references to the stage give mixed results. When I test the file stand-alone, there are no errors. But when I load it from another swf, I get null object reference runtime errors. I'm referencing the stage at various points in the code, but the null errors occur only at one of those points. When I do
trace(stage)
from the code that lies outside of any function (I'm using free-form code, not a class) I get "null". But when I do the same thing from within a function, I get "[object Stage]". However, if I create a new function and reference stage from within it, I get "null". It seems to me that no matter where you reference the stage within a swf, it should always produce the same results. Am I mistaken?
Referencing Stage From A Child
Hi, I'm making a test game to flesh out my AS3 knowledge. Currently, I have a main class (let's call it gameTitle) that the game runs from. I have several other classes, including GameScreen which is eventually displayed using the addChild method. The third piece of the puzzle are the game controls. This block of code contains a method that requires 'stage' as an argument (it detects keys being held down).
This particular method works fine when it's a part of the main class. I want to move it to the GameScreen class, but I'm having trouble referencing the same 'stage' property from here without getting errors. I've tried parent.stage, but I get the following error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at GameScreen$iinit()
at gameTitle/menuSelection()
I should note that gameScreen is the class where the method is located. And this class is initiated by the menuSelection() method which is located in the gameTitle class.
Referencing A MovieClip On Stage Through XML
Hello.
I have a swf with several MovieClip instances on the stage at authoring time. For example, say I have mBuilding that contains mFloor, that in turn contains mAppartment.
I have an xml file that contains data so the swf knows what to do with the MovieClips.
I've been trying different things, but I'm still stumped. Can anyone give me some advice?
Thanks in advance.
Attach Code
//xml
<my_data>
<movie_clip1>mBuilding</movie_clip1>
<movie_clip2>mBuilding.mFloor</movie_clip2>
</my_data>
//flash
//xmlMovies is the variable contaning xml data
trace (this[xmlMovies.movie_clip1]); //correct
trace (this[xmlMovies.movie_clip2]); //"... null object or reference..."
Referencing The Stage From A Loaded Swf
I am converting my website, which has a liquid interface, to as3 but I am still learning and I have a problem.
I have child.swf that I load dynamically into parent.swf. When I run that I get:
Quote:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Through trial and error I found that the null object is the child.swf trying to reference the stage at several places such as stage.stageWidth. If I comment all of them out it runs error free, but it also doesn't do anything. I have tried replacing the first 'stage' with other things such as 'root.stageWidth' but no dice.
I was also wonder how I can have a button in child.swf unload itself from the parent.swf?
Referencing Objects On Stage
Ok, this is a dumb question but I'm just horribly stuck.
In my script I go toframe 5, and there are several textfields and clips on stage, but I can't reference them from my code. I get an error saying the objects don't exist.
If I move the objects of stage and just move them into place later that works but I'm pretty sure there is a better way to do it.
Any thoughts or links? I've checked around google but I don't know exactly what I should be searching for here.
Referencing To Stage, From MovieClip
Hi i've got little trouble... First files: http://rapidshare.com/files/12813666...there.rar.html
And now. How i can get from starterClass.as file to stage, and move to frame 2?
Referencing A MovieClip On Stage Through XML
Hello.
I have a swf with several MovieClip instances on the stage at authoring time. For example, say I have mBuilding that contains mFloor, that in turn contains mAppartment.
I have an xml file that contains data so the swf knows what to do with the MovieClips.
CODE//xml
<my_data>
<movie_clip1>mBuilding</movie_clip1>
<movie_clip2>mBuilding.mFloor</movie_clip2>
</my_data>
//flash
//xmlMovies is the variable contaning xml data
trace (this[xmlMovies.movie_clip1]); //correct
trace (this[xmlMovies.movie_clip2]); //"... null object or reference..."
Help Referencing Stage Elements
How do I go about referencing an element on the stage such as a Movie Clip from within a custom class that doesn't extend the movie clip itself.
For example if I have the following document class...
Code:
package classes
{
import flash.display.MovieClip;
import classes.XMLLoader;
public class DocumentClass extends MovieClip
{
public function DocumentClass():void
{
var xml:XMLLoader = new XMLLoader();
}
}
}
and this is my XMLLoader class...
Code:
package classes
{
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class XMLLoader
{
var req:URLRequest = new URLRequest("myXML.xml");
var loader:URLLoader = new URLLoader();
public function XMLLoader():void
{
loader.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.addEventListener(Event.COMPLETE, loadComplete);
loader.load(req);
}
private function loadProgress(event:ProgressEvent):void
{
var percent:Number = ( 100 / event.bytesTotal ) * event.bytesLoaded;
}
private function loadComplete(event:Event):void
{
var newLoader:URLLoader = URLLoader(event.target);
}
}
}
If I have a dynamic text box with the instance name xml_txt inside a movie clip with the instance name xml_movie on the stage, how can I access it from within the XMLLoader class?
Referencing Stage Items From Packages
Take this very basic piece of code:
ActionScript Code:
package {
import fl.controls.Button;
import flash.display.*;
import flash.events.MouseEvent;
public class ControlButton extends MovieClip {
public function ControlButton() {
setupButtons();
trace("buttons setup");
}
private function setupButtons():void {
myPauseButt.addEventListener(MouseEvent.CLICK, pauseButtHandler);
}
private function pauseButtHandler():void {
trace("-- pauseButtHandler: pause/play clicked");
}
}
}
it just traps a button click for a button component on stage.
If you instance it in the document class, directly in the fla, it works.
Instead if you instance it in another class, defined in another package, it doesn't find the button:
1120: Access of undefined property myPauseButt.
for the record, this is how I instance ControlButton:
ActionScript Code:
var cb:ControlButton = new ControlButton();
addChild(cb); // tried with and without this, same thing.
MORALE: What should I do to see a button component on stage from some remote class?
Having A Problem Referencing Objects On Stage ?
Hi everybody,
I am having a problem referencing two objects on stage and telling them to swap depths. I have an object called "illustration" on the stage that has two separate layers inside of it. These two layers hold "illustrationText" and "illustrationTextRed". My problem comes when I try to swap the depth of the two child objects (illustrationText, illustrationTextRed).
The code I placed on the timeline:
PHP Code:
illustration.addEventListener(MouseEvent.ROLL_OVER, onIllustrationOver);
illustration.addEventListener(MouseEvent.ROLL_OUT, onIllustrationOut);
function onIllustrationOver(event:MouseEvent):void
{
root.illustration.swapChildren(illustrationText, illustrationTextRed);
}
function onIllustrationOut(event:MouseEvent):void
{
root.illustration.swapChildren(illustrationText, illustrationTextRed);
}
Compiler errors keep getting thrown:
Access of undefined property illustrationText
Access of undefined property illustrationTextRed
Am I going about this the right way?
Thanks for your help!
-Brian
Referencing Stage.stageWidth From A Class
I created a custom class in a .as file. I then linked this custom class with a symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.
I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.
Under this type of linkage, is there a way to reference the stage width from the class?
I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class.
Below is the code for my .fla file and my .as file. In the .as file you'll see the line "x = Math.random() * stage.stageWidth;". This is the line giving me problems. I could hard code it, as I do for the y variable on the next line, but I'd prefer not to in order to keep the code flexible.
I also attached the files in a zip.
Any help would be appreciated.
ActionScript Code:
//.fla code
var i:int;
for(i=0; i < 100; i++){
var myBall:flaBall = new flaBall();
addChild(myBall);
}
//.as code
package {
import flash.display.*;
import flash.events.Event;
public class Ball extends MovieClip{
var dx:Number;
var dy:Number;
public function Ball(){
addEventListener(Event.ENTER_FRAME, onEnterFrame2);
reset();
}
private function reset(){
x = Math.random() * stage.stageWidth;
y = Math.random() * 400;
dx = Math.random() * 20 - 10;
dy = Math.random() * 20 - 10;
}
private function onEnterFrame2(event:Event):void{
move();
checkBounds();
}
private function move(){
x += dx;
y += dy;
}
private function checkBounds(){
if (x > 550 || x < 0){
dx *= -1;
}
if (y > 400 || y < 0){
dy *= -1;
}
}
}
}
Referencing Added Stage Children
I am trying to reference a child I added named "userInfo_mc" with nested inputText named "inputEmail". But I am getting this error when compiling referencing the line inside the userInfoSubmit function :
1120: Access of undefined property userInfo_mc.
Any Ideas? Any help is appreciated
Attach Code
function individualAccount():void
{
var userInfo_mc:UserInfoMC = new UserInfoMC();
addChild(userInfo_mc);
userInfo_mc.emailInput.addEventListener(MouseEvent.MOUSE_OVER, showEmailInfoBubble);
userInfo_mc.emailInput.addEventListener(MouseEvent.MOUSE_OUT, hideInfoBubble);
userInfo_mc.continue_btn.addEventListener(MouseEvent.CLICK, userInfoSubmit);
}
function userInfoSubmit(event:MouseEvent):void
{
if (userInfo_mc.emailInput.text == ""){
trace("Fill this out!");
}
}
Referencing Stage From External Class
I have an external class file that extends the MovieClip class and is linked to a movieClip on the main stage. I need it to be able to access properties of other movieclips on the main stage. How could I do this. Here is what my base movieclip class that I want to access the stage with looks like. Remember, it is linked to a movieclip on the stage, if that matters...
Obviously there is more code in the class, but I removed it for the sake of simplicity.
Attach Code
package{
import flash.display.MovieClip;
import flash.display.DisplayObject;
import Math;
public class Test extends MovieClip{
public function Test(){ //Constructor
}
}
}
Referencing Stage.stageWidth From A Class
I created a custom class in a .as file. I then linked this custom class with an symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.
I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.
Under this type of linkage, is there a way to reference the stage width from the class?
I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class.
Any help would be appreciated.
Referencing Author Time Buttons On The Stage?
I have some buttons on the stage that were manually placed during authoring. They all have their own instance names manually assigned already. I need to code them thru my Document Class. How do I get reference to them?
I know how to do this if I am placing them from the library at runtime, but not this way.
Thanks
Error When Trying To Access Stage
Hello,
I get an exception thrown that says:
TypeError: Error #1009: Cannot access a property or method of a null object reference
I get this exception thrown when I try to add an eventlistener like this:
ActionScript Code:
_mySprite.stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
(_mySprite is already added to the stage when I try to add the eventlistener)
Any ideas?
Stage Error Handling
I've been working on this large project for the last three months and I'd like to introduce some error handling. The application's front end is written entirely in Actionscript 3.0 and there is nothing on the stage in Flash CS3. Basicly I have one class that controls all of the main functions of the application with each section of the application being its own class that is called/created by the top level class. So I'd like to do all my error handling at this level the very top of the application. But for some reason the error handler is not called. I'm listening for IOErrorEvent.IO_ERROR in one instance with useCapture set to true.
ActionScript Code:
stage.addEventListener(IOErrorEvent.IO_ERROR,errorHandler,true);
stage.addEventListener(SecurityErrorEvent.SECURITY_ERROR,errorHandler,true);
stage.addEventListener(AsyncErrorEvent.ASYNC_ERROR,errorHandler,true);
stage.addEventListener(ErrorEvent.ERROR,errorHandler,true);
None of these events ever fire, anyone have any ideas? Oh and below is the method the event listeners are supposed to call, I plan to do something else once I get it to be called.
ActionScript Code:
private function errorHandler(err:*):void {
trace('ERROR');
}
Error 1120, Can't See MC On Stage.
Hello.
Let's say I have an .fla called myLA, and it's document class is called myFLA.as. On the stage I have a movieclip called myMC, it's instance name is also myMC. I have a second actionscript 3 file which I'm using to handle certain things, that (along with the document class myFLA.as) need access to the myMC movieclip.
On the document class it's easy yeah, myMC.etc etc. How do I get access to it from another .as file? I've imported my new as file into the document class, and tried myFLA.myMC etc but no joy.
Does this make sense?
Cheers, A.
[as] Stage.width Error? [mx]
When I use the stage.width and stage.height properties in test movie mode, the values are completely unrelated to the movie props.. why is this?
I've published the movie and check it there and its correct..is there a work around to this problem
Zen
Stage.addChild Using For Loop Gives Me Error?
Hi,
I have 4 movieclips on the stage (mc_1,mc_2,mc_3,mc_4) I want to add them as children to the stage using for loop, I have this code:
for (var i=1; i<5; i++) {
stage.addChild(["mc_"+i]);
}
but it gives me this error:
1067: Implicit coercion of a value of type Array to an unrelated type flash.displayisplayObject.
Anybody can help me.
Thanks a lot.
Error From Stage.addEventListener (I Assume)
Hello,
Nice to finally be wrapping my brain around AS3 and posting in this forum for a change.
I've been developing a site, testing out SWFAddress. I got all of that working, but for some reason, I get the following error when running the SWF in a browser:
Quote:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.keelywatson::Main/onStageResize()
I assume the error relates to:
ActionScript Code:
stage.addEventListener(Event.RESIZE, onStageResize);
Now, when testing this on a PC browser at home (FireFox 3), I was getting this error as well, but once I moved the listener below the other stage code for alignment and scale mode, it stopped throwing this error. Now that I'm on FireFox on a Mac (yuk), it's back.
Does anyone have any ideas as to why this may be happening? Thanks!
Stage.addChild Using For Loop Gives Me Error?
Hi,
I have 4 movieclips on the stage (mc_1,mc_2,mc_3,mc_4) I want to add them as children to the stage using for loop, I have this code:
for (var i=1; i<5; i++) {
stage.addChild(["mc_"+i]);
}
but it gives me this error:
1067: Implicit coercion of a value of type Array to an unrelated type flash.display:DisplayObject.
Anybody can help me.
Thanks a lot.
but it gives me this error:
1067: Implicit coercion of a value of type Array to an unrelated type flash.display:DisplayObject.
Anybody can help me.
Thanks a lot.
Error When Stage.resize On Firefox
Hi, i´m buiding my personal website, and I´m using some actionscript to organize thisngs on stage depending on browser size, everything works well on IE, but on Firefox, eveything in wrong, please can someone look at my code and try to explain me what is the problem.
Code:
function makeBoton(tmp_mc, ancho, largo, p, col, label) {
var tm_mc = tmp_mc.attachMovie("randomTypo", "tempo"+p, p+1000);
tm_mc.label_txt.text = label;
tm_mc.label_txt.autoSize = true;
return tm_mc;
}
var i, buttons = [mc1, mc2, mc3, mc4];
for (i=0; i<buttons.length; i++) {
buttons[i].onMouseUp = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
for (i=0; i<buttons.length; i++) {
buttons[i].gotoAndStop(buttons[i] == this ? "inactive" : "active");
}
}
};
}
function init() {
Stage.scaleMode = "noScale";
Stage.align = "LT";
liste = new Object();
liste.onResize = size;
Stage.addListener(liste);
clips = [];
basex = 0;
menu_mc = createEmptyMovieClip("menu", 1);
_global.label_array = ["ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX"];
for (var i = 0; i<label_array.length; i++) {
var clip = makeBoton(menu_mc, 70, 15, i, "0xCC0000", label_array[i]);
clip.setText(this, label_array[i], "-", 1, 5, 10, 15);
clip.onRollOver = rollOverLink3;
clip.onRollOut = rollOutLink3;
clip.onRelease = pressLink;
clip._x = basex;
clips.push(clip);
basex += clip._width;
}
size();
}
function size() {
basex = 0;
tamanio = Stage.width/label_array.length;
for (var i = 0; i<clips.length; i++) {
clips[i]._x = basex;
basex += tamanio+2;
clips[i]._width = tamanio;
}
//me an holder are mc´s on stage
me._x = 5;
me._y = Stage.height-50;
loadMovie("words.swf", me);
holder._x = 0;
holder._y = Stage.height/2-350;
holder.swapDepths(menu);
}
init();
thsnks in advance
Error When Stage.resize On Firefox
Hi, i´m buiding my personal website, and I´m using some actionscript to organize thisngs on stage depending on browser size, everything works well on IE, but on Firefox, eveything in wrong, please can someone look at my code and try to explain me what is the problem.
Code:
function makeBoton(tmp_mc, ancho, largo, p, col, label) {
var tm_mc = tmp_mc.attachMovie("randomTypo", "tempo"+p, p+1000);
tm_mc.label_txt.text = label;
tm_mc.label_txt.autoSize = true;
return tm_mc;
}
var i, buttons = [mc1, mc2, mc3, mc4];
for (i=0; i<buttons.length; i++) {
buttons[i].onMouseUp = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
for (i=0; i<buttons.length; i++) {
buttons[i].gotoAndStop(buttons[i] == this ? "inactive" : "active");
}
}
};
}
function init() {
Stage.scaleMode = "noScale";
Stage.align = "LT";
liste = new Object();
liste.onResize = size;
Stage.addListener(liste);
clips = [];
basex = 0;
menu_mc = createEmptyMovieClip("menu", 1);
_global.label_array = ["ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX"];
for (var i = 0; i<label_array.length; i++) {
var clip = makeBoton(menu_mc, 70, 15, i, "0xCC0000", label_array[i]);
clip.setText(this, label_array[i], "-", 1, 5, 10, 15);
clip.onRollOver = rollOverLink3;
clip.onRollOut = rollOutLink3;
clip.onRelease = pressLink;
clip._x = basex;
clips.push(clip);
basex += clip._width;
}
size();
}
function size() {
basex = 0;
tamanio = Stage.width/label_array.length;
for (var i = 0; i<clips.length; i++) {
clips[i]._x = basex;
basex += tamanio+2;
clips[i]._width = tamanio;
}
//me an holder are mc´s on stage
me._x = 5;
me._y = Stage.height-50;
loadMovie("words.swf", me);
holder._x = 0;
holder._y = Stage.height/2-350;
holder.swapDepths(menu);
}
init();
thsnks in advance
Removing Child From Stage Error #2025
I'm making the transition from AS2 to AS3 and I thought I had began to start thinking in the new way but now I'm stuck again.
I have a click event listener activated by clicking a movieclip. Everything works well, external swfs are loading, alpha changes working on the other movieclip buttons but as soon as I add a script to remove a child(movieclips from the other movieclip buttons) it gives me this error:
[color="black"][color="black"]
WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at mainmovie_fla::MainTimeline/Missionbtn()
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at mainmovie_fla::MainTimeline/collectionClick()
Here is my script, the 2 buttons in question are Collection button and Mission Button
ActionScript Code:
var i=new Loader();
addChild(i);
i.load(new URLRequest("flashslideshow.swf"));
i.x=15
i.y=170
var imageRequest:URLRequest = new URLRequest("about.swf");
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
var collectionRequest:URLRequest = new URLRequest("collection.swf");
var collectionLoader:Loader = new Loader();
collectionLoader.load(collectionRequest)
//LINKS
var blogLink:URLRequest = new URLRequest("http://www.adobe.com");
var storeLink:URLRequest = new URLRequest("http://www.ehecalt.bigcartel.com");
//
//BLOG BUTTON ************************************
blog_mc.addEventListener(MouseEvent.CLICK, Blogbtn);
function Blogbtn(event:MouseEvent):void
{
navigateToURL(blogLink);
mission_mc.alpha = .4;
store_mc.alpha = .4;
contact_mc.alpha = .4;
blog_mc.alpha = 1;
collection_mc.alpha = .4;
}
//
//STORE BUTTON ********************************
store_mc.addEventListener(MouseEvent.CLICK, Storebtn);
store_mc.addEventListener(MouseEvent.ROLL_OVER, StoreOver);
store_mc.addEventListener(MouseEvent.ROLL_OUT, StoreOut);
function StoreOver(event:MouseEvent):void
{
store_mc.gotoAndPlay(2);
}
function StoreOut(event:MouseEvent):void
{
store_mc.gotoAndPlay(5);
}
function Storebtn(event:MouseEvent):void
{
navigateToURL(storeLink);
mission_mc.alpha = .4;
store_mc.alpha = 1;
contact_mc.alpha = .4;
blog_mc.alpha =.4;
collection_mc.alpha = .4;
}
//
// COLLECTION BUTTON
collection_mc.addEventListener(MouseEvent.CLICK, collectionClick);
function collectionClick(event:MouseEvent):void
{
mission_mc.alpha = .4;
store_mc.alpha = .4;
contact_mc.alpha = .4;
blog_mc.alpha =.4;
collection_mc.alpha = 1;
addChild(collectionLoader);
collectionLoader.x = 15;
collectionLoader.y = 170;
removeChild(i);
}
//
//Contact BUTTON ************************************
contact_mc.addEventListener(MouseEvent.CLICK, Contactbtn);
function Contactbtn(event:MouseEvent):void
{
mission_mc.alpha = .4;
store_mc.alpha = .4;
contact_mc.alpha = 1;
blog_mc.alpha = .4;
collection_mc.alpha = .4;
}
//
//MISSION BUTTON
mission_mc.addEventListener(MouseEvent.CLICK,Missionbtn);
function Missionbtn(event:MouseEvent):void
{
mission_mc.alpha = 1;
store_mc.alpha = .4;
contact_mc.alpha = .4;
blog_mc.alpha = .4;
collection_mc.alpha = .4;
addChild(imageLoader);
imageLoader.x = 15;
imageLoader.y = 170;
removeChild(i);
}
//buttonmode
contact_mc.buttonMode = true;
blog_mc.buttonMode = true;
store_mc.buttonMode = true;
collection_mc.buttonMode = true;
Removing Child From Stage Error #2025
I'm making the transition from AS2 to AS3 and I thought I had began to start thinking in the new way but now I'm stuck again.
I have a click event listener activated by clicking a movieclip. Everything works well, external swfs are loading, alpha changes working on the other movieclip buttons but as soon as I add a script to remove a child(movieclips from the other movieclip buttons) it gives me this error:
[color="black"][color="black"]
WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at mainmovie_fla::MainTimeline/Missionbtn()
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at mainmovie_fla::MainTimeline/collectionClick()
Here is my script, the 2 buttons in question are Collection button and Mission Button
ActionScript Code:
var i=new Loader();
addChild(i);
i.load(new URLRequest("flashslideshow.swf"));
i.x=15
i.y=170
var imageRequest:URLRequest = new URLRequest("about.swf");
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
var collectionRequest:URLRequest = new URLRequest("collection.swf");
var collectionLoader:Loader = new Loader();
collectionLoader.load(collectionRequest)
//LINKS
var blogLink:URLRequest = new URLRequest("http://www.adobe.com");
var storeLink:URLRequest = new URLRequest("http://www.ehecalt.bigcartel.com");
//
//BLOG BUTTON ************************************
blog_mc.addEventListener(MouseEvent.CLICK, Blogbtn);
function Blogbtn(event:MouseEvent):void
{
navigateToURL(blogLink);
mission_mc.alpha = .4;
store_mc.alpha = .4;
contact_mc.alpha = .4;
blog_mc.alpha = 1;
collection_mc.alpha = .4;
}
//
//STORE BUTTON ********************************
store_mc.addEventListener(MouseEvent.CLICK, Storebtn);
store_mc.addEventListener(MouseEvent.ROLL_OVER, StoreOver);
store_mc.addEventListener(MouseEvent.ROLL_OUT, StoreOut);
function StoreOver(event:MouseEvent):void
{
store_mc.gotoAndPlay(2);
}
function StoreOut(event:MouseEvent):void
{
store_mc.gotoAndPlay(5);
}
function Storebtn(event:MouseEvent):void
{
navigateToURL(storeLink);
mission_mc.alpha = .4;
store_mc.alpha = 1;
contact_mc.alpha = .4;
blog_mc.alpha =.4;
collection_mc.alpha = .4;
}
//
// COLLECTION BUTTON
collection_mc.addEventListener(MouseEvent.CLICK, collectionClick);
function collectionClick(event:MouseEvent):void
{
mission_mc.alpha = .4;
store_mc.alpha = .4;
contact_mc.alpha = .4;
blog_mc.alpha =.4;
collection_mc.alpha = 1;
addChild(collectionLoader);
collectionLoader.x = 15;
collectionLoader.y = 170;
removeChild(i);
}
//
//Contact BUTTON ************************************
contact_mc.addEventListener(MouseEvent.CLICK, Contactbtn);
function Contactbtn(event:MouseEvent):void
{
mission_mc.alpha = .4;
store_mc.alpha = .4;
contact_mc.alpha = 1;
blog_mc.alpha = .4;
collection_mc.alpha = .4;
}
//
//MISSION BUTTON
mission_mc.addEventListener(MouseEvent.CLICK,Missionbtn);
function Missionbtn(event:MouseEvent):void
{
mission_mc.alpha = 1;
store_mc.alpha = .4;
contact_mc.alpha = .4;
blog_mc.alpha = .4;
collection_mc.alpha = .4;
addChild(imageLoader);
imageLoader.x = 15;
imageLoader.y = 170;
removeChild(i);
}
//buttonmode
contact_mc.buttonMode = true;
blog_mc.buttonMode = true;
store_mc.buttonMode = true;
collection_mc.buttonMode = true;
If someone could help me get to the bottom of this and help me understand where I went wrong I'd be extremely grateful.
Error#1009 - Null Reference To Stage
Hi,
I'm new to using actionscript 3 and I have been reading on how to handle this error, but I still can't get it to work. I have a main.as file that is loading two other classes. One for handling keyboard events and the other for controlling the context menu. If I take the keyController class and use this as the document class, I get no errors and my keyboard events are handled. If I use another class to instantiate the keyController class, I get the error.
I would greatly appreciate any help!
Thanks,
Wes
Here is the error I'm getting...
ActionScript Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at sdf::KeyController/::keyDownListener()
Here is my Main class which instantiates the KeyController Object
ActionScript Code:
package sdf{
import flash.display.MovieClip;
import flash.display.Stage;
import sdf.*;
public class SDFtaxi extends MovieClip {
private var cMenu;
private var kControl;
public function SDFtaxi() {
trace("SDFtaxi Created");
//cMenu = new ContextMenuZoom();
kControl = new KeyController(stage);
}
}
}
Here is the KeyController class...
ActionScript Code:
package sdf{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.*;
public class KeyController extends MovieClip {
public static const A_Key:int = 65;
public static const B_Key:int = 66;
public static const C_Key:int = 67;
public static const D_Key:int = 68;
public static const E_Key:int = 69;
public static const F_Key:int = 70;
public static const G_Key:int = 71;
public static const H_Key:int = 72;
public static const I_Key:int = 73;
public static const J_Key:int = 74;
public static const K_Key:int = 75;
public static const L_Key:int = 76;
public static const M_Key:int = 77;
public static const N_Key:int = 78;
public static const O_Key:int = 79;
public static const P_Key:int = 80;
private var clipToHighlite:String;
private var stageRef:Stage;
public function KeyController(stageRef:Stage) {
stageRef = stageRef
stageRef.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
stageRef.addEventListener(KeyboardEvent.KEY_UP, keyUPListener);
}
private function keyDownListener(e:KeyboardEvent):void {
clipToHighlite = String.fromCharCode(e.charCode);
getChildByName(clipToHighlite).alpha = 100;
}
private function keyUPListener(e:KeyboardEvent):void {
getChildByName(clipToHighlite).alpha = 0;
}
}
}
Why Does Reference To Stage.width Generate An Error?
Newbie question.
I included the following code that I found on the web to track the size of the stage as it is being resized, and for some reason the compiler generates strange error messages.
The code in question is:
1 Stage.scaleMode = "noScale";
2 var myListener:Object = new Object ();
3 var mytext:String = "foobar";
4 trace (mytext);
5 myListener.onResize = function ()
6 {
7 mytext = "Stage size is now " + Stage.width + " by " + Stage.height;
8 trace (mytext);
9 };
10 Stage.addListener (myListener);
And the compiler messages are:
LINE 1: 1119: Access of possibly undefined property scaleMode through a reference with static type Class.
I see in the documentation that Stage has a property of scalemode, why is the compiler complaining, or is this someting that was in actionscript 2 and now the syntax has changed?
Access Stage In Preloaded Swf -> Error 1009
Hi. I'm trying to preload an external swf, but when I try to access the stage in the external swf, I get a 1009 error.
When I remove the stage.scaleMode, stage.align and stage.stageWidth, it works fine.
The content.swf also works fine when i run it seperately from the preloader.
How can I solve this problem?
Here's my code:
Attach Code
This is my preloader document class:
-----------------------------------------------------
package {
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
public class Preloader extends MovieClip {
public var loader:Loader=new Loader ;
private var req:URLRequest;
public function Preloader() {
req=new URLRequest("content.swf");
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.load(req);
}
private function loadProgress(event:ProgressEvent):void {
var percent:Number=event.bytesLoaded / event.bytesTotal;
var percentr=Math.round(percent * 100);
trace("Loading: " + percentr + "%");
}
private function loadComplete(event:Event):void {
trace("Loading Complete");
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,loadProgress);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadComplete);
addChild(loader);
}
}
}
This is my content document class:
-----------------------------------------------------
package {
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
public class Content extends MovieClip {
public function Content() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
trace(stage.stageWidth);
}
}
}
Edited: 10/21/2008 at 04:37:34 AM by Hylkev
Stage And Keyboard Getting TypeError: Error #1009:
Trying to hook up a keyboard listener to the stage but am getting a runtime error. Spent over an hour trying to figure out what's going on, but from everything I've seen (online and in a reference book) the stage should not be null, but it is.
Code:
package ghg.system
{
import flash.display.*;
import flash.events.Event;
import flash.events.KeyboardEvent;
public class Input extends Sprite
{
public function Input()
{
super();
stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDownListener );
stage.addEventListener( KeyboardEvent.KEY_UP, keyUpListener );
}
private function keyDownListener( e:KeyboardEvent ) :void{}
private function keyUpListener( e:KeyboardEvent ) :void{}
}
}
The specific run-time error is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ghg.system::Input()
at Main()
at russianreactor_fla::MainTimeline/frame1()
Any idea why the stage is null?
Do I have to do some type of initialization on it?
AS3 - Stage.scaleMode - TypeError: Error #1009:
Hi!
I'm trying to prevent my swf movie to scale and align top/left. This is the code that i put on my first frame movie:
PHP Code:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT
Everything works fine. Now i'm trying to make the same but using a class like this:
viewer.as:
PHP Code:
package classes{
import flash.display.Stage;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
public class viewer {
private var mcStage:Stage;
public function viewer():void {
init();
}
public function init():void {
mcStage.stage.scaleMode = StageScaleMode.NO_SCALE;
mcStage.stage.align = StageAlign.TOP_LEFT;
}
}
}
main.fla:
PHP Code:
import classes.viewer;
var mystage:viewer = new viewer();
And i get this error:
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at classes::viewer/init()
at classes::viewer()
at viewer_fla::MainTimeline/frame1()
What's wrong?
I understand that i'm trying to access the stage before it's ready, but i can't understand why the code doesn't work when i put in a class but works when i put direct on the fla's first frame.
I hope somebody can explain me and show me the way to fix it. I was reading all night and i find many examples like this (Action Script 3: Resize SWF on Browser resize) that works by creating an object and passing a movieclip as parameter... but in this step i don't want to relocate the movieclip (this will be my next step ), but now i just want to understand how the stage.scaleMode works inside a class...
as3 is kind of scary, i'm frustrated .
Thanks!
Referencing A Movie Itself
Hi guys,
I am currently trying to build a preloader that will preload my movie. The code for the preloader resides in the class.
Basicly, i need to pass a reference of my movie to my class. I am currently using:
ActionScript Code:
var myloader:mySiteLoader = new mySiteLoader(this);
in my class i have the following relevant code:
ActionScript Code:
private var movieToLoad:*;public function mySiteLoader(movieLoad:*){ movieToLoad = movieLoad; movieToLoad.addEventListener(ProgressEvent.PROGRESS, progressHandler); movieToLoad.addEventListener(Event.COMPLETE, onComplete);}
This however, chucks an TypeError: Error #1010: A term is undefined and has no properties. at me.
Any ideas appreciated
Referencing A Movie Or A .swf...
Hey y'all...haven't psoted ina while. Got a basic (or so I think) question 4 ya....
I'm making a simple site of some things I've done over the past year. I want to show .mpegs and to show some .swf files, but I want them to appear within another flash movie, not an external movie. I knwo that this can be done with referencing the .swf or mpeg...but I'm not sure how to do it.
Got any tuts/tips?
Strange Error: Error Opening Url File (that Is No Longer Loading Into Movie)
I had a few external swf's loading into my main movie, and after several revisions I went through my directory and deleted the swf's that were no longer being used.
Now I am getting an error that one of them cannot open, (it is one of the deleted that I am no longer using)
I know where the code should be, because of the timing of when the error appears in the output window, but I cannot find
code anywhere telling this movie to load.
Any ideas about what I could have done and how to find it?
Here is the actual message:
Error opening URL "file:///P|/Web%20Projects/CBS/Natri/NATRI%202003/hosted.swf"
Preloading Swf, Adds It To The Stage And Then Get Error When Clicking On Dropdown
Hello,
I have a preloader that loads my main swf-file and when it's loaded I add my main swf to the stage. In my main swf I have a lot of stuff and a couple of dropdowns. When everything has been loaded and added it looks fine but when I click on on of theese dropdowns I get the following error:
ActionScript Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.containers::BaseScrollPane/drawBackground()
at fl.controls::List/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::List/scrollToIndex()
at fl.controls::SelectableList/scrollToSelected()
at fl.controls::ComboBox/open()
at fl.controls::ComboBox/onToggleListVisibility()
(if i just run my main swf without preloading it works fine)
I have a document class where I add eventlisteners to my dropdowns...
Any help appreciated. Thanks.
SecurityError: Error #2070....cannot Access Stage Owned By...
i am loading swfs into my main swf. the swfs being loaded in will be made by me, but also a lot made by other people.
i noticed that, if a swf being loaded in uses just about ANY components, that i get this error...
SecurityError: Error #2070: Security sandbox violation: caller loadMeIn.swf cannot access Stage owned by main.swf.
this is a major issue for me. i want these swfs to be able to use components, but i DO NOT want to use Security.allowDomain('*') because then the loaded in swfs have access to everything. i am purposely giving these swfs no access to main.swf
there's got to be a way around this...
i understand that when components are added into a swf they are trying to add listeners to the stage, so i don't know how to fix this problem
Movieclip Referencing Another MovieClip On Stage
Hi all,
I have a movieclip with dynamically loaded content in a movieclip that sits on the stage, which works fine, it loads the content fine. Call it Clip A
I want multiple movieclips to reference this movieclips content. ie I want a copy of this Clip A to appear in multiple movieclips.
Real example
Clip A loads teamshirt Arsenal
Multiple clips to also have Arsenal teamshirt by looking at ClipA
Any ideas? Do i go about it using loadMovie and pointing it to the scene or attachMovie?
thank you in advance
Jason
Referencing A Loaded Movie
Can anyone help?
I have loaded a movie clip with the command;
loadMovie ("../aspect/aspect_ratio.swf", "_parent._parent.main_drop");
which works fine (I have a somewhat complicated movie going on!!). I now want to tell that movie to goto a frame from the same bit of code. I tried
tellTarget ("_parent._parent.main_drop") {
gotoAndPlay ("two");
}
but obviously this is not right.
Can anyone point me in the right direction.
Cheers
Nick
Referencing A Movie Clip
I have a button which calls the below code:
_root.movie.chapter+varChapter.play();
I have a series of frames with MC named chapter1, chapter2 etc. How do I dynamically reference a MC?
_root.movie. #### MC here to be referenced dynamically ####.play()
I have tried _root.movie.chapter where chapter is set using:
varChapter = "chapter1"
or varChapter = 1
and then
chapter + varChapter
but this does not work?
Referencing A Loaded Movie
hi
someone at work asked me about this & i have no idea
he's got library.swf with 4 movie clips that have the linkage of 'export this symbol'
there are buttons in library.swf to load in the linked movie clips, e.g.
placeHolder.attachMovie("circle", "myCircle", 2);
placeHolder.myCircle._x = -40;
placeHolder.myCircle._y = 40;
right...
library.swf is loaded into the 'placeholder' movie clip in main.swf
placeHolder.loadMovie("library.swf");
can he use any variation on the above attachMovie() code to trigger the attachMovie inside library.swf using a button inside main.swf (if that makes sense)
as i see it, the complication arises through the fact that library.swf has no instance name inside main.swf - is there any way to give a loaded movie an instance name?
i've suggested rearranging everything to use levels but it would be a lot easier not to...
any ideas anybody?...
thanks for your help
Referencing A Loaded Movie
I have a seperate movie that I load into my main movie and basically use that as a navigation system. I'm trying to reference a particular scene within the main movie from within the loaded navigation movie. I'm having trouble with the referencing. I have no problem referencing a Frame Label on the main timeline, but for some reason it won't go to a scene. I'm probably messing something up with my code, but any help would greatly be appreciated!!
Thanks!
Sound Referencing Outside Movie
I've heard that you can "reference" a sound loop source outside of your Flash movie with MX in order to reduce your movie size. Does anyone know how to do this?
Embedded Movie Referencing
hello,
i am trying to reference a movie which is inside another movie and change its x position, i am trying to do this by:
_root.parentmovie.childmovie._x=100;
but its not working for some reason, does anyone know why ?
thank you
Referencing An Attached Movie
I am trying to reference an attached movie but I don't know how to reference it. Here's my code here...
_root.attachMovie("contact", "newContact", 10);
okay so then I can say...
_root[newContact] if i want to reference it.
but then I later i am attaching a movie to newContact so i say
_root[newContact].attachMovie("contactBox", "newContactBox", 11);
now how do i reference the inner movie?
i seem to be able to access properties if i use the names directly
such as
test = newContact.newContactBox._alpha;
trace(test);
but as soon as i start using dynamic names (sending the names to the opener functions with variables it says that it's undefined...
so if i say...
var1 = "contactBox";
var2 = "newContactBox";
and then have a button that says:
on(press){ trace(var1.var2._alpha); } it doesn't work
but if I say
on(press){ trace(newContact.newContact._alpha); } it works...???
what am i doing wrong? help me please
Referencing A Movie Clip
Hi all. I'm a bit new to AS3 and have a pretty simple question. Here is my code.
Code:
function loadXML(loaded) {
if (loaded) {
_root.inventor = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.comments = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
text_1.text = _root.inventor;
text_2.text = _root.comments;
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("inventors.xml");
but what if the text boxes (text_1 and text_2) are inside of a movieclip called mc_background? how do I reference this in the code - obviously not using _root...but?
I'm a newbie as you can see, but am working on it.
Regards
~ Steven
Help Referencing Movie Clips
Hello everybody
I have a big problem here:
I have a movie clip on the stage containing some movie clips inside but can´t reference them successfully from the self contained movie clips:
should I state in the container movie clip?:
Code:
this._parent.movieclip1
how can I reference the parent movie clip from the child movie clip?
Thanks in advance
Referencing Movie Clips
Help me, I'm completely stuck.
All I want to do is make a button when pressed, change the frame of another movie clip at the same hierarchy as it (the button and clip have the same parent clip).
I've tried this and it doesn't work:
_parent.pdf2.gotoAndPlay(2);
pdf2 is the name of the clip I want to change.
Any help is apprecieated.
|