The [embad(source='')] Thing Will Only Work In Document Class?
So if I want to use an embedded MovieClip, I have to pass the instance to my internal classes from the Document Class?
I tried to use "[embed(source='')]" but not working in a non-doc-class....
Just want to make sure whether it's the truth.
KirupaForum > Flash > ActionScript 3.0
Posted on: 10-19-2008, 10:52 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Urgent, Desperate PHP Thing... Source Included...
hi all,
i'm givin all the source and my question is simple... what i want is, there lies two dynamic text boxes which should display the info that has been submitted by the users from the below fields....
but i don't know the php side and nothing updates after i push the "modify" button....
by the way those files are taken from hi-score tut... but my aim is completely different...
IT IS SIMPLE i just want to be able to update the contact infos and by the help of those files without FTPing, without uploading .txt files(that's a classic one that everybody does) or using them as a source...
just by the help of that php file being able to update the info in seconds....
thnx all.... and i'm desperate and worse, it's urgent... i don't think that writing a correct or simple10-15 lined php should be so hard for pro-people...
thnx.... and thnx....
Embad My Flash Into Another Website
Short question, I have a nice flash graphic, and another website would like to use it on their own website. Is their any way that they show this on their website but using the one on our server (because we updating it often)
Thanks, Alex
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
Any Open Source Countdowns?" Xxdays. Xxhrs. Xxmins To Go" Type Thing
Can anyone recommend any good open source solutions for a countdown. I need to put one on the head of a web page saying xxx days xxx hrs and xxx mins to go.
Flash or Javascript are fine but I suspect Flash would be much easier for me to customise
Any assistance or guidance would be most welcome.
Thanks in advance
Class Thing?
how do I move hundreds of instances with different names around? A nice example would be good, with two differently named instances moving smoothly across the stage through code that doesn't call them by instance name. Must be a class thing right?
Hi. How Do You Name You As Class Source Folder?
I've been giving it some strange names like src, ascrt, and whatever else. Always been willing to come up with a beautiful name that I'd use throughout my works but can't figure out what it could be.
What do you name that folder?
Document Class
Hiii.
I'm trying the very simple Document class textfield in the Properties dialog box, where I add in the value: Main
I save that as myFlashCS3.fla. There's nothing else in that .fla.
In that same dir, I have Main.as, which has this code:
Code:
package
{
import flash.display.MovieClip;
public class Main extends MovieClip
{
public function Main()
{
trace("holla");
}
}
}
I publish my myFlashCS3.fla and the Output shows nothing. I was expecting it to show: holla
What am I doing wrong?
Thank you.
Document Class
In AS 3.0 using document class can we access MovieClips in frame other than first .... If so how to refer to movieclips in some other frames
More Than 1 Document Class?
Is it possible to attach more than one class to a project in Flash? I have one .as file attached as a document class that extends the movie clip and I want add an alert box class that extends the sprite. How do I go about doing this?
Does anyone know of a tutorial on how to pull xml data and place it in an alert box?
Thanks,
Mike
Help With Document Class
Hi guys, i have 2 swf files, Loader.swf & Shell.swf. They both have a document class each...
Loader.swf's document class "PreLoader"
ActionScript Code:
package com.KB
{
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.media.*;
import flash.net.*;
import flash.text.*;
import flash.utils.*;
public class PreLoader extends MovieClip
{
public var TEST_TEXT:String;
private var SWF_LOADER:Loader;
private var SWF_PATH:URLRequest;
public function PreLoader()
{
TEST_TEXT = "hello there";
SWF_PATH = new URLRequest("Shell.swf");
SWF_LOADER = new Loader();
SWF_LOADER.contentLoaderInfo.addEventListener(Event.COMPLETE,LOAD_COMPLETE);
SWF_LOADER.load(SWF_PATH);
}
private function LOAD_COMPLETE(e:Event):void
{
trace("load complete");
addChild(SWF_LOADER);
}
}
}
and here's Shell.swf's document class "Shell"
ActionScript Code:
package com.KB
{
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.media.*;
import flash.net.*;
import flash.text.*;
import flash.utils.*;
public class Shell extends MovieClip
{
public function Shell()
{
test();
}
public function test():void
{
try
{
trace(PreLoader(this.parent.parent).TEST_TEXT);
}
catch(err:Error)
{
trace("there was an error");
}
}
}
}
the whole idea is PreLoader loads shell.swf and adds it to the stage and i want to be able to refer a variable or call a function from shell.swf document class to the PreLoader document class. Its easy to do this in a keyframe on the main timeline but using a document class is a little different, help please!
Document Class
Hi,
I just started with AS3. I've made some simple tests and everything is working fine. Now what my question is about, I've made my Document class called Main.as In that class i've imported a subclass of me. Now is there any way to access a movieclip on my stage in my subclass?
Thanks in advance...
Document Class
Actionscript 3/Flash 9 introduces the Document Class. I think I understand the concept that it enables you to link an external .as file which then acts as if it is the _root class. Firstly, is that correct? Secondly, given that you can create code in external .as files in ActionScript 2, what's the practical advantage of this new features over AS2?
Kev
Specifying A Document Class
I just started read the book "Foundation Action Script 3.0" and i got to "Specifying a document class". I create a document.fla and enter a Document class called : Document.
I then create a Document.as and i write:
package {
import flash.display.MovieClip;
public class Document extends MovieClip {
public function Document () {
trace("Hello World");
}
}
}
Bit i get a 5007 error in Line1? Can anyone help :-)
But when i Test Movie I get a 5007 error
Help With Document Class
heres my code
Code:
package{
import flash.display.Sprite;
import flash.display.MovieClip;
public class Tools extends Sprite{
public function Tools()
{
}
var window1:MovieClip = new MovieClip();window1.width=950;window1.height=150;addChild(window1);
var window2:MovieClip = new MovieClip();window2.width=950;window2.height=150;addChild(window2);
var window3:MovieClip = new MovieClip();window3.width=950;window3.height=150;addChild(window3);
var window4:MovieClip = new MovieClip();window4.width=950;window4.height=150;addChild(window4);
}
}
my problem is it gives me undefined property calls, the var definition for the movieclips are ok but after that it doesnt recognize the var for giving it a property and it gives an error, i also get an error in addChild as an undefined method, help would be very greatful plx
The Thing Won't Work. HELP
I have a timer.
When the timer reaches 0 the main timeline has to go to frame 3.
So I use this code in the actions layer frame.
Code:
if (time=0) {
gotoAndStop(3);
}
This code seems just fine but when I test the movie the time left is 0
(when it has to be 30) and I am in frame 3 (when I still have to be in frame 2) So I try to use _root and _parent in the code but that won't work. I also tried to put the code into an MC. That won't work either.
Anybody got another idee?
How To Get Whole Thing To Work
hi,
i have been trying my hands on scripting for a while....
though going through some tutorials, forum examples, attribute defination..im able to make sense of the script to which i couldnt earlier
but now my problem lies how do i get all the exapmles to work ..
in the sense the tutorials i done are bits and piece...like menus, then moving a clip on x cooridnate using ease in, ease out effect... and so on..but all the things done are in action scripts where in the scripts is on the clips and some on 1st frame
before trying the scripting part i used the basic motion tween and shape tweening effect for animation to and then follow up by getting other things with layers
for ex. how would i know when a box with ease in effect is over i want the menu top appear on stage ....then some fancy scripted effect to follow
is there a way in script that tell to follow sequence and appearing of animation on stage and then other clip or animation appear on stage after certain scripted clip code is executed...
any help would be appreciated....
or may a tutorial link that shows how to get it done
with regards,
babun
How Exactly Does This AS Thing Work?
Okay I will admit I am a tweener. Well, I used to be. Back when I found Flash in 97 I thought making a blue circle tween into a red square was the coolest thing I had ever seen. I made tons of stick figure animations and tweened blood and rolling sick heads.
After being in the military, getting married, kids and growing up a little, I finally came back to Flash. Using MX Pro 2004 I found a metric butt ton of new options. Packages, AS 2.0... wow! AS can do anything! And you can write all the action script in one file and call it from the timeline? I don't have to include anything in the movie itself? WOW!
But I do don't I? Some things just can't be put in an AS file, somethings just have to be attached to MCs and buttons right?
So I have just completed (minus some small tweaking) my first official Flash done all by myself. It is a tiny littel 5 frame Point and Click type thing. Nothing too major, except that it has over 400 MC instances, and just over 3000 lines of coding....
From tweeing to writing Action Script... I will never learn how to do it the easy way. And to make matters worse I learn a fragment of AS2.0 and I hear they are going to totally change it and release AS3.0??? I will never get on that learning curve!!!
Anyway... I am really not asking for any specific tutorials, or code snippets, etc...
What I would like to try to understand though is what can (or can NOT, if that list is smaller) go into a stand alone AS file?
If I create an AS file named Game_Engine and in frame 1 I put something like
require Game_Engine (or however you call it)
I am pretty sure I can put all my variables in there, but what else? Are there any limits?
~MoN
Darndest Thing---load Movie Class
I have a loop that loads about 60 graphics for a dynamic MovieClip rollover function.
When I rollover the button on my computer, it shows the rollover state.
When I upload it to the server, it says it can't load the rollover state.
I have tried:
1. renaming the files
2. putting the files in extra folders to avoid confusion
3. using a different variable to call the class.
I would appreciate your assistance.
Thank you,
Emma
Attach Code
for (i=1;i<=26;i++){
//it names the variable from an Array
thisvariable=theAlphabet[i-1]
newname=this.attachMovie("generic", thisvariable,i);
//newname._alpha=0;
newname.createEmptyMovieClip("container", 1);
newname.createEmptyMovieClip("rcontainer",this.getNextHighestDepth());
//newname._y=100;
//this.newname.rcontainer._visible=false;
var K:loadMovies=new loadMovies();
K.loadingMovie("theNormal/"+thisvariable+".png", newname.container);
K.loadingMovie("theRollOver/"+thisvariable+".png", newname.rcontainer);
////I turn the rollover feature off until the user rolls over the mc.
newname.rcontainer._alpha=0;
}
}
Document Class Question
What's the difference between having a class be the 'Document Class' and just importing it on frame 1 in the timeline?
How Do I Avoid Using The 'Document Class'?
Hey all,
I've made a game in as3. I have one main .as file that runs the game. That .as file loads all the graphics, creates other classes, etc.
To instantiate the main class, I just added it to the 'Document Class' option in CS3 (if you start a new project and click on the stage and then go to properties, it allows you to add a document class. Now I assume that when the swf file is run, it automatically instantiates the class and then the game goes from there.
My question is this : How do I not use the document class option? I'd like to instantiate the class myself.
For example, on frame 1 of the swf file, I tried somethign liek this which didn't work :
Code:
import MainGameClass
var foo:MainGameClass = new MainGameClass();
The code ran perfect before when I used the document class option. Now by changing it to the code above I get tons of errors (50+).
Every error reported is like :
1120: Access of undefined property timeleftTextField.
1123: Access of undefined property livesleftTextField.
etc...
What do I need to do to make this work? I assume this is because my MainGameClass is not at the same level as before....
Thanks in advance for taking the time to help me!
Ryan Ritten
Question On Document Class
I'm still getting my feet wet with Actionscript 3, so please forgive any stupidity here :b.
I'm still currently coding some of my work in the timeline because I haven't fully mastered the language yet, so here's my question:
I would like to make a document class and put the following code in it to resize my content on every new frame instead of inserting the code into my timeline on every new frame that needs to be repositioned.
Code:
this.stage.addEventListener(Event.RESIZE, resizeHandler);
function resizeHandler(event:Event):void {
position();
}
position();
function position() {
example.x = stage.stageWidth/2;
example.y = stage.stageHeight/2;
}
I've tried a few attempts at making a document class but just get errors galore. This seems like it would be rather simple but I'm just not seeing the obvious.
Can anyone help me sort a solution out?
Preloader & Document Class
Hi.
When I start a Flash Project, I usually write the Document Class and link it to the .FLA. It obviously works and I think it's the best way to do everything.
The problem is ... How to implement a preloader?
The most obvious answer is: move everything is on the first frame to the (for example) 15th one. Then make the classic "looping code" (that shows the progress bar or the bytes loaded etc.) directly on the frames.
But the Document Class is loaded on the 1st frame and every target called by the Document Class stays on the 15th frame!
So I ask you: What technique do you use to make live together a Document Class based project and a preloader?
Thank you.
Document Class Confusion
Hey new to flash so please forgive my ignorance, but I have a image gallery I built using the document class and xml and I want to know how to add it to the stage via a button. I have a fla file I'm working on and I want the gallery to appear when the gallery button is clicked and to disappear when another button is pushed. I know I have to import the class but what after that? Thanks.
I'm Stuck On Document Class
I have a preloader on frame 1 of the timeline.
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
if (total == loaded) {
gotoAndPlay("start");
this.removeEventListener(Event.ENTER_FRAME, loading);
}
}
stop();
I also have an example of a document class which I found on the forum from cancerinform(moderator).
package {
import flash.display.MovieClip;
public class classRoot extends MovieClip {
public function classRoot() {
}
}
}
When I test the movie I get this message:
Discription
1046: Type was not found or was not a compile-time constant: Event.
Source
function loading(event:Event):void {
If I take the document class away then the swf plays fine.
I just need to understand why this is happening.
Preloader And Document Class
Hi,
I have a fla associated with a Document Class and I can't get a preloader to load function properly in terms of intializing the .as class--
This is the error I get:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MyContentNew2/init()
at MyContentNew2()
I tried two different methods--One with a separate fla entitled preloader with this code:
Code:
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("finished4experiment.swf"));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}
function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(l);
}
This doesnt seem to work at all---The other method I tried was to put the preloader code within my fla file by adding an additional scene which I put prior to the main movie---Heres the code for that:
Code:
stop();
var finished:Boolean = false;
addEventListener(Event.ENTER_FRAME, loader);
function loader(event:Event) {
var total = stage.loaderInfo.bytesTotal;
var loaded = stage.loaderInfo.bytesLoaded;
var percentage = Math.round(100*loaded/total);
myPreloader.bar.width = 4*percentage
myPreloader.loadingtext.text = "Loading: "+String(percentage)+"%";
if (loaded >= total&&finished==false) {
setTimeout(end_preload,2000);
finished = true;
}
}
function end_preload():void{
removeChild(myPreloader);
gotoAndStop(2);
removeEventListener(Event.ENTER_FRAME,loader);
}
This one kind of works but throws the same error and its obvious that the init function of the main document class isnt being initialized as the variables I've assigned there which control image scale etc arent scaling etc.
Does anyone know why the preloader would result in the main document class not being initialized?
Thanks,
----Yvette
Extending The Document Class
I've build a flash FLA project which has the class "MyGame" as its document class which all works great.
Now I want to make a slightly different version of it with a few bits of extra functionality, so I've got a new FLA, and want it to use an extended version of MyGame as its document class, let's say it's called "MySlightlyDifferentGame".
So the code for MySlightlyDifferentGame looks like this...
code:
package {
import flash.display.*;
public class MySlightlyDifferentGame extends MyGame {
public function MySlightlyDifferentGame(){
super();
// stuff here...
}
}
}
Trouble is, MyGame is now not recognising any objects on the stage of the FLA any more (they're all in the same place as they were in the original).
So for example I have a button on the first frame called "play_btn", and when myGame tries to reference it, I get:
1120: Access of undefined property play_btn.
Any ideas???
How Do You Refer To The Document Class?
I know that this must be an elementary problem, but I'm wondering how to refer to the Document Class that is instantiated by Flash?
I create a Flash AS3.0 project and create a class called "Main". I then edit the Publish settings and set the Document Class to be "Main".
Now how do I refer to the functions in this Main class?
Any help would be greatly appreciated!
|