Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Another Stage Access Question...



I ran into the stage access problem in a project I'm working on and, rather than passing on the actual project, I've simplified it in a smaller test project to illustrate my problem. Here's the .fla:
Code:
var greenSquare:Sprite = new Sprite();greenSquare.graphics.beginFill(0x00FF00);greenSquare.graphics.drawRect(-30, -30, 60, 60);greenSquare.graphics.endFill();addChild(greenSquare);greenSquare.x = stage.stageWidth/2;greenSquare.y = stage.stageHeight/2;var littleSquare1:Sprite = new Sprite();littleSquare1.graphics.beginFill(0xFF0000);littleSquare1.graphics.drawRect(-10, -10, 20, 20);littleSquare1.graphics.endFill();addChild(littleSquare1);littleSquare1.x = 475;littleSquare1.y = 200;littleSquare1.addEventListener(MouseEvent.CLICK, moveToLittleSquare1);function moveToLittleSquare1(e:MouseEvent) { blueSquare.x = littleSquare1.x; blueSquare.y = littleSquare1.y;}var littleSquare2:Sprite = new Sprite();littleSquare2.graphics.beginFill(0xFF0000);littleSquare2.graphics.drawRect(-10, -10, 20, 20);littleSquare2.graphics.endFill();addChild(littleSquare2);littleSquare2.x = 275;littleSquare2.y = 350;littleSquare2.addEventListener(MouseEvent.CLICK, moveToLittleSquare2);function moveToLittleSquare2(e:MouseEvent) { blueSquare.x = littleSquare2.x; blueSquare.y = littleSquare2.y;}var littleSquare3:Sprite = new Sprite();littleSquare3.graphics.beginFill(0xFF0000);littleSquare3.graphics.drawRect(-10, -10, 20, 20);littleSquare3.graphics.endFill();addChild(littleSquare3);littleSquare3.x = 75;littleSquare3.y = 200;littleSquare3.addEventListener(MouseEvent.CLICK, moveToLittleSquare3);function moveToLittleSquare3(e:MouseEvent) { blueSquare.x = littleSquare3.x; blueSquare.y = littleSquare3.y;}var littleSquare4:Sprite = new Sprite();littleSquare4.graphics.beginFill(0xFF0000);littleSquare4.graphics.drawRect(-10, -10, 20, 20);littleSquare4.graphics.endFill();addChild(littleSquare4);littleSquare4.x = 275;littleSquare4.y = 50;littleSquare4.addEventListener(MouseEvent.CLICK, moveToLittleSquare4);function moveToLittleSquare4(e:MouseEvent) { blueSquare.x = littleSquare4.x; blueSquare.y = littleSquare4.y;}var blueSquare:Sprite = new Sprite();blueSquare.graphics.beginFill(0x0000FF);blueSquare.graphics.drawRect(-30, -30, 60, 60);blueSquare.graphics.endFill();addChild(blueSquare);blueSquare.x = littleSquare1.x;blueSquare.y = littleSquare1.y;var movingDot:DotMove;stage.addEventListener(KeyboardEvent.KEY_DOWN, startDot);function startDot(evt:KeyboardEvent):void { if (evt.keyCode == 32) {// spacebar go(); }}stage.addEventListener(KeyboardEvent.KEY_DOWN, stopDot);function stopDot(evt:KeyboardEvent):void { if (evt.keyCode == 17) {// CTRL key removeChild(movingDot); }}function go():void { movingDot = new DotMove(blueSquare.x, blueSquare.y, greenSquare.x, greenSquare.y); addChild(movingDot);}
Here's DotMove.as:
Code:
package { import flash.display.*; import flash.events.*; import flash.utils.Timer; public class DotMove extends Sprite { private var dot:Sprite; private var step:Number = 0.1; private var timer:Timer; private var x1:Number; private var y1:Number; private var x2:Number; private var y2:Number; public function DotMove(x1, y1, x2, y2):void { init(x1, y1, x2, y2); } function init(x1, x2, y1, y2) { dot = new Sprite(); dot.graphics.beginFill(0x000000); dot.graphics.drawCircle(-2, -2, 4); dot.graphics.endFill(); addChild(dot); dot.x = x1; dot.y = y1; timer.addEventListener(TimerEvent.TIMER, translate); timer.start(); } function translate(e:TimerEvent):void { trace("in translate"); } }}
The actual functionality I'm looking for is, when I hit the spacebar, the dot moves from the blue square to the green square. I've left out that code and only included a trace. When I hit the spacebar, I get this standard error: "Error #1009: Cannot access a property or method of a null object reference." My problem is this: I know that I can get access to the stage in the DotMove class by changing this...
Code:
public function DotMove():void { init(); } function init() {
...to this...
Code:
public function DotMove():void { addEventListener(Event.ADDED_TO_STAGE, init); } function init(event:Event) {
My problem is that I need to pass (x1, x2, y1, y2) to DotMove. How can I pass (x1, x2, y1, y2) to DotMove, and to init, if init's argument is already (event:Event)? Thanks!



KirupaForum > Flash > ActionScript 3.0
Posted on: 11-02-2007, 06:19 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Why Is "stage" Accesible But I Cant Access Things On Stage
I have placed a textfield on the stage and in a class however cannot access this textfield but I can access simply stage

eg trace(stage) but not trace(stage.debug)

1119: Access of possibly undefined property debug through a reference with static type flash.display:Stage.

if i declare it in the class like so

private var stage:Stage; or public var stage:Stage;
I get other errors.

Im converting to 3 from 2 and the new error pessages are harder to decipher.


In fact just scripting in the first frame produces the same errors, so it not the class.


thanks

Access Shapes On The Stage
I want to import a Freehand document into
Flash and be able to access all the
shapes on the stage and use them
as motion guides for movie clips.
I see nothing in the AC reference
for this sort of thing.
Impossible? Is there a way?

How Do You Access Stage Properties?
You cannot instantiate the Stage class, on the other hand neither "stageWidth", nor "Stage.stageWidth" are resolved.

???

Stage Access Question
Okay I'm going to try to explain this as best I can.

I have 3 as files, each one containing 1 package and 1 class.

I have one As file that my FLA is linked to. In this file it calls functions from another AS file called JoeyAvino.as. This is where I store functions I use over and over such as...
in Amedia.as

ActionScript Code:
private var stageFunction = new JoeyAvino;
stageFunction.fadeMC(text_mc.over, 1, 0, .5);

In JoeyAvino.as

ActionScript Code:
function fadeMC($mc, $op1, $op2, $speed):void {
    $fadeTween = new Tween($mc, 'alpha', None.easeNone, $op1, $op2, $speed, true);
}

Okay so this works great!

But now, In my second as file JoeyAvino.as I want to call a movie clip and I get access of undefined property..

ActionScript Code:
fadeMC(myMc, 0, 1, 0.5);

What do I need to do to do this?
The class in JoeyAvino.as extends MovieClip but for some reason I can't access the stage.

I know I'm probably retarded. Help would be awesome.

Eventually I want to be able to call the stage from my 3rd as file but let me figure this out for now.

How To Access Stage Properties?
Hi! I just recently got started with AS3.
My current problem is that I have a dynamic text field on the stage and wanted to change it's text from inside a Movie Clip.
When I try this code:

stage.textfield.text = "hello";

I get an error saying that I'm trying to access an undefined stage property.
So, the real question I have is: how can I access variables and properties that I declared on the stage, from within Movie Clips?
In AS2, if I declared on the stage, for instance, a variable named "code", I could access it from inside a Movie Clip using: "_root.code" and it would work fine.
How should I do this in AS3?
Thanks!

Cannot Access Stage Owned By
I am working on a couple Flash Banners that are loaded into another swf file.

I have 3 swfs:

BannerLoader.swf
Edmond.swf
SanAntonio.swf

BannerLoader partially loads the SanAntonio.swf and throws an error that reads:


Quote:




*** Security Sandbox Violation ***
SecurityDomain 'http://www.weightwise.com/Websites/101/Files/SanAntonio.swf' tried to access incompatible context 'file:///Rich%20G5/Users/richjamison/Documents/Flash/WeightWise/Banners/HomePage/Round2/Publish/BannerLoader.swf'
SecurityError: Error #2070: Security sandbox violation: caller http://www.weightwise.com/Websites/1...SanAntonio.swf cannot access Stage owned by file:///Rich%20G5/Users/richjamison/Documents/Flash/WeightWise/Banners/HomePage/Round2/Publish/BannerLoader.swf.
at flash.display::Stage/get stageWidth()
at SanAntonio_fla::MainTimeline/frame1()




I think it has something to do with the URLRequest being a http address instead of a local file on my hard drive.


After the SanAntonio.swf fades out and is removed, the Edmond.swf loads in the same manner BUT it doesn't throw the error. This is confusing because the Edmond.swf and SanAntonio.swf are the same except for different Doctor photos and background image. Everything else is the same, including the code.

Any Thoughts,

Access Movieclip On Stage ?
I have a movieclip on stage, named "book1".

Now I have a class called "Shelf" (it's NOT a document class). Here it is :


ActionScript Code:
package{
  import flash.display.Sprite;
  import flash.display.MovieClip;

  public class Shelf extends MovieClip {
    public function Shelf {
      // .... How do I access book1 on stage ?
    }
  }
}

How do I access "book1" movieclip on stage from Shelf class ?

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?

Can't Access Stage From External Swf
Hey all, I have a question...I've developed a flash gallery that can be dynamically resized using stage.stageWidth and stage.stageHeight. I wanted a preloader for it, since people were staring at a black square until it was done loading, so I decided to use a loader swf that loads the gallery swf.

The problem is that once the gallery swf is finished loading, it errors out with: Cannot access a property or method of a null object reference, at the stage.stageWidth line. Is there anyway to access the stage from a loaded swf??

How To Access MC On Stage In A Class?
Hi there.
I have my custom Class, and some movieclips on Stage.
How could I access them from the class?

Let's say, we've got a MC on Stage called "bubble", and example class:

ActionScript Code:
myClass
{
  public function myClass (
    // How I can access "bubble" MC here?
  }
}

Root Stage Access
Hi all

Making the jump to AS3 - and don't get the root/stage stuff.
I just want to know how to access root variables/ and then how to access root movieclips from within movieClip instances

eg.

Here's my fla code:

ActionScript Code:
var myX:int = 200;
function Start():void {
    var newCircle:Ball = new Ball();
    addChild(newCircle);
}
Start();

Here's my Ball Class:

ActionScript Code:
package {
    import flash.display.*;
    import flash.events.*;

    public class Ball extends MovieClip {
        public function Ball() {
            this.x = stage.myX;
            this.y = 40;
        }
    }
}


So why does stage.myX not reference my var myX??

Access MovieClip In The Stage
Hello,

I am using the ActionScript 3 in a aplication and i have problem to access the MovieClips that is on the Stage. Let me explain.

I the stage i have two MovieClips, with instance of mc1 and mc2. Inside of mc1 i try to access some proprerties from mc2 but without success.

I try using this:

trace(parent.mc2.width);

But the Flash return the error 1119, undefined propertie.

So, how can i access the MovieClips that is on my stage from another MovieClip.

Thanks

Cannot Access Stage.stageWidth
with this:

trace(Stage.stageWidth)

i get this error:

1119: Access of possibly undefined property stageWidth through a reference with static type Class.

Access The Stage From A Package?
Hi --

I have a custom package I wrote and I need to add a child to the stage from
the package. However, a plain "addChild()" throws an error when compiling
the movie. I tried stage.addChild() and root.addChild() but those both give
me errors at compile time as well.

Can anyone help me with this?

Thanks

Rich

Dynamic Mc Access To Stage
I have a Document Class named is StageControl.
Class path is com.magazine.tool.StageControl;

StageControl working perfectly. But im dynamic creating (linkage) a mc in container movie clip.

var content_mc:textSmall = new textSmall();
container.addChild(content_mc);

problem is, i have an scripts in content_mc frame1. I want to access root.tempText.

trace(stage.root.tempText);
trace(root.tempText);

root code:
var tempText:String = "test";

error code:
1119: Access of possibly undefined property tempText through a reference with static type flash.displayisplayObject.


please help me this question.

Cutting Off Access To The Stage?
i have a swf which will be loading outside swfs (not of my making). i realize there are potential security flaws... but neglecting the important stuff for a moment...

if the loaded swf tries to change the stage orientation... for example if i initially set my stage to align as such:

Code:
Stage.align = "TL";

and then the loaded swf sets it to be:

Code:
Stage.align = "CC";
this completely messes up the orientation of my swf.

this problem could be manifest in many ways, but my specific goal here is to be able to load Google videos without them messing up my swf. Is there any way to cut off access to the Stage object?

pace, thnx

Stage Access From Loaded SWF
I've searched and found similar topics, but never a solution. I apologize if this has been answered before...

I am loading an external swf using a loader. the external swf is calling the stage for a MOUSE_LEAVE event. the stage is coming back null.

does anyone know how to reference the stage from within a loaded swf?

thanks!

Can't Access Stage With Preloaded Swf Help Please
Here is the problem. I have two FLA/SWF, one is named main.swf, and other is called preloader.swf.

The document class of preloader.swf references to com.jeffreyseiffert.Preloader

The document class of main.swf references to com.jeffreyseiffert.Main

I have 3 Actionscript files. Preloader.as, Main.as, and TopLevel.as (last one thanks to senocular.com)

Preloader.as as you can tell is a preloader. It does url request for main.swf. Then when the event tells it that it is done loading it adds it to the stage.

Both of them extend TopLevel. But it brings up this error when it tries to load the file.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TopLevel$iinit()
at com.jeffreyseiffert::Main$iinit()


I even commented out all the code in Main.AS but the default constructor but still same error. Anyhelp in how i can allow Main.as access stage would be appreciated. I will post my code here

Preloader.as

ActionScript Code:
package com.jeffreyseiffert{    import TopLevel;    import flash.net.URLRequest;    import flash.display.Loader;    import flash.display.LoaderInfo;    import flash.display.Sprite;    import flash.display.DisplayObject;    import flash.display.MovieClip;    import flash.events.Event;    import flash.events.ProgressEvent;    import flash.events.StatusEvent;    //create new URLRequest object    public class Preloader extends TopLevel {        private var loader_mc:bar_mc;        private var background_mc:Background_mc;        private var percent_txt:percentage_txt;        private var myloader:Loader;        private var myRectangle:Sprite;        private var incrementer:Number;        private var home_btn:Sprite;        public function Preloader() {                                    // initialize sizing            trace("Preloader initialized");            loader_mc=new bar_mc();            background_mc=new Background_mc();            percent_txt=new percentage_txt();            myRectangle=new Sprite();            incrementer=0;            resizeHandler(null);            TopLevel.stage.addChild(background_mc);            trace("background_mc added to stage");            TopLevel.stage.addChild(loader_mc);            trace("loader_mc added to stage");            TopLevel.stage.addChild(percent_txt);            trace("percent_txt added to stage");            TopLevel.stage.addChild(myRectangle);            trace("myRectange added to stage");            var myrequest:URLRequest=new URLRequest("nav.swf");            //create new Loader object            myloader=new Loader();            //load URLRequest into loader            myloader.load(myrequest);            //create listener to response to PROGRESS event            myloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressHandler);            myloader.contentLoaderInfo.addEventListener(Event.COMPLETE,alldone);            //create a function to respond to the PROGRESS listener            stage.addEventListener(Event.RESIZE,resizeHandler);        }        public function progressHandler(myevent:ProgressEvent):void {            var myprogress:Number=myevent.target.bytesLoaded / myevent.target.bytesTotal;            loader_mc.scaleX=myprogress;            percent_txt.p_txt.text=Math.round(myprogress * 100) + " % Loaded";            createRect(myprogress,stage.stageHeight - background_mc.height - 100,0,5,stage.stageHeight,0xFFFFFF);        }        public function createRect(stagePercent:Number,x:Number,y:Number,mWidth:Number,mHeight:Number,color:Number):void {            incrementer+=1;            myRectangle.alpha=.10;            myRectangle.graphics.beginFill(color);            myRectangle.graphics.drawRect(stage.stageWidth*(stagePercent),y,mWidth,Math.random() * stage.stageHeight);            myRectangle.graphics.endFill();            myRectangle.graphics.beginFill(color);            myRectangle.graphics.drawRect(stage.stageWidth*(stagePercent),stage.stageHeight,mWidth,Math.random() * (stage.stageHeight/2));            myRectangle.graphics.endFill();        }        public function resizeHandler(event:Event):void {            background_mc.x=(TopLevel.stage.stageWidth - background_mc.width)/2;            background_mc.y=(TopLevel.stage.stageHeight - background_mc.height )/ 2;            loader_mc.x=(TopLevel.stage.stageWidth - loader_mc.width)/2;            loader_mc.y=(TopLevel.stage.stageHeight - loader_mc.height)/ 2;            percent_txt.x=(TopLevel.stage.stageWidth - percent_txt.width)/2;            percent_txt.y=(TopLevel.stage.stageHeight - percent_txt.height+70)/2;        }        //create a function to respond to COMPLETE listener        public function alldone(myevent:Event):void {            TopLevel.stage.removeChild(loader_mc);            TopLevel.stage.removeChild(background_mc);            TopLevel.stage.removeChild(myRectangle);            stage.removeChild(percent_txt);            myloader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,progressHandler);            myloader.contentLoaderInfo.removeEventListener(Event.COMPLETE,alldone);            TopLevel.stage.removeEventListener(Event.RESIZE,resizeHandler);            addChild(myloader);            //stage.removeChild(loader_mc);        }    }}

Main.as

ActionScript Code:
package com.jeffreyseiffert{        import flash.display.Sprite;    import flash.display.DisplayObject;    import flash.display.MovieClip;    import flash.events.*;    import flash.utils.*;    import TopLevel;            public class Main extends TopLevel{                function Main (){            //stage.scaleMode=StageScaleMode.NO_SCALE;                                //stage.align=StageAlign.TOP_LEFT;            trace("Enter Constructor for Main");            //create new Loader object            //resizeHandler(null);//    //            //create listener to response to PROGRESS event//            //create a function to respond to the PROGRESS listener//            container_mc.main_menu.resume_btn.addEventListener(MouseEvent.CLICK,loadResume);//            container_mc.main_menu.web_sites_btn.addEventListener(MouseEvent.CLICK,loadWebsites);//            container_mc.main_menu.graphic_designs_btn.addEventListener(MouseEvent.CLICK,loadGraphicDesign);//            container_mc.main_menu.contact_me_btn.addEventListener(MouseEvent.CLICK,loadContactMe);                    }        //public function loadResume(e:MouseEvent):void{//            trace("loading resume");/*//            var myrequest:URLRequest=new URLRequest("resume.swf");//            //load URLRequest into loader//            myloader.load(myrequest);//            myloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressHandler);//            myloader.contentLoaderInfo.addEventListener(Event.COMPLETE,alldone);*///            //        }//        public function loadWebsites(e:MouseEvent):void{//            //        }//        public function loadGraphicDesign(e:MouseEvent):void{//            //            //        }//        public function loadContactMe(e:MouseEvent):void{//            //            //        }//        public function  progressHandler(myevent:ProgressEvent):void {//////        }//        public function createRect(stagePercent:Number,x:Number,y:Number,mWidth:Number,mHeight:Number,color:Number):void{//            //incrementer+=1;//            //myRectangle.alpha=.10;//            //myRectangle.graphics.beginFill(color);//            //myRectangle.graphics.drawRect(stage.stageWidth*(stagePercent),y,mWidth,Math.random() * stage.stageHeight);//            //myRectangle.graphics.endFill();//            //myRectangle.graphics.beginFill(color);//            //myRectangle.graphics.drawRect(stage.stageWidth*(stagePercent),stage.stageHeight,mWidth,Math.random() * (stage.stageHeight/2));//            //myRectangle.graphics.endFill();//            //            //        }////        public function alldone(e:Event):void{//            //        }//        public function resizeHandler2(event:Event):void {//            trace("resize");//            //            container_mc.x=(width-(container_mc.width/2))/2;//            container_mc.y=20;////        }    }    }

TopLevel.as

ActionScript Code:
package {        import flash.display.DisplayObject;    import flash.display.MovieClip;    import flash.display.Stage;    import flash.display.StageAlign;    import flash.display.StageScaleMode;        /*     * TopLevel class     * have all document classes extend this     * class instead of Sprite or MovieClip to     * allow global stage and root access through     * TopLevel.stage and TopLevel.root     */    public class TopLevel extends MovieClip {                public static var stage:Stage;        public static var root:DisplayObject;                    public function TopLevel() {            TopLevel.stage = this.stage;            TopLevel.root = this;            this.stage.scaleMode=StageScaleMode.NO_SCALE;            this.stage.align=StageAlign.TOP_LEFT;        }    }}

I really appreciate those who take the time to help me out with this.

Cannot Access Stage Owned By
I am working on a couple Flash Banners that are loaded into another swf file.

I have 3 swfs:

BannerLoader.swf
Edmond.swf
SanAntonio.swf

BannerLoader partially loads the SanAntonio.swf and throws an error that reads:


Quote:




*** Security Sandbox Violation ***
SecurityDomain 'http://www.weightwise.com/Websites/101/Files/SanAntonio.swf' tried to access incompatible context 'file:///Rich%20G5/Users/richjamison/Documents/Flash/WeightWise/Banners/HomePage/Round2/Publish/BannerLoader.swf'
SecurityError: Error #2070: Security sandbox violation: caller http://www.weightwise.com/Websites/1...SanAntonio.swf cannot access Stage owned by file:///Rich%20G5/Users/richjamison/Documents/Flash/WeightWise/Banners/HomePage/Round2/Publish/BannerLoader.swf.
at flash.display::Stage/get stageWidth()
at SanAntonio_fla::MainTimeline/frame1()




I think it has something to do with the URLRequest being a http address instead of a local file on my hard drive.


After the SanAntonio.swf fades out and is removed, the Edmond.swf loads in the same manner BUT it doesn't throw the error. This is confusing because the Edmond.swf and SanAntonio.swf are the same except for different Doctor photos and background image. Everything else is the same, including the code.

Any Thoughts,

Access Movieclip On Stage ?
I have a movieclip on stage, named "book1".

Now I have a class called "Shelf" (it's NOT a document class). Here it is :


PHP Code:



package{
  import flash.display.Sprite;
  import flash.display.MovieClip;

  public class Shelf extends MovieClip {
    public function Shelf {
      // .... How do I access book1 on stage ?
    }
  }





How do I access "book1" movieclip on stage from Shelf class ?

Thanks.

Access Stage From Class
Hi

I have a package, with classes, functions etc. Basically i need to tell some movieclips on the stage to be visible etc but using this.MyMCName obviously doesn't work. How do i reference movieclips from within a class?

Access Stage From Class
I've gone through the Access to stage and root post in the AS3 Tip of the Day thread and it's put some perspective into how things work and have changed however I just can't get the syntax right... Here's what i've got

Code:
function onUpper(event:MouseEvent):void{
switch(holder.name){
case "one" :
var startx:Number = holder.x;
var finishx:Number = holder.x+100;
//var whichclip:MovieClip = holder;
var whichclip:MovieClip = root.content_mc;
//trace(whichclip);
var xTween:Tween = new Tween(whichclip, "x", Regular.easeOut, startx, finishx, .5, true);
trace("first one")
break;
this is inside of my external class, basically this runs inside of a function that creates buttons which will be my navigation. the second declaration of "whichclip" is where i need help. it's pretty obvious what i'm trying to do and what i'm doing wrong if you're up to speed with AS3. any help is greatly appreciated. thanks.

Access To Stage From Subclass
hello,

i'm a bit stuck with something. i have a class that loads a bunch of thumbs. now i would like to reorder them when the stage is resized.
my problem is now that I get an error when I try to access the stage:

Code:

      public function loadThumbs(stageW:Number, stageH:Number, stageRatio:Number, folder:String ) {         
      
              _xmlL = new XMLLoader (xmlPath + _folder);         
         _xmlL.addEventListener (XMLLoader.XMLLOADED, xmlComplete);         
         
                       stage.addEventListener(Event.RESIZE, onResizeThumb);         
      }

in the fullscrollbar of onebyonedesign he also is doing this. my class extends Sprite.
can anyone help me with this?

MX: Main Stage Timeline Access
OK.. I found my problem. I've been telling the clip that contained the script to gotoAndPlay(2) when I need to be telling the main timeline to jump to another scene... the MC containing the script is a child of the main movie and I want it to tell the main stage to jump to another scene.. or just another frame on the main timeline if another scene is not possible. Here is what it looks like now.


Code:
onClipEvent(load) {
defaultX = this._x;
defaultY = this._y;
}

onClipEvent(mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
startDrag(this);
this.swapDepths(100);
}
}

onClipEvent(mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
stopDrag();
if (this._droptarget=="/target1") {
setProperty(this, _x, _root.target1._x);
setProperty(this, _y, _root.target1._y);
_root.whereTo = "house";
trace("I should be going to " add _root.whereTo);
/*--------->*/_root.gotoAndPlay(2);
} else {
_x = defaultX;
_y = defaultY;
}
}
}
this seems to be telling the MC that contains this script to jump to frame 2 instead of the main timeline... any ideas?

Thanks,
Carl Gibson - rkitecsure@hotmail.com

How To Access Movie Clips Placed On Stage?
I'm REALLY new to actionscript.. I just need to make this work for a project. I'm using Flash MX.

I have an MC on my stage called combo. I have an invisible button over it called mask. I want to put in an


Code:
on(Rollover){combo.gotoAndPlay(2);}


but sadly it is not able to access the combo. or ANY other movie clip present on the stage. I tried trace(targetPath("combo")); with every kind of mundane combination, but it always returns -undefined-

Please help me, and dont call me names cuz this might be obvious?

Type Pasword Anywhere On Stage To Access
I would like to access a hidden menu system if the user
types the word "admin" on the keyboard

so basically something just listening for those letters typed in a row.. and when the word is typed in full the menu will pop up automatically

I just don't know where to start on setting up a listener for the key strokes

Can't Access Movieclip Instance On Stage
Hi,
I recently updated from Flash 5 (!) to CS3, and I thought my JavaScript knowledge should help me in upgrading myself. Well, it helped, but there's a few concepts I am having trouble with...
That aside, I have one major issue I can't figure out at the moment.

I have a regular MovieClip (one frame, only graphics inside) with an instance called "myFlag" on the stage using the IDE. I created a document class file which is loaded and run normally. Inside this class I am trying to access the x and y property of myFlag, but for some reason I can't - the compiler can't find myFlag.
I tried exporting the Symbol to AS3 (not quite sure what that does so far, but that's not part of my question - I'll figure that out another day).
I have some example files from a book I am using to teach myself, and when working with components I saw that the code they were using to access properties of an instance on the stage is the same as mine, but mine doesn't work.


Code:
var flagStartX:uint = Math.round(myFlag.x - (myFlag.width/2)+1);


This is the "offending" code. It sits in the class after the class definition and after the constructor is done. After this code come my other functions which are called from the constructor.

I can't figure this one out, and I have not received a lot of help in the Adobe forums. Then I saw the attendance of this forum, so I am hoping someone will be able to help me here.

What am I doing wrong?

Thanks!

Problem With A MovieClip ...can't Access The MC Even If Is On Stage
Hi all!

Need some help cause it seems i have no inspiration

I have 2 classes. The first one runes and add's a MovieClip to the stage called "menu_mc" i add to this MovieClip an EventListener that sends the event to a function of another class.

The problem is that when i click on the MovieClip it runs the function, adds the new MovieClip "menu2" ... but won't remove the "menu_mc" from the stage.
here are the classes:

package
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import fl.transitions.TweenEvent;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.media.SoundMixer;
import flash.events.Event;

import flash.media.Sound;
import flash.net.URLRequest;

public class VM extends MovieClip
{
private var menu_mc:MenuMC = new MenuMC();

public function VM():void
{
menu_mc.x = this.stage.stageWidth/2;
menu_mc.y = this.stage.stageHeight/2;
this.addChild(menu_mc);

var align:AlignMenu = new AlignMenu();
menu_mc.btn1.addEventListener(MouseEvent.CLICK, align.onClick1);
addChild(align);
}
}

}

//************** The second Class

package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
import flash.media.SoundMixer;

import fl.transitions.Tween;
import fl.transitions.easing.Bounce;
import fl.transitions.easing.Elastic;
import fl.transitions.easing.Strong;
import fl.transitions.TweenEvent;
import fl.transitions.TransitionManager;
import fl.transitions.Photo;
import fl.transitions.Transition;

public class AlignMenu extends MovieClip
{
private var menu2:MenuR = new MenuR();
var menu_mc:MenuMC = new MenuMC();

public function AlignMenu():void
{
trace(menu_mc);
trace(menu2);
menu2.btn1_resized.addEventListener(MouseEvent.CLI CK, onClick2);
}
public function onClick1(event:MouseEvent):void
{
trace(event.target.name);

var btn1:SimpleButton ;
if(event.target.name == menu_mc.btn1.name)
{
trace(numChildren);
var tw0:Tween = new Tween(menu_mc.menuLine, "alpha", Strong.easeInOut, 1, 0, 1, true);
var tw:Tween = new Tween(menu_mc.btn1,"scaleX",Bounce.easeOut,1,0,2,t rue);
var tw1:Tween = new Tween(menu_mc.btn1,"scaleY",Bounce.easeOut,1,0,2,t rue);
var tw01:Tween = new Tween(menu_mc.btn1, "alpha", Strong.easeInOut, 1 ,0, 1.5, true);

tw01.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished0);

function tweenFinished0(event:TweenEvent):void
{
menu2.x = 431;
menu2.y = 92.5;
menu2.alpha = 1;
var tw:Tween = new Tween(menu2, "alpha", Bounce.easeInOut, 1, 1, 1, true);
addChild(menu2);
}
}
}
}
}

Constructor Function Cannot Access Stage
inside a class's constructor function I had

ActionScript Code:
t0_txt.stage.focus = t0_txt
t0_txt.setSelection(0, 0)

but from constructor function stage is not accessible so I used setTimeout


ActionScript Code:
public function contactform()
        {
    setTimeout(focusfirst, 10)
        }
    public function focusfirst():void{
            t0_txt.stage.focus = t0_txt
            t0_txt.setSelection(0, 0)
    }

I feel that setTimeout is not a good saolution and may cause problems...
how are these type of things usually done?

Constructor Stage Access Problem
I have a subclass under my main class that strictly loads audio.

package app.easy.sound {

import flash.media.*
import flash.net.*
import flash.events.*
import flash.display.*



public class AudioP extends Sound {

public function AudioPlay(path:String) {
_channel = new SoundChannel();
var context:SoundLoaderContext = new SoundLoaderContext(10000);
this.load(new URLRequest(path), context);

this.addEventListener(ProgressEvent.PROGRESS, onLoadProgress, false, 0, true);
function onLoadProgress(evt:ProgressEvent):void{
progData = evt.bytesLoaded;


}


}

What I want to do is access the stage from here and alter a graphic based off of the progData variable.

The problem is, the stage is not accessible from this .as file, no matter what I try.

This load function is called from another .as file and this .as file is never introduced to the main stage so how can I affect graphics on the stage from here?

any help is greatly appreciated

Access Button In Stage(.fla File)
I have a button in my stage..ie on my fla file...The botton name is btn_pause.
I need to access that button from my class file(.as file)..I had tried Stage.btn_pause.But it is not working..Please give me a solution..with some example..

Thankyou...

Cannot Access Stage Properties From AS3 Class
please take a look at the attached code. it's throwing this compiler error:

1120: Access of undefined property stage

any ideas why?










Attach Code

package ccg.Screens {

import flash.display.*;

public class ScreenHiding {

public function ScreenHiding ( c:Sprite )
{
trace("ScreenHiding: "+stage.frameRate);
};
};
};

How To Access Stage Instance From Constructor?
I have some frame code that looks like this:

var mc = new myClass();
addChild( mc );
// Try to access mc.stage here, no problem

Inside myClass it looks like this:

package {
class myClass {
function myClass() {
// try to access "stage" here, it comes up null!
}}}

So how can I access the stage in the constructor instead of in the frame code? I want to add event listeners to the stage and would rather do it from within the class constructor than in the frame code. Doing this in the frame code will just lead to sloppiness as the application develops.

Thanks.

How To Access Stage From External Class
Hello Flash Forum Members,

I have an fla file with a bunch of actionscript, which adds objects in the library (classed as sprites) to the stage of the fla file.
This works and plays correctly. I have these objects in the library. I call this fla yo_lesson.fla, and the published swf is yo_lesson.swf.

I then decided that it would be nice to create a loader file that can load different external swfs on the stage of my loader app.
I have tried to load the yo_lesson.swf file in my loader fla/swf (called FlashMenu.fla,FlashMenu.swf) using the url loader, urlrequest, etc.
The file loads, but I get many many errors in terms of the "stage". I have an event listener for the stage:

this.addEventListener(Event.ENTER_FRAME, everyFrame);

This line is in the actionscript for my yo_lesson.fla file.
I gave up trying to load this swf file. I decided to try to convert yo_lesson.fla/swf to a class, using the action script from the yo_lesson.fla. I created a class called FlashBook.as, and a file called FlashBook.fla, and added the FlashBook.as file to the FlashBook.fla file with the publish settings in the actionscript tab. My class file does include the code for the everyFrame function for the event listener.

I do not have a listener in my FlashBook.fla file, i do have objects from the yo_lesson.fla file added to the FlashBook.fla library. These objects are sprites which I add to the stage. but my everyFrame function does not run beyond the first frame, and none of my library objects gets added to the stage.

I guess that I cannot access the timeline in an external class? Or, how can I do this? I know enough that I am trying to add the class to my stage in the FlashBook.fla file, and access/track frame numbers from the "stage" in the external class file, which I am not doing correctly.

If i load a swf with out a timeline in it, (like just an image, etc) the file will load.

Thanks,

eholz1

Trying To Access Textfield On Stage From Another Class
This is for AIR: My document class imports a separate class "ConnMonitor" and uses it to constantly monitor the network connection. It's at the very end of that class where it's supposed to update a textfield on the stage as the connection changes, but the class can't access the textfield.









Attach Code

DOCUMENT CLASS:

package URLUpdater {

import flash.display.MovieClip;
import flash.text.*;
import flash.events.StatusEvent;
import URLUpdater.ConnMonitor;

public dynamic class Main extends MovieClip
{
public var cm:ConnMonitor = new ConnMonitor();

public function Main()
{
cm.updateConnMonitor();
}
}
}

CONNECTION MONITOR CLASS:
package URLUpdater {

import flash.display.MovieClip;
import flash.text.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import air.net.URLMonitor;
import flash.events.StatusEvent;
import flash.data.SQLConnection;
import flash.display.*;

public dynamic class ConnMonitor extends MovieClip
{
private var conn:SQLConnection;
private var connState:String = "offline";

public function ConnMonitor()
{
updateConnMonitor();
}

public function updateConnMonitor():void {
var req:URLRequest = new URLRequest("http://www.google.com");
req.method = "HEAD";
var urlMonitor:URLMonitor = new URLMonitor(req);
urlMonitor.addEventListener(StatusEvent.STATUS, onConnStatus);
urlMonitor.pollInterval = 1000;
urlMonitor.start();
}
public function onConnStatus(e:StatusEvent):void {
var monitor:URLMonitor = e.target as URLMonitor;
if(monitor.available == true) {
conn_txt.textColor = 0x009900;
conn_txt.text = "You are online";
} else {
conn_txt.textColor = 0xFF0000;
conn_txt.text = "You are offline";
}
}
}
}

Application Wrapper And Access To Stage
Hi,

I have my application swf with its document class Application. I made a wrapper swf in order to preload the application, so the entire project has the following structure:

wrapper.swf -> Document class: TopLevel.as
main.swf -> Document class: Application.as

The problem is that I cannot access the stage when I publish the main.swf file, so it gives compiling errors.

Note: Application and other classes used in the project try to access the stage through static methods (i.e. Application.showPreload() ).

What am I doing wrong?

Do We Have To Passin At Least One DisplayObject To Access The Stage?
Well. Sometimes we want to get the querystring passed into a swf like: someswf.swf?a=1&b=2

But we have to use a DisplayObject.loaderInfo to access the parameters. This makes some functions in a configuration class very "weird", something like:


Code:
public static function getParams(displayObject:DisplayObject):Object
{
var param:Object = {};
param = displayObject.loaderInfo.parameters;
return param;
}
We HAVE TO pass a displayObject inside

So this is the only way?...

Preloading Swf Access To Stage = Null
Hello, I'm trying the preloader from Lee's tutorial and it works fine, as long as you don't have any reference to the stage. I have a fla that has a Document Class:

Code:

package  {
   import flash.display.MovieClip;
   
   public class Main extends MovieClip {
      
      public function Main():void
      {
          trace(this, stage);
                                    var t:Test = new Test();
                                    addChild(t);
                                    t.init();
      }
   }
}

The "Test" class is a test to reference the stage, here is it's code:

Code:

package  {
   import flash.display.MovieClip;
   
   public class Test extends MovieClip {
      
      public function Test():void
      {
          trace(stage);
      }
      public function init():void
      {
         trace(stage, root, MovieClip(root));
      }
   }
}

The root and MovieClip(root) are accessed correctly but the stage is not.

Here is the preloader class and implementation:

Code:

package  {
   import flash.display.Sprite;
   import flash.display.Loader;
   import flash.display.DisplayObjectContainer;
   import flash.text.TextField;
   import flash.text.TextFieldAutoSize;
   import flash.net.URLRequest;
   import flash.events.ProgressEvent;
   import flash.events.Event;
   
   public class PreloadSWF extends Sprite {
      var loader:Loader;
      var tf:TextField;
      var bar:DisplayObjectContainer;
      var symbol:String;
      var prog:Number;
      
      public function PreloadSWF(swf:String, tf:TextField = null, bar:DisplayObjectContainer = null, symbol:String = '%', customProgress:Function = null):void
      {
          this.tf = tf;
         this.bar = bar;
         this.symbol = symbol;
         loader = new Loader();
         if (customProgress != null)
         {
            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, customProgress);
         } else {
            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
         }
         loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
         loader.load(new URLRequest(swf));
      }
      
      private function onProgress(e:ProgressEvent):void
      {
         if (tf != null)
         {
            prog = e.bytesLoaded / e.bytesTotal;
            tf.text = Math.ceil(prog * 100).toString() + symbol;
            tf.autoSize = TextFieldAutoSize.LEFT;
         }
         
         if (bar != null)
         {
            bar.scaleX = prog;
         }
      }
      
      private function onComplete(e:Event):void
      {
         for (var i:uint = 0; i < this.parent.numChildren; i++)
         {
            this.parent.removeChildAt(0);
         }
         addChild(loader);
      }
      
      
   }
}

Implementation:
Code:

var preloaderSWF:PreloadSWF = new PreloadSWF('main.swf', bar.tf, bar.bar, '$');
addChild(preloaderSWF);

So pretty basic stuff, I guess I just want to know how can a preloaded swf access the stage. Help me just this time..........

Access Deeply Nested Movieclips On Stage Via AS3
Hello friends, iam new at forums. Iam new in AS3 too. I need your help, plz. Please look on following image while I explain the problem:


As you can see on the image, ive created a 1-frame-timeline which has a movieclip called Main_mc (instancename is myMain_mc). Main_mc has 3 movieclips, one is called Intro_mc. These 3 movieclips are not present on the whole timeline. F.e. Intro_mc is just present at frame 2-19. All of these movieclips has instance-names, f.e. myIntro_mc.

Intro_mc is again a movieclip which has more movieclips, which are present on certain frames, f.e. one movieclip is just present at frame 12-20. All movieclips has instance-names.

(I code into a seprated actionscript-file. Please read comments inside of the source code.)

Problem is that i cant refer to moviceclips which are nested in the movieclip "myMain_mc" which is on the main timeline. I can just refer to movieclips which are on the main timeline (like myMain_mc), i cant go deeper.

Many thanks for hints and thoughts.



Code:
package {

class Game {
...
...
var myMain:MovieClip;
var myIntro:MovieClip;
var mainTL:MovieClip;
...
function Murphy(pt) {
mainTL = pt; // pointer to main timeline of flash movie; given when instance is created
...
}
...
private function fSTATE_INIT():void {
// this works great
// i get the movieclip instance "myMain_mc" which is on stage of the main timelime
myMain = MovieClip(mainTL.getChildByName("myMain_mc"));


// this doesnt work anymore
// now, i try to get one movieclip called (instantiated as) "myIntro_mc"
// which is nested inside of "myMain_mc"
myIntro = MovieClip(myMain.getChildByName("myIntro_mc"));
trace(myIntro) // null

}
...
...
}
}

[CS3] ActionScript 3: How Do I Access The Stage Properties From A .as File?
I'm restarting from square one with AS 3, since I got over my head with all the OOP stuff when I first dove in, and I want to do this right. I want to write a very simple app as a first exercise. I have a .fla file (Keepaway_applet.fla) whose Document Class is set to "Keepaway". In this Flash file's library (not on the stage) is a symbol which has been given the Class "Background". This symbol is just a rectangle. I also have a file "Keepaway.as", in the same folder as the .fla file.

I want Keepaway.as to put an instance of Background onto the stage and size it to the stage, but I can't access the stage properties of Keepaway_applet.fla from the .as file. When I run the following code in Keepaway.as, the Background symbol properly appears at the upper left of the stage, but at its original size. That is, its width and height are not being set to the stage width and height.


Code:
package {

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;

public class Keepaway extends MovieClip {

public function Keepaway() {

var theBackground:Background = new Background;
addChild(theBackground);
theBackground.x = theBackground.y = 0; // put reg at upper left of stage
theBackground.width = stage.width;
theBackground.height = stage.height;

}
}
}
I also tried


Code:
theBackground.width = theBackground.stage.width;
theBackground.height = theBackground.stage.height;
My understanding was that you had to access the stage through some display object on the stage, which is why I tried putting the AddChild() statement before doing the sizing. But I'd rather size the rectangle to the stage size first, then add it to the Display list.

Can anyone tell me what I'm doing wrong?

As always, thanks!

Symbol On Stage How To Access From Document Class?
Normally working in Flex i'm having a bit of trouble getting Flash CS3 to work as I want.

I have a MovieClip symbol in my library. I have an instance of that on my stage. I have a document class all linked up. How do I access that instance on the stage from my document class without instatiating a new class?

I can create new instances and then use addChild to add them, but I have laid out this class on the stage and just want to send some text to a textfield inside it. Just can't seem to do it! Help!

Access To The Stage Object If Class Is Not In The DisplayList
hey all,
i have a utility class that isn't added to the displayList. this class needs access to the stage object to get stage.stageWidth. if this class is never added to the displayList how can it get access to the stage object to get the stage width?

thx
michael

Access Deeply Nested Movieclips On Stage Via AS3
Hello friends, iam new at forums. Iam new in AS3 too. I need your help, plz. Please look on following image while I explain the problem:


As you can see on the image, ive created a 1-frame-timeline which has a movieclip called Main_mc (instancename is myMain_mc). Main_mc has 3 movieclips, one is called Intro_mc. These 3 movieclips are not present on the whole timeline. F.e. Intro_mc is just present at frame 2-19. All of these movieclips has instance-names, f.e. myIntro_mc.

Intro_mc is again a movieclip which has more movieclips, which are present on certain frames, f.e. one movieclip is just present at frame 12-20. All movieclips has instance-names.

(I code into a seprated actionscript-file. Please read comments inside of the source code.)

Problem is that i cant refer to moviceclips which are nested in the movieclip "myMain_mc" which is on the main timeline. I can just refer to movieclips which are on the main timeline (like myMain_mc), i cant go deeper.

Many thanks for hints and thoughts.

Sourcecode

ActionScript Code:
package {
 
  class Game {
    ...
    ...
    var myMain:MovieClip;
    var myIntro:MovieClip;
    var mainTL:MovieClip;
    ...
    function Game(pt) {
      mainTL = pt; // pointer to main timeline of flash movie; given when instance is created
      ...
    }
    ...
    private function fSTATE_INIT():void {
       // this works great
       // i get the movieclip instance "myMain_mc" which is on stage of the main timelime
       myMain = MovieClip(mainTL.getChildByName("myMain_mc"));
     

       // this doesnt work anymore
       // now, i try to get one movieclip called (instantiated as) "myIntro_mc"
       // which is nested inside of "myMain_mc"
       myIntro = MovieClip(myMain.getChildByName("myIntro_mc"));
       trace(myIntro) // null
       
    }
   ...
   ...
  }
}

Access A MovieClip On The Stage From Default Class.
Hi how do I access a movie clip in my library (using FLash CS3), that is already on the timeline, on the stage from the Default class so I can change its properties with script ?

I have a movie clip containing an image (mcMan) that is dynamically added to the stage as below in the Default class. I added it dynamically so I could do a transition :


Code:
private function onManEveryFrame(event:Event):void
{
if (this.currentLabel == "enterMan")
{
man.removeEventListener(Event.ENTER_FRAME, onManEveryFrame);
//add man to stage
tMgr = new TransitionManager(man);
addChild(man);
man.x = 0;
man.y = 0;
tMgr.startTransition({type:Blinds, direction:Transition.IN, duration:.9, easing:None.easeOut, numStrips:20, dimension:0});
}
}
Thats fine and all but on the stage itself I have another movieclip from the library called mcTree again containing a single image I want to animate. This uses a motion tween but unfortunately is appearing on top of the mcMan movieclip above when I publish the movie.

I tried

this.setChildIndex(man, this.numChildren - 1);

to put the man at the top index but still the tree is in front of the man. I was thinking if I could access the instance object (or whatever) of mcTree on the stage I could use something like

this.swapChildren(tree, man);

At the moment I didnt give the mcTree movie on the stage an instance name as there are 3 keyframes using the same mcTree and I want to talk about the same object (mcTree). Should I give them all the same instance name? Very confused, must have missed something basic. Wasted a good few hours on it already

many thanks for any ideas or links.

Access To The Stage Object If Class Is Not In The DisplayList
hey all,
i have a utility class that isn't added to the displayList. this class needs access to the stage object to get stage.stageWidth. if this class is never added to the displayList how can it get access to the stage object to get the stage width?

thx
michael

How To Access Or Create A Stage In A Class File
Hello Flash Actionscript writers,

I have recently discovered that I cannot use the "stage" in a class file. I had a regular fla file that had actionscript
in my "actions" layer. Of course, the fla has a stage object. I decided it might be nice to use the actionscript
I wrote (copied, stole, etc) in as a class, so I could use it in different places, etc. I am still a neophyte in this area.

My new class file consists of a button and a textfield. I created small classes for each of these items as an exercise for myself on creating a simple class, etc.

I also have a URLLoader, and use an xmllist to do a sort of mini-slide show. The idea is to show a button and the textfield. When the user clicks the button the slide show starts. I would like to be able to center the images loaded on the stage, along with the buttons, etc. Right now I am cheating - since I decided the stage is 500 px wide, etc. I can use 500 - myButton.width, etc to center items. The fla where the class is called has a stage that wide, etc. The swf created from the class file WeeklySlideShow.swf is created from a fla with the DocumentClass set to my class WeeklySlideShow.as.

I then have yet another fla file, and load my WeeklySlideShow.swf into that file, and play it, etc. But my buttons and images are not centered. Or should I just put my actionscript class back into the calling fla as an actions layer, thus having a stage where I can center everything. I probably have a flaw in the items in my class file and am really miss-using the class concept, etc.

Any tips will help.

Thanks,

eholz1

Access Deeply Nested Movieclips On Stage Via AS3
Hello mrs and mr. Iam new on AS3 and have a problem.

Please let me explain via an image:
Explenation on image

As you can see on the image, ive created a 1-frame-timeline which has a movieclip called Main_mc (instancename is myMain_mc). Main_mc has 3 movieclips, one is called Intro_mc. These 3 movieclips are not present on the whole timeline. F.e. Intro_mc is just present at frame 2-19. All of these movieclips has instance-names, f.e. myIntro_mc.

Intro_mc is again a movieclip which has more movieclips, which are present on certain frames, f.e. one movieclip is just present at frame 12-20. All movieclips has instance-names.

(I code into a seprated actionscript-file. Please read comments inside of the source code.)

Problem is that i cant refer to moviceclips which are nested in the movieclip "myMain_mc" which is on the main timeline. I can just refer to movieclips which are on the main timeline (like myMain_mc), i cant go deeper.

Many thanks for hints and thoughts.







Attach Code

package {

class Game {
...
...
var myMain:MovieClip;
var myIntro:MovieClip;
var mainTL:MovieClip;
...
function Game(pt) {
mainTL = pt; // pointer to main timeline of flash movie; given when instance is created
...
}
...
private function fSTATE_INIT():void {
// this works great
// i get the movieclip instance "myMain_mc" which is on stage of the main timelime
myMain = MovieClip(mainTL.getChildByName("myMain_mc"));


// this doesnt work anymore
// now, i try to get one movieclip called (instantiated as) "myIntro_mc"
// which is nested inside of "myMain_mc"
myIntro = MovieClip(myMain.getChildByName("myIntro_mc"));
trace(myIntro) // null

}
...
...
}
}

























Edited: 10/16/2008 at 02:11:51 AM by Usoppe

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

[F8] Cant Access Instance Names On Stage... Gives Me Undefined
This is the first time flash does this to me.
I consider myself quite effiicient at actionscripting (ok not a guru) to have such problems by mistake.

Anyway, my problem is that i am trying to access an MC through a buttons on rollover & rollout actions. So, the button and the MC are BOTH on the same timeline and stage, on the SAME movie clip, and they both have keyframes at the same frame. However, whenever i try to use something like

on (rollOver) {
McInstanceName.dothat;
}

it does nothing.
If i try a

trace(McInstanceName._x);

it gives me UNDEFINED!

What the hell is going on?

It must have to do something with the tween i have just before. In a mad moment, i duplicated the MC that wasnt working with this method and i used the duplicated which did have any tween at all. That worked, but its not right having all your mcs 2 times cause flash had a bad hair day.

Any ideas?

Copyright © 2005-08 www.BigResource.com, All rights reserved