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




Document Class And Stage Size



Hi,

i'm a little confused how to handle the stage size inside the document class.

When calling this.stage.width or this.stage.height from within the constructor in the DocClass, i'm not getting the values that are defined in the properties inspector.

Shouldn't the stage size be a fixed value? For some reason i also seem to get different stage widths / heights at different points in the script.

Thanks for your help!



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 06-18-2008, 11:24 AM


View Complete Forum Thread with Replies

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

AS3 Stage In Document Class Bug?
Hey everyone

I have a problem in most of my fullscreen flash movies. They all depend on the stageWidth and stageHeight parameters to be able to align objects on stage, and 99& of the time this works great.

But 1% of the time, my Flash site won't catch the stage properties until a bit later in the code. If I run the following class as a document class, 99% of the time I will get:

1024
768

But 1% of the time, I will get:

0
0

This is the document class:


Code:
package
{
import flash.display.Sprite;

public class Tester extends Sprite
{
public function Tester()
{
trace(stage.stageWidth);
trace(stage.stageHeight);
}
}
}
I don't understand this error? Could it have something to do with me using SWFObject when inserting the movie or something?

Right Stage / Document Size For All Browsers?
how do I make a movie fit in all browser screen resolutions? What if I make a movie in 1024 x 768 and someone watches it at 800 x 600?

Placing What Was A Document Class, On The Stage
Hey guys, I've got a bloody headache of an issue.

I have these two classes:

ParticleSystem.as
Particle.as

from the "Learning Actionscript 3.0" book, and I want to use them in my animation, yet they are built so that the first is used as a document class.

This would be okay, but I've got alot of functionality in the animation, so whenever I try to use a stop(); or a play(); method, I get the error that basically says you have to import something first(I can't remember which error).

I also want to control the emitter to move it along a path, or follow a movieclip along a path.

Here is the code.


ActionScript Code:
//ParticleSystem

package  {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.MovieClip;
   
    public class ParticleSystem extends MovieClip {
       
        //vars for the location of the emitter
        private var emitterX:Number = stage.stageWidth/2;
        private var emitterY:Number = stage.stageHeight/2;
       
        //the function used to make a system
        public function ParticleSystem() {
            stage.addEventListener(Event.ADDED_TO_STAGE, onLoop, false, 0, true);
        }
       
        //make the particle
        private function onLoop(evt:Event) {
            var p:Particle = new Particle(emitterX,
                                          emitterY,
                                          Math.random()*11 - 6,
                                          Math.random()*-20,
                                          1,
                                          Math.random()*0xFFFFFF);
            addChild(p);
        }
    }
}


ActionScript Code:
//Particle
package  {
    import flash.geom.*;
    import flash.events.Event;
    import flash.display.*;
   
    public class Particle extends Sprite {
        private var _xpos:Number;
        private var _ypos:Number;
        private var _xvel:Number;
        private var _yvel:Number;
        private var _grav:Number;
       
        public function Particle(xp:Number, yp:Number, xvel:Number, yvel:Number, grav:Number, col:uint) {
            _xpos = xp;
            _ypos = yp;
            _xvel = xvel;
            _yvel = yvel;
            _grav = grav;
           
            var ball:Sprite = new Ball();
            addChild(ball);
           
            x = _xpos;
            y = _ypos;
            alpha = .8;
            scaleX = scaleY = Math.random() * 1.9 + .1;
           
            var colorInfo:ColorTransform = ball.transform.colorTransform;
            colorInfo.color = uint(col);
            ball.transform.colorTransform = colorInfo;
           
            addEventListener(Event.ADDED_TO_STAGE, onRun, false, 0, true);
        }
       
        private function onRun(evt:Event):void {
            _yvel += _grav;
            _xpos += _xvel;
            _ypos += _yvel;
            x = _xpos;
            y = _ypos;
           
            if(_xpos < 0 || _ypos < 0 || _xpos > stage.stageWidth || _ypos > stage.stageHeight) {
                removeEventListener(Event.ENTER_FRAME, onRun);
                parent.removeChild(this);
            }
        }
    }   
}


To sum it up, I basically just need help approaching how to add this to the stage.

I try this to no avail.

ActionScript Code:
var emitter:ParticleSystem = new ParticleSystem();
addChild(emitter);

Thanks in advance!

Reference A Button On Stage In Document Class
Hey guys,

I was wondering how I would go about getting to a button that is NOT made programatically from the document class? Let's say I drag a box on and convert to a symbol and give it an instance name of myBox. in my document class how would I go about accessing it's properties?

Thanks!

Accessing Assets On Stage Using Document Class
ok, if an asset is on stage (design time) and it has an instance name AND it's on frame 1, I can access it BUT if it's frame 2 or beyond, I get errors....any ideas on how to refer to assets on stage frame 2 and beyond within your Document class? 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!

Document Class And Objects On Stage Problem
I am using a document class on my project right now, and it works fine. I get an error when I give instance names to my MovieClips i have on the stage.. and the error is found on the doc class, on line 1, a comment.

and also, I am going to load an swf into this project, but when I try to load it, i get this error

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at xxx_fla::MainTimeline/spontaneousBox_fla::frame1()
the code in that one is on the timeline..

Accessing Parent Document Class Stage
Hi folks!

I'm having some problems accessing the stage of a parent document class in a full-browser site I'm working on.

Here's my setup: I have a main document class that loads sub-classes when individual pages are chosen from the main navigational page.

Since it's full-browser, I'd like to have the ability to reference the stage width and height from sub-classes, but can't seem to get it working properly. I've mucked around with Application Domains, and still can't seem to figure it out.

Help!

Many thanks in advance.

Preload Main Movie Via Document Class & Add Details To Stage?
Hi Guys,

I have what I think might be a dumb question on my behalf or maybe I am missing something but is it not possible to added a preloader movie clip that i create to the stage via the document class? i.e. if i wanted to use this method of preloading my movie, is it possible to add a movie clip to the stage with the status? Everything I try just doesn't seem to work Currently, when i test within flash using simulate download, my stuff is added to the stage, after the movie is loaded? I've moved my content on the stage to frame 2 with the correct frame label.

cheers for any help,
stacey


Code:
package {

import flash.display.*;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.*;
import flash.text.*;

public class SiteLoader extends MovieClip {

var preloader_site_mc:MovieClip = new MovieClip();


public function SiteLoader():void {


createPreloader();

//this.loaderInfo.addEventListener(Event.INIT, initApplication);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);


}


public function showProgress(theProgress:ProgressEvent):void {

//get the values
TextField(MovieClip(preloader_site_mc).getChildByName("preloader_site_percentage")).text = "" + (theProgress.bytesLoaded / theProgress.bytesTotal * 100);

//update width of bar by amount changed as a percentage
Sprite(MovieClip(preloader_site_mc).getChildByName("preloader_site_progressBar")).scaleX = theProgress.bytesLoaded / theProgress.bytesTotal;

}

public function onLoadComplete (myEvent:Event):void {

gotoAndStop("loaded");


}


public function createPreloader():void {

//create the preloader itself dynamically
var sprite_preloader_site_progressBarBorder:Sprite = new Sprite;
sprite_preloader_site_progressBarBorder.graphics.lineStyle(0.5,0x30304a,0.5,false,LineScaleMode.NORMAL,CapsStyle.NONE);
sprite_preloader_site_progressBarBorder.graphics.moveTo(550,420);
sprite_preloader_site_progressBarBorder.graphics.lineTo(735,420);
sprite_preloader_site_progressBarBorder.graphics.moveTo(735,420);
sprite_preloader_site_progressBarBorder.graphics.lineTo(735,425);
sprite_preloader_site_progressBarBorder.graphics.moveTo(735,425);
sprite_preloader_site_progressBarBorder.graphics.lineTo(550,425);
sprite_preloader_site_progressBarBorder.graphics.moveTo(550,425);
sprite_preloader_site_progressBarBorder.graphics.lineTo(550,420);
preloader_site_mc.addChild(sprite_preloader_site_progressBarBorder);

var sprite_preloader_site_progressBar:Sprite = new Sprite;//b6c0df or fbda9b
sprite_preloader_site_progressBar.name = "preloader_site_progressBar";
sprite_preloader_site_progressBar.graphics.lineStyle(2,0xb6c0df,0.2,false,LineScaleMode.NORMAL,CapsStyle.NONE);
sprite_preloader_site_progressBar.graphics.moveTo(552,423);
sprite_preloader_site_progressBar.graphics.lineTo(734,423);//dont have a width yet
sprite_preloader_site_progressBar.scaleX = 0;
preloader_site_mc.addChild(sprite_preloader_site_progressBar);

//ADD TEXT FIELDS

//create new instance of the font
var preloader_site_font:Font = new Arial_Embedded();

//create a format for the fields
var preloader_site_TextFormat:TextFormat = new TextFormat();
preloader_site_TextFormat.font = "Arial";//
preloader_site_TextFormat.color = 0x57578f;//0xfbda9b;
preloader_site_TextFormat.size = 10;

//create the fields & their attrs
var textField_preloader_site_loadingText = new TextField();
textField_preloader_site_loadingText.autoSize = TextFieldAutoSize.LEFT;
textField_preloader_site_loadingText.selectable = false;
textField_preloader_site_loadingText.name = "preloader_site_loadingText";
textField_preloader_site_loadingText.defaultTextFormat = preloader_site_TextFormat;

var textField_preloader_site_percentage = new TextField();
textField_preloader_site_percentage.autoSize = TextFieldAutoSize.NONE;
textField_preloader_site_percentage.selectable = false;
textField_preloader_site_percentage.name = "preloader_site_percentage";
textField_preloader_site_percentage.defaultTextFormat = preloader_site_TextFormat;

var textField_preloader_site_percentSymbol = new TextField();
textField_preloader_site_percentSymbol.autoSize = TextFieldAutoSize.LEFT;
textField_preloader_site_percentSymbol.selectable = false;
textField_preloader_site_percentSymbol.name = "preloader_site_percentSymbol";
textField_preloader_site_percentSymbol.defaultTextFormat = preloader_site_TextFormat;

//add content to those text fields
textField_preloader_site_loadingText.text = "LOADING DATA";
textField_preloader_site_percentage.text = 0;
textField_preloader_site_percentSymbol.text = " %";

//set the positions
textField_preloader_site_loadingText.x = 550;
textField_preloader_site_loadingText.y = 400;//move above registration point
textField_preloader_site_percentage.x = 700;
textField_preloader_site_percentage.y = 400;
textField_preloader_site_percentSymbol.x = 720;
textField_preloader_site_percentSymbol.y = 400;

preloader_site_mc.addChild(textField_preloader_site_loadingText);
preloader_site_mc.addChild(textField_preloader_site_percentage);
preloader_site_mc.addChild(textField_preloader_site_percentSymbol);

//add to stage
this.addChild(preloader_site_mc);


}


}



}

How Do I Get The Stage Size Of A Movieclip From Within A Class
Hi Guys,

I have a movieclip and a class attached to it.
In the class I have a simple trace to return the size of the
movieclip's stage. when I attach the movieclip into the stage I
get

Error #1009: Cannot access a property or method of a null object reference.

Why is that? and how can I get the stage width of a mc from a class.
that's what I have been using:

ActionScript Code:
trace(this.stage.stageWidth);

thanks

Stage.width And Stage.height Not Matching Document Settings?
Ok, so I have no idea why this would be happening and its driving me nuts. I have my Flash movie size set to 960x650. However, when I trace stage.width and stage.height, I get:

950.05x630

Why in the world would this be happening? It's screwing up all the work I'm trying to put into positioning elements relative to the stage size. Thanks for any help!

Making The Document Size Dynamic With The Window Size
Im looking to make the flash file dynamic so that when someone changes the window size the flash file expands with it and some of the items contained move also.

thanks for any help.

Calling A Function In Main Class From A Loaded Swfs Document Class
Hi
I have a main.swf that loads page.swf. They each have a document class called "Main" and "Page".

How can I call a function in Main from Page?

In AS2 this would be somthing like _parent.myFunction();


Cheers

AddChild Works With Document Class, But Not Timeline-instantiated Class
I cannot get a sprite to display for me when I create an instance of a very simple class in my FLA file's timeline.
However, when I make the class file the FLA's document class file, it displays just fine.
The task in question is simply drawing a square with the shape class.

Problem example:
My class, Test.as, resides in the same folder as my FLA file - so I don't use any import statement. I'm new to lots of CS3 stuff. Can anyone tell me why this doesn't work and create the shape on the stage? This seems to fail silently without any errors:
var myTest:Test = new Test();

Working example:
Setting the document class to Test.










Attach Code

// Test class

package {
import flash.display.*;

public class Test extends Sprite {

public function Test():void{
doThing();
}

private function doThing():void{
var myRect:Shape = new Shape();
myRect.graphics.lineStyle (2, 0xcc0000, 1);
myRect.graphics.beginFill(0xcccccc, 1);
myRect.graphics.drawRect(10, 10, 200, 200);
addChild(myRect);
}
}
}

Document Class Initialising Another Class With Display Objects
Hi

I'm currently learning AS3 and have got stuck with something fundamental to do with Flash and the Document Class.

I have a very simple Document Class as follows:

package {

import flash.display.*;
import com.Application;

public class EntryPoint extends Sprite {
public function EntryPoint() {
var app:Application = new Application();}}

}

I then would like to build out into other classes/patterns and want the following code to simply attach an item from the library on to the stage.

The item in the library has a Class reference of CircleTest and has a Base Class of flash.display.Sprite.

My Application class is as follows:

package com {

import flash.display.*;

public class Application extends Sprite{
public function Application() {
var mc_root:Sprite = new Sprite();

addChild(mc_root);

var circleTest:CircleTest = new CircleTest();

mc_root.addChild(circleTest);}}

}


When I compile this from Flash I get nothing other than an empty stage :-(

Please can someone tell me what I'm doing wrong here.

Many thanks in advance

D

How Do I Access A Variable Declared In My Document Class From Another Class
Hi there,

I'm pretty new to classes and am probably missing something really basic so apologies if this seems like a stupid question.

I'm trying to access a variable that I've declared in my document class from within another class.

I know I can pass the variable through when I call the class as follows:


Code:
var myBall:Ball = new Ball(5);
and pick this up in the Ball function within my Ball class as follows:


Code:
public function Ball(ballSpeed) {
trace(ballSpeed);
}
But what if I don't want to do that as I have a whole load of general global variables I want to access which were defined in my document class?

What I actually want to do is just have access to all the variables defined in the document class from within the Ball class.

I tried parent.variableName and various other ways of accessing what I need but all of them spit back errors.

Any help would be really appreciated - I'm sure this is very basic but I'm totally stuck on this.

Many thanks.
Ian

Applying A Custom Class To An Object In The Document Class...
How's it going guys. I just started learning Actionscript 3.0 and so far not bad. However, I'm having trouble applying custom created classes to objects in the main document class. I'm using Flash as the application, however there is no timeline scripting involved. I loaded the document class called Main.as:


ActionScript Code:
package
{
    import flash.display.MovieClip;
    import flash.net.URLRequest;
    import flash.display.Loader;
   
    public class Main extends MovieClip
    {
        private var _redBox:Loader = new Loader();
        private var _redBoxLink:URLRequest = new URLRequest("images/redbox.jpg");
        public var buttonScaleHover:ButtonScaleHover = new ButtonScaleHover();
       
        public function Main()
        {
            _redBox.x = 100;
            _redBox.y = 100;
            _redBox.load(_redBoxLink);
            addChild(_redBox);
        }
    }
}

Now, what I'm trying to do is apply this class named ButtonScaleHover.as to the _redBox in the document class. Here is the code for ButtonScaleHover:


ActionScript Code:
package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
   
    public class ButtonScaleHover extends Sprite
    {
        private var _xScale:Number;
        private var _yScale:Number;
       
        public function ButtonScaleHover()
        {
            trace("The ButtonScaleHover Class is being loaded");
            _xScale = this.scaleX
            _yScale = this.scaleY
            this.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
            this.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
        }
       
        public function onRollOver(event:MouseEvent):void
        {
            this.scaleX *= 2;
            this.scaleY *= 2;
        }
       
        private function onRollOut(event:MouseEvent):void
        {
            this.scaleX = _xScale;
            this.scaleY = _yScale;
        }
    }
}

I tried using
ActionScript Code:
_redBox.ButtonScaleHover();
in the document class after i added it to the display object list. However, it didn't work. Basically, I'm just trying to apply a custom class to an object(in this case the loader). Thank you guys very much in advance.

Call Function Of Document Class From MovieClip Class
How can I run a function of the main document class from a class of a MovieClip? I usually just used MovieClip(parent).function(), but now my MovieClip has another parent. Or what do I have to pass to the MovieClip class when creating the MovieClip to acess the main document class?

Sharing Vars Between Document Class And An Imported Class.
I'm working on my first really in depth AS3 project, learning as I go.

I've been sorting through the XML docs and i've bumped my head into a bit of a question. So, to preface, I have been able to load the XML successfully, but I want to be able to use my own XML loader class to load the XML and then be able to reference it from the document class. Also, I'd like to be able to send a file path to the loader class when I call it.

Not sure if that makes sense, but I will post what I did and see how bad it is


The document class:

ActionScript Code:
package rg.sites{
   
    // flash classes
   
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.text.*;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.net.*;
    import flash.errors.*;
   

    // RG classes
   
    import rg.classes.XMLSiteLoader;

    // Layout Objects

    public class SiteCurrent extends MovieClip {
       
        // vars
        public var siteLoader:XMLSiteLoader;
        public var site_xml:XML;
        public var xml_site_loading:String = "current_site.xml";
   
        public function SiteCurrent() {
            trace("Site Current is loaded");
            siteLoader = new XMLSiteLoader();
            siteLoader.addEventListener(Event.COMPLETE, xmlSiteLoaded);
        }//end constructor function
       
        private function xmlSiteLoaded(event:Event):void {
       
        trace(site_xml.toXMLString());
        trace("
" + "Background art: " + site_xml.section.(@id == "Splash"));
       
        }
       
       
    }//end class
}//end package

The XMLSiteLoader class:


ActionScript Code:
package rg.classes

//
// XMLSiteLoader version 0.1 beta
//

{
    //import fl.controls.*;
    import flash.net.*;
    import flash.events.*;
    import flash.errors.*;
   
    public class XMLSiteLoader extends EventDispatcher {
        //public var site_xml:XML;
       
        private var siteReq:URLRequest;
        private var siteLoader:URLLoader = new URLLoader();
        public var site_xml:XML;
        public var xml_to_load:String;
       
       
        public function XMLSiteLoader() {
            //trace(stage.xml_site_loading);
            if(xml_to_load == true) {
                trace("xml file path sent");
                siteReq = new URLRequest(xml_to_load);
               
            }
            else {
                trace("No XML file path sent, use default value");
                siteReq  = new URLRequest("current_site.xml");
            }
           
            trace("XML Site Loader is loading: " + siteReq);
            siteLoader.load(siteReq);
            siteLoader.addEventListener(Event.COMPLETE, xmlLoaded);
           
           
           
        } // constructor class
       
       
        private function xmlLoaded(event:Event):void {
        site_xml = new XML(siteLoader.data);
        trace("
" + "from XML Site Loader: " + site_xml.section.(@id == "Splash"));
        dispatchEvent(new Event(Event.COMPLETE));
        }
       
       
    }//end class
}//end package

I get an error that says:


Quote:




Site Current is loaded
No XML file path sent, use default value
XML Site Loader is loading: [object URLRequest]

from XML Site Loader: portfolios/splash_gallery/splash.xml
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at rg.sites::SiteCurrent/xmlSiteLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at rg.classes::XMLSiteLoader/xmlLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()




Thanks in advance for any thoughts or suggestions.
-g

Displaying A TextField From A Class That Is Called From My Document Class
I'm having a problem with my main project so I've made a small test project to replicate it. The code's included here.

I've created a new .fla called TextboxFromClass.fla that's empty except for a linked in Document class called TextboxFromClass.as

I've created another class called TextboxClass.as

Everything's linked and referenced properly - when I run it there's no errors and I get a trace output "Got here" but only the TextField for the Document Class displays ("From the Doc Class"), not the one from the TextboxClass ("From the TextBoxClass Class").

I'm guessing it's a scope thing but I'm fairly new to ActionScript 3.0 so I'd appreciate your help.







Attach Code

//Code in the Document Class (called TextboxFromClass.as

package script
{
import script.*
import flash.display.MovieClip;
import flash.text.*;

public class TextboxFromClass extends MovieClip
{
var inputNameLabel:TextField = new TextField();
var backgroundGreen : int = 0x2E510B;
var foregroundGreen : int = 0x00FF99;

public function TextboxFromClass()
{
with (inputNameLabel)
{
x = 300;
y = 200;
width = 200;
height = 30;
text = "From the Doc Class";
}
var format:TextFormat = new TextFormat();
with (format)
{
font = "Arial";
color = foregroundGreen;
size = 20;
}
inputNameLabel.setTextFormat(format);
addChild(inputNameLabel);

//This should output some text like the above - but doesn't
var abc:TextboxClass = new TextboxClass();
}
}
}

// Code in TextboxClass.as

package script{
import script.*;
import flash.display.MovieClip;
import flash.text.*;

public class TextboxClass extends MovieClip {
var t:TextField = new TextField();
var backgroundGreen : int = 0x2E510B;
var foregroundGreen : int = 0x00FF99;

public function TextboxClass() {
with (t) {
x = 300;
y = 250;
width = 300;
height = 30;
text = "From the TextBoxClass Class";
}
var format:TextFormat = new TextFormat();
with (format) {
font = "Arial";
color = foregroundGreen;
size = 20;
}
t.setTextFormat(format);
addChild(t);
trace("Got here");
}
}
}

























Edited: 02/09/2008 at 07:42:24 AM by SoCentral2

Applying A Custom Class To An Object In The Document Class...
How's it going guys. I just started learning Actionscript 3.0 and so far not bad. However, I'm having trouble applying custom created classes to objects in the main document class. I'm using Flash as the application, however there is no timeline scripting involved. I loaded the document class called Main.as:

package
{
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.display.Loader;

public class Main extends MovieClip
{
private var _redBox:Loader = new Loader();
private var _redBoxLink:URLRequest = new URLRequest("images/redbox.jpg");
public var buttonScaleHover:ButtonScaleHover = new ButtonScaleHover();

public function Main()
{
_redBox.x = 100;
_redBox.y = 100;
_redBox.load(_redBoxLink);
addChild(_redBox);
}
}
}


Now, what I'm trying to do is apply this class named ButtonScaleHover.as to the _redBox in the document class. Here is the code for ButtonScaleHover:


package
{
import flash.display.Sprite;
import flash.events.MouseEvent;

public class ButtonScaleHover extends Sprite
{
private var _xScale:Number;
private var _yScale:Number;

public function ButtonScaleHover()
{
trace("The ButtonScaleHover Class is being loaded");
_xScale = this.scaleX
_yScale = this.scaleY
this.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
this.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}

public function onRollOver(event:MouseEvent):void
{
this.scaleX *= 2;
this.scaleY *= 2;
}

private function onRollOut(event:MouseEvent):void
{
this.scaleX = _xScale;
this.scaleY = _yScale;
}
}
}


I tried using
_redBox.ButtonScaleHover();in the document class after i added it to the display object list. However, it didn't work. Basically, I'm just trying to apply a custom class to an object(in this case the loader). Thank you guys very much in advance.

Button Class Affect The Document Class
I want it so when you click the button, it can make the movie go to the next scene or change a variable in the document class. I can do it on the timeline but I want it as a class instead

And it would be cool if I could figure out how to make seperate packages just for functions and variables so I didn't have to write it all in one document, I just don't want to code in a big pile after I heard you can do this


Cheers

When Should I Use Document Class And External Class Files?
Hello all,

I was recently sent on an intensive three day Actionscript 3 course by my employers - it was fantastic and gave me a great understanding of the fundamentals of coding with Actionscript.

I have one question that I wasn't really able to raise during training, the topic was touched on briefly but wasn't explained in any detail.

When should I use document class files and external class files? If I understand it correctly, creating Linkage with an element in my library then creates a class file, and that file should contain specific functionality relating to the element. For instance, if it was a movie clip in my library that is used to contain loaded product images, then the associated external class file should contain the code that handles the URLRequest and the Loader, plus any extra functionality such as Event Listeners and a function for dragging and dropping of the MC. When I want to access that functionality, I call the function in my class file from my main movie and pass it the correct parameters. Am I on the right track here?

When should I use the document class? I know how to set a document class, and going by my previous logic, I imagine it's used to contain global functions that may be required (such as exiting the movie, file handling etc). Am I correct?

One more - say I'm using an external class file - do I need to import it on the first frame of the actions layer, or can I import in my document class?

That's it, a little clarification need really.
Thanks in advance.

Problems With Document Class Interacting With Another Class
Here is my problem:

I need to have a menu on the bottom of the screen to have mouse overs / on / off states. When the user mouses over a button I need to have the slide name change in the text field on the Stage, when they mouse off, the Slide name of the button with the on state should be displayed. When the click on it, a slide should load.

I have a Movie Clip with a linkage ID: Nav Button in the library that has timeline animations with labels: over, on, off, and passed and onBut that makes the button change states.

I have a Document Class(Presentation.as) that creates instances of the external class NavButton class (NavButton.as) with the values it received from XML.

When user mouse overs a button I need a text in the textField that is created from the Document class to change value. but I can't access that text field from the NavButton class.
code from Document Class: Presentation.as

public var pageTitle:TextField = new TextField();
pageTitle.x = 500;
pageTitle.y = 500;
if (sStatus == "on"){
pageTitle.text = sTitle; // works! sTitle comes from XML
}
addChild(pageTitle);

code from NavButton.as

public function onButtonOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
////NOT WORKING, need to assign this text value to the text field on stage!
stage.pageTitle.text = this._btnTitle;

}

public function onButtonClick(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("on");
////NOT WORKING, need to call this function in document class
createSlide();

}
Also, once the user click on the button I need another slide to load so I need to call a function in the document class to start loading that data from XML.

So I am having few problems, for about 5 days already. Let's say my hair is in place but I really really want to know how to do it.

1). How to assign values from the mouseover function of the NavButton class, to the textField that was created in the Document class? So that it changes when u mouse over and goes back to the default value when it's off.

2). How to call a function in the Document class from the mouseClick function of the NavButton class, to start building out the rest of the info.


I tried having a textField placed manually on stage with a different name, but still I can't access it from the NavButton class!

My code is attached.

Thank you very much for your help!
-D.

How Do I Call A Method Of The Document Class From Another Class?
I am creating instances of another class from inside my document class. I want these instances to communicate with the document class, how is this accomplished in AS3?

For example, the document class creates a series of boxes with something like:

var box = new Box();

The document class can now call methods of box with box.method(). The question is how can box call methods within the document class?

Reading Document Class Variable From A Class
I have a document class that establishes a variable called "_captioning". The document class then loads a button class that on attachChild needs to check to see if _captioning is set to true or false. I can load this class and can trace strings being generated inside the class but I can't target the _captioning variable outside of it in the document class.

I just need to see how I can get this button class to read things in the document class.

Accessing Document Class From Static Class?
I am building a family tree like tree in flash.

I have a package TreeManager which holds all my classes.

The document class TreeManaager.Tree controls adding new nodes to the stage.


ActionScript Code:
public function addProfile(relationship:Object):void
{
    profile = new Profile();// create new profile

    var align:Alignment = new Alignment();//make Alignment object
...

The profile class controls all the internal node functionality.

Question - If I have a button in my node MC (profile class) which should add a new relationship (i.e. call addProfile) how to I do this?


ActionScript Code:
public class Profile extends MovieClip {
       
public function Profile ():cool:
{
    this.addEventListener(MouseEvent.CLICK,Tree.addProfile);

This always throws an error. I can just add the buttons events from the document class, but it would be helpful to know if you can access the document class from a packaged static class?


ActionScript Code:
// add button events
profile.mother.addEventListener(MouseEvent.CLICK,addRelationship);
profile.brother.addEventListener(MouseEvent.CLICK,addRelationship);
profile.son.addEventListener(MouseEvent.CLICK,addRelationship);

AddChild From Class Called From Document Class
Hey all,

I've recently found the disadvantages of adding code to the timeline and the great and beautiful advantages of moving them to the document class and using external classes to hold my code, so areas of this i'm quite new with this still.

Im having a bit of trouble with adding a MovieClip from the library to the stage from a class which is called from the document class.

The document class imports the new class and creates the instance, this is all fine as i can see the trace statement from the second class.

The following code below works when in the document class... which it should do and is the way i've always used to add a child to the stage

ActionScript Code:
// imports etc + code below wrapped in constructor

var testInstance:Visual_Scale3 = new Visual_Scale3();
addChild(testInstance);

But if i was to use the same code in the second class called from the document class nothing happens, here is my second class

ActionScript Code:
package uk.co.website.scale
{   
    import flash.display.Sprite;
    import Visual_Scale3;

    public class Scale3 extends Sprite
    {      
        public function Scale3() {
            trace("Scale3 class loaded!");
           
            var testInstance:Visual_Scale3 = new Visual_Scale3();
            addChild(testInstance); 
        }      
    }
}

All i see is the trace statement "Scale3 class loaded!", im guessing its something to do with not being able to locate the MovieClip, Visual_Scale3 from the timeline.

Thanks in advanced,
alex

Problems With Document Class Interacting With Another Class
Here it goes:

So i need to have a menu on the bottom of the screen to have mouse overs / on / off states. When the user mouses over a button I need to have the slide name change in the text field on the Stage, when they mouse off, the Slide name of the button with the on state should be displayed.

So I have a Movie Clip in the library that has timeline animations with labels: over, on, off, and passed and onBut that makes the button change states accordingly.

I have a Document Class(Presentation.as) that creates instances of the another class NavButton class (NavButton.as) with the values it received from XML.

When user mouse overs a button I need a text in the textField that is created from the Document class to change value. but I can't access that text field from the NavButton class.
-----------------code from Document Class: Presentation.as
public var pageTitle:TextField = new TextField();
pageTitle.x = 500;
pageTitle.y = 500;


if (sStatus == "on"){
pageTitle.text = sTitle;
}
addChild(pageTitle);

-----------------code from NavButton.as
public function onButtonOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
////NOT WORKING, need to assign this text value to the text field on stage!
stage.pageTitle.text = this._btnTitle;

}
Also, once the user click on the button I need another slide to load so I need to call a function in the document class to start loading that data from XML.

public function onButtonClick(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("on");
trace(this._btnId);

////NOT WORKING, need to call this function in document classto create a slide
createSlide();

}


So I am having few problems, for about 5 days already. Let's say my hair is in place but I really really want to know how to do it.

1). How to assign values from the mouseover function of the NavButton class, to the textField that was created in the Document class? So that it changes when u mouse over and goes back to the default value when it's off.

2). How to call a function in the Document class from the mouseClick function of the NavButton class, to start building out the rest of the info.


I tried having a textField placed manually on stage with a different name, but still I can't access it from the NavButton class!


My code is attached.

Thank you very much for your help!
-D.

Reference The Document Class From Within Another Class?
OK, I am learning AS3 and I have seen variations of this question asked a thousand times but none seem to do the trick for me...

I have made a document class and some other custom classes that are working nicely. I am having trouble accessing a movieclip instance on the root timeline! (duh) I want _level0 back! I feel like I am being stupid, but i have tried using parent, root, stage, the name of my document class, etc.

It's a guess but the trouble seems to come from the fact that I am linking movieclips in my library to a class, but then physically placing them on the main timeline rather than creating instances via the "new" keyword. I do this out of convenience for design control. Any ideas out there?

thanks for any helps.

Get Class To Run A Function That Is On The Document Class
hey

i'm using a document class called DocClassGraph
and in DocClassGraph i have a function called loadJSON.

then
var graph:GraphClass;
addChild(graph);

and now want to run the function loadJSON from the Graph Class.
i have tryed parent.loadJSON("data2.json");
but this does not work?????

Can't Instantiate A Class From Within My Document Class
My classes work when I link them to Movie clips, but when I try the below code I get an error:

package {
import flash.display.MovieClip;
import flash.ui.Mouse;
import Enemies;
//
public class VertShooter extends MovieClip {
public var _enemy:Enemies;
//
public function VertShooter () {
trace ("VertShooter Class");
Mouse.hide ();
//
_enemy = new Enemies();
addChild (_enemy);
}
}
}
/////////////////////////

Please help, thanks!

Extending A Class That Is A Document Class Of A Swf/fla
Hey
I have a question about extending or subclassing classes in as3 and flash.
I have a fla project that has its Document Class set to an as3 class called Portrait. B/c the portrait class is a document class of my fla project, it directly accesses all movieclip objects in the scene.

I want to create a new project that extends this project. By that, I mean I would like to extend the functionality by adding more movieclip objects to the scene and more script, but keep the original source code. Is this even possible?

I tried writting a new class called PortraitExt which extends the Portrait class. And I duplicated the original project, added some new objects, and set its document class to PortraitExt. However, when I tried compiling, it complained about the orignal Portrait class not being able to find the movieclip objects that are contained in the scene.

Thanks!

Class Communication Through The Document Class?
Hello all. I've been running into the problem of classes, their variables, and how they are able to interact.

Example:
I have a document class which instantiates two different classes, each with their own public variables. I can call these variables from the document class, but not from one class to the other.

Document class (generic test code)
Code:

var test01:MyClass = new MyClass();
trace(test01.myVar) // outputs: "This is your FIRST test string"

var test02:MyNewClass = new MyNewClass();
trace(test02.myDifferentVar) //outputs: "This is your SECOND test string"


Now say I'm in, "MyClass"
Code:

// here I'm trying to reference an instance of "MyNewClass()" that is in my document class
trace(test02.myDifferentVar) // outputs: undefined


I was under the impression that I would have access to anything in my document class from anywhere in any other class. Is there a way of referencing to the document class, as in its instance name or something?
Code:

// here I'm trying to reference an instance of "MyNewClass()" that is in my document class
trace(*DocumentClass*.test02.myDifferentVar) // outputs: undefined



This is turning out to be a big problem, but I hope there is an easy fix for it. Does anyone have any suggestions?
Thank you,
-EthanG

[F8] Symbol Size Bigger Than Max Stage Size - How To Edit/view?
Newbie Alert!

I am trying to edit a FLA file for a sliding timeline and the main background image with the details (years, images text) is 23960 px wide and I cannot scroll the main stage area all the way to the right to edit the contents. How can I do this please?

Thanks.

Broadsword1967

Change Stage Size (not Scale) Based On Browser Size?
Not sure this can be done. I've looked through LOTS of resizing tutorials, but they don't do exactly what I want, and I'm not sure it's possible.

Basically, I have a slideshow that loads from xml and fades in a variety of sizes of images in random positions. I'm trying to set it up so that the swf (which is in a div tag in an interface) will resize depending on the browser size and will use the NEW stage size to determine the x/y position of the images (without resizing them) and will skip any images that are too big for the stage size...

Any ideas if this is possible? Dynamically sizing and determining the "working area" of a swf based on the browser/div size?? Any tutorials out there?? I can figure out the code, I just need to know where to start...

THANKS!!!!

[CS3] Document/stage Height - Problem
I already posted a thread in Flash 8 but now realise this might have been the wrong forum - so apologies for "cross-posting"! Feel free to delete my previous post in other forum.

The problem...

I have converted a very long technical document from PDF to SWF which works quite well but if I wish to reduce or increase the FLA document size (over 2880px), it wouldn't allow me. e.g. this particular document's height is about 4400px and flash opened it without issues but if I wish to reduce the height to say 3000px... no luck!

Is there a way of setting the document height that's more than 2880 (either within Flash or any other 3rd party tool including command-line) - basically "forcing" Flash CS3 to accept more than 2880px?

Many thanks in advance!

What Document Size Do You Use?
If you are doing a movie for a 15"monitor (800 x 600), what movie size should you use?

I know you can use Javascript along with the fscommand to make the site full screen, but I want to get as close as possible so that background images will not be stretched too far.

Thanks
Graeme

Document Size
Can anyone pls tell me what size i should make my flash document to make it look like this flash website - http://www.johnmayer.com/ ???

Document Size
Can anyone pls tell me what size i should make my flash document to make it look like this flash website - http://www.johnmayer.com/ ???

Document Size
Can anyone pls tell me what size i should make my flash document to make it look like this flash website - http://www.johnmayer.com/ ???

Document Size?
Hey everyone,
I'm VERY new to webpage construction....what should I set my document size to in order to display properly? i.e. 550px by 400px??? bigger??? Whats the norm?

[help] Document Size
what size do I make my document so that there won't be a scrollbar vertically or horizontally but the whole page is the stage? This is for when I turn the flash doc into a website. Please help. If you didn't understand just ask me to restate it or something.

Thank you for your time and help

Document (re)size?
I made a flash movie with a white bg at 1024 X 768 pixels b/c I didn't want to run out of room--figured I didn't have to occupy the white space I didn't need, but better to not run out of width to the right.

I tried resizing the document later after I saw it on the web (as it looks different than when you just test your scene or movie in the flash environment). In my case, the test environment in Flash is how I want it, but on the web, everything appears lower than I'd like. Is the solution to resize? Is there even a way to resize after the movie is built so that everything shifts upwards?

Or perhaps I need advice on the best way to go about sizing your document in the first place.

Thanks.

[F8] Document Size...
I'm working with many movie clips with-in movie clips...i was wondering is there a way for the document size to leak through the movie clips, so i can see exactly what i'm cropping? If you don't understand my question i've attached a ss of flash i messed with in photoshop to illustrate my point....

http://img513.imageshack.us/img513/5075/cropgg3.jpg

if you look the white box is the actual doc. size...is there anyway i can get the doz size to leak through the layers i have above it? This would save me ALOT of time....thnx ahead of time...

`pj

Document Size
I was given a project just recently to take an 8.5x11 (2550x3300 pixels) print ad and convert it into a flash animation. although when I go to the dimension sizes it wont allow any thing larger than 2880x2880 pixels. Does anyone know if there is a way for me to achieve this or am I out of luck?

Thanks!

Document Size
Hi, I am a new Flash user and I have a very basic question. I would like to know which one is the document size to see an animation or a web page on a full screen.
For the animation I am using all pictures imported from Photoshop.
Many thanks in advance for your help!

Document Size
I have a novice question. I have an animated symbol that I created in flash. It sits right in the middle of the flash document. The document is 372px X 253px and there's a lot of white space. When I embed this flash object in my web page it is way too large because the document size is too large.

If I change the document size to 100px X 100px then my symbol ends up not being in the white space of the document and I can't figure out how to move it, without doing it frame by frame which would takes many many hours to do.

So, experts, how do I do this?

HELP:> Document Size
Hi Kirupians
I'm a noobie rookie designer and I started working on a website for a friend/client.
I need some help with this issue: I like the idea of background pictures sliding on different pages of the site, but I don't want to see the picture outside of the boundaries of the Flash document when the new picture comes in. I'm still able to see the picture outside of the frame of the menu and I'd like to limit the pic to the inside of the frame.

Here's the link (major work in progress, but you can see the draft for Discography and go back to Home and see what I mean)..

thanks

http://www.emunityrecords.com/4mula/bradsite/index.html

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