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




Using Class Defined In External SWF



Hi guys I have two SWF files loader.swf and external.swf, external.swf is sitting on a remote server and I load it up from loader.swf using MovieClipLoader. external.swf includes a class definition for SomeClass by including a .as file, which also sits on the remote server. External.swf defines a method that returns an instance of SomeClass. Once I've loaded up external.swf via loader.swf I can call the function that returns an instance of SomeClass. The problem is that laoder.swf seems to require a local copy of the as fiel that defines the class, rather than being able to receive the information it needs from external.swf, I really need to keep this class definition on the remote server, and not have a copy of it locally. Is thre any way I can encapsulate this within external.swf? I'm free to cahnge whatever I like. This is all in AS2 by the way. Many thansk for taking the tiem to read this and any help or pointers is much appreciated.



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 07-07-2008, 01:31 PM


View Complete Forum Thread with Replies

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

Classes May Only Be Defined In External ActionScript 2.0 Class Scripts
an external .as file.

Code:
class myHover extends MovieClip{
/*========================================================*
variables
*========================================================*/
var speed:Number=1.8;
var big:Number=150;
var small:Number=100;
/*========================================================*
functions
*========================================================*/
function goBig(){
this.onEnterFrame=function(){
this._xscale+=speed;
this._yscale+=speed;
//if(this._yscale || this._xscale>=big){
if(this._xscale>=big){
delete this.onEnterFrame();
}
}
}
function goSmall(){
this.onEnterFrame=function(){
this._xscale+=speed;
this._yscale+=speed;
//if(this._yscale || this._xscale<=small){
if(this._xscale>=small){
delete this.onEnterFrame();
}
}
}
}
.fla file


Code:
#include "myHover.as"
var mcNorthern:MovieClip;
/*========================================================*
event handlers
*========================================================*/
mcNorthern.onRollOver=function():Void{
this.goBig();
}
mcNorthern.onRollOut=function():Void{
this.goSmall();
}
returns:
Classes may only be defined in external ActionScript 2.0 class scripts

What am I doing wrong?

Classes May Only Be Defined In External ActionScript 2.0 Class Scripts.
i try to use the BitmapExporter 2.2.
i inserted the .as file into the first frame in my fla but when i try to test movie i get
"Classes may only be defined in external ActionScript 2.0 class scripts."
since i am not expert in extensions - what did i do wrong and hoe can i properly use this extension?

Classes May Only Be Defined In External ActionScript 2.0 Class Scripts.
I am trying to integrate flash and coldfusion. I have been following a tutorial in "Macromedia Coldfusion MX 7" that has given me a good start. However, every time I try to publish the flash file, I come up with the error "Classes may only be defined in external ActionScript 2.0 class scripts." I googled it up and found what others have found to be the problem... (http://www.adobe.com/devnet/flash/ar...mx2004_02.html) that The name of an AS class file must match the name of the class it contains. Well, I think it does...

Inside the NetServices.as file that it is referencing, the line of code that flash has a problem with is: "class mx.remoting.NetServices extends Object"

Inside the flash file...

#include "../../../../coldfusion/NetServices.as" //this is where I have put the file

// Application initialization
if (inited == null) {
inited = true; // to do this only once
NetServices.setDefaultGatewayUrl("<A href="http://localhost:8500/flashservices/gateway") //">http://localhost:8500/flashservices/gateway") // set the default gateway URL
gateway_conn = NetServices.createGatewayConnection(); // connect to the gateway
myService = gateway_conn.getService("coldfusion", this); // get a reference to a service // In this case, the "service" is the /ows/23 directory in web server root
}

Anyways, in both cases, I am using "NetServices" so I don't see what the problem could be.

Any help with this would be greatly appreciated and if you need more clarification on what I am trying to accomplish, please feel free to ask.

Thanks again!

Access Class Defined In "linkage..." From External Class
Hi

Rather strange title hu? Well, I'm trying to access a class which was defined on a library symbol in my main.fla by using the Linkage... dialog. Classname: GrungeTitle, BaseClass: BitmapData.

I'm trying to access this class to build my repeating background on my main.fla (which uses a document class: base.as).

My code of the document class:

Code:
public function init():void {
grungeBackgroundTile = new GrungeTile(300, 300);

var spr:Sprite = new Sprite();
spr.graphics.beginBitmapFill(grungeBackgroundTile);
spr.graphics.drawRect(100, 100, 100, 100);
spr.graphics.endFill();

addChild(spr);
}
This code gets called on the third frame of my main.fla by calling: init();
When I try to draw a simple square in the sprite, the rectangle gets drawn on the stage, when I try to make a fill with a library item then it doesn't display a thing.

Any help?
Thanks

Using Variable Defined In One Class In Another Class, How?
hi everybody. i have a variable (holdFrame) in a class that controls a pause button, so that when the pause button is pressed, the variable stores the frame number where the pause button was pressed. pressing this button takes the timeline to a frame with nothing but the word "PAUSED" and a continue button on it. i have a class for the continue button that needs to call the variable that stored the previous frame number in it, so when the continue button is pressed the timeline is returned to the previous frame.

so how do i make that variable available to the other class and how do i call that variable from the other class? they are in the same package. below is the code for the two classes.

pause button code:

Code:
package lesson
{
import flash.display.MovieClip;
import flash.events.*;

public class PauseAll extends MovieClip
{
public var holdFrame:int;

public function PauseAll()
{
this.addEventListener(MouseEvent.CLICK, pauseAll);
this.buttonMode = true;
}

private function pauseAll(e:MouseEvent):void
{
holdFrame = MovieClip(parent).currentFrame;
MovieClip(parent).gotoAndPlay(MovieClip(parent).totalFrames);
}
}
}
continue button code:

Code:
package lesson
{
import flash.display.MovieClip;
import flash.events.*;
import lesson.PauseAll;

public class ContinueAll extends MovieClip
{

public function ContinueAll()
{
this.addEventListener(MouseEvent.CLICK, continueAll);
this.buttonMode = true;
}

private function continueAll(e:MouseEvent):void
{
MovieClip(parent).gotoAndPlay(MovieClip(parent).holdFrame);
}
}
}

New Object Not Getting Defined Within Class.
Hi. I'm trying to make 500 objects (boxZ0Z0,boxZ0Z1,...) each with a distinct id "i". I'm getting 500 objects: trace for "this["boxZ"+a+"Z"+b].id" returns 500 statements, but each value returns undefined...my helper code calls for:


Code:
import globalMap
var globalMap1:GlobalMap = new GlobalMap();

Code:
class GlobalMap {
var globalMap:Object = new Object();
var b:Number = 0;
var a:Number = 0;
function GlobalMap(){
for(var i:Number=0; i<500; i++) {
this["boxZ"+a+"Z"+b] = new Object();
this["boxZ"+a+"Z"+b].id = i;
a = a+1
trace(this["boxZ"+a+"Z"+b].id)
if(a==250){
a = 0;
b = b +1;
}
}
}

}
help?

How To Access Property Of A Defined Class For Swf
I have a car.fla file. I created a class called Car inside car.as, which handles the manipulation of the symbols in library of car.fla. So car.fla is linked to car.as.

Class Car is extended from MovieClip.


In my main code, I am loading up car.swf by doing this:

var url = new URLRequest(xampp://directory/to/car.swf);
var carSWF = new Loader();
carSWF.contentLoaderInfo.addEventListener(Event.IN IT, this.onURLLoaded);
carSWF.load(url);


But here is my problem. I want to be able to access a property of Car. Say I have a property called var backWheel.

class Car{


var backWheel:Number;

}

How do I access this property?

I tried doing:

var url = new URLRequest(xampp://directory/to/car.swf);
var carSWF = new Loader();
carSWF.contentLoaderInfo.addEventListener(Event.IN IT, this.onURLLoaded);
carSWF.load(url);

var myCar:Car = carSWF.content;
trace("myWheel: "+myCar.backWheel);


This returned an error "Cannot access a property or method of a null object reference." Any suggestions?

Creating A EmptyMovieClip With A User Defined Class
I have a class fully defined, and Im populating an array with emptyMovieClips... How would I go about doing that?
I tried seting the superclass of my class to the MovieClip class, and than just populating the array with instances of my class... after that I called the class method that loads a Jpeg into the clip but it does not function.
Any suggestions? I appreciate it.
thanks

User Defined Class - Properties & Methods
If I create a class and set up one property which is a variable initiated at the start of the class but not within a function or a constructor and I reference the property from the .fla in a for loop as:

Book is the class and myBook is the new object.

myBook:Book = new Book(); // (fla script).

for(var prop in myBook) {
trace(prop);
}

the .AS contains

Class Book
{

var myProp:Number = 0;

function Book() {
}

}

The trace does not return anything. However when I include myProp (the class variable) in a function (other than Book function) and call that function from the .fla then the trace works and I can see myProp.

I would be grateful if someone could explain: Do I need to include Class variables in called functions (methods of the Class) in order for them to be properties of the Class?

thanks in advance

Accessing Variables Defined In Document Class
I am having trouble assessing values established in my document class.

My document class: ZoneViewer.as:

public class ZoneViewer extends Sprite {
private var zone_area_alpha_low:Number=.2;
}

This code exists on a frame within a movieclip on my main timeline:

this.zone_shape.alpha = zone_area_alpha_low;


How do I access the .2 value which is declared in my document class:ZoneViewer.as? "zone_area_alpha_low" is not working.

[AS2] Reffering To This From Function Defined Inside Class
Hello fellow kirupians. Time for me again to ask for you help.
I'll begin with the example code

ActionScript Code:
class className () {    //constructor    function className(targetmc,linkId) {      xxx =  targetmc.attachMovie(linkId,targetmc.getNextHighestDepth());      xxx.onPress = function () {          // this here refers to the newly created mc.         this.startDrag();         intvl = setInterval(updater,200); // this doesnt work         // nor does the flowing because this reffers to the mc I press not to the instace of the class         intvl = setInterval(this.updater,200);      }    }    private function updater() {        trace("Updating + "+getTimer())    }}


My question is how can I set up an interval when I click on a button that is created from within the class.
I need my function updater to keep repeating untill I clear the interval. The only way I can figure out is to give the full path like
this._parent._parent.instanceName.updater inside the setInterval, but although this works I think is just dumb to hardcode the instace name of the class. I could of course try to pass the instance name as a parameter, but I would really love to find out the smart way to do this (by the book).

Thank you for taking your time and reading this.

AS3 - Class Events And Timeline Defined Functions
I'm just wondering, i got used to this in AS2

I make a class


ActionScript Code:
class User
{
    public function User (uid:Number)
    {
        var h = this;
        var xml:XML = new XML ();
        xml.onLoad = function (s)
        {
            if (s)
            {
                h.onReadConfig ();
            }
        };
        xml.load ('somephp.php?id=' + uid);
    }
    public function onReadConfig ()
    {
        // empty function
    }
}


then i do something like this on the timeline code so i could customize every event.


ActionScript Code:
var u:User = new User(20);
u.onReadConfig = function(){
    some_mc.gotoAndPlay('animate');
}


for some reason, if i try to modify the method of the User class, it returns a
1168: Illegal assignment to function onReadConfig. error.

So i was wondering if there were any simple but effective way of listening to the "onReadConfig" event function so that my timeline code would just wait for my user object to finish reading the xml and do whatever it wants.

But if you have any other alternatives on this, i am open to suggestions :-)

How Do You List All The Class Items Defined Inside The SWF File?
Is there a way to list every class item defined inside the SWF file???
I know you can use a class browser thing in FlashDevelop or FlexBuilder, but I have no access to any of those, so I want to figure out to see if that is available via a code...

Thanks...

LoadMovie Cause Problems With OnEnterFrame Method Defined On A Class
Hello everyone

I have just started to work with classes few days ago and i found this problem on my way.

I have defined on a class a method that has to be executed every frame (onEnterFrame), but it doesnt works, the reason for the error is not on the class nor on the way i define the object of that class: its on a loadMovie() statement wich loads a picture on a movieClip. That movieClip is the class parameter, and when i use the loadMovie it stop the onEnterFrame method. Its very rare. To make the example work just put any image on the same folder with the name "Pic1". Thats all. (

Code of an example below
Copy the first code onto an .as file and save it as mySizer.as
Copy the second code on a .fla and save it on the same folder of .as file
Grab any jpg to that folder and name it as Pic1.jpg

Any help would be apreciated
Thanks in advance







Attach Code

class code (mySizer.as)

class mySizer extends MovieClip{
var Target:MovieClip;
function mySizer (my_MC){
this.Target = my_MC
}
function init(){
this.Target.onEnterFrame = this.sizer;
}
function sizer (){
trace (this._width);
trace (this._height);
}
}
--------------------------------------------------------------------
FLA code

var Container:MovieClip = this.createEmptyMovieClip ("Container",1)
Container.loadMovie ("Pic1.jpg")
var mySizer:Object = new mySizer (Container)
mySizer.init();

























Edited: 01/30/2007 at 04:52:03 PM by Quiltron

Call The Methods Defined In The Main Class File From An Externally Loded Swf
Hi All,

I am new to Actionscript3.0 and the OOPs Model. It was easy to call a function on the root from the externally loaded swf using actionscript 2.0.
I want to achieve the same in ActionScript 3.0. the problem is i want to call a method defined in my Main Class which is an external .as file from the timeline of the externally loaded swf. ( eg. The externally loaded swf has got animation and when it reaches a particular frame it calls a function say a play or pause function which is defined in the main class.) how can we achieve this?

Thanks in advance

AS3 - Call The Methods Defined In The Main Class File From Timeline Of Externally Loded Swf
Hi All,

I am new to Actionscript3.0 and the OOPs Model. It was easy to call a function on the root from the externally loaded swf using actionscript 2.0.

I want to achieve the same in ActionScript 3.0. the problem is i want to call a method defined in my Main Class which is an external .as file from the timeline of the externally loaded swf. ( eg. The externally loaded swf has got animation and when it reaches a particular frame it calls a function say a play or pause function which is defined in the main class.) how can we achieve this?

Thanks in advance

User Defined Base Class Linked With 2 Symbols Gives Error #1034: Type Coercion Failed
Hi, I have two movie clips in the library linked to the same base class, Container, with different class names defined in Properties. These clips each contain (nest) several other clips that are also linked to another base class, Contained. Is there something else that needs to be done to deal with nested clips like this? I'm not certain that nesting is an issue, but in a scenario with different symbols I could not replicate the problem. I've attached a simplified version of the problem .fla with the 2 .as files. I'm using the latest version of CS3. The error is: TypeError: Error #1034: Type Coercion failed: cannot convert Contained_AnteriorLeft@1c4ba431 to Contained_PosteriorLeft.

Can I Load And External Url Into A Pre-defined Area Of My Movie?
can i load and external url into a pre-defined area of my movie?
I don't want to use a frameset. I want the site to be all flash.
So, instead of loading another site into a frame, I want to load it (via a button click) into an area that i can define the x and y, alpha, etc.
the site is http://www.laffinsdesign.com/lead3 and I want the sites to open up where the book is instead of popping up wherever.
Thanks, RJ.

Loading External Htm Files Into A Defined Area
I'm wondering if it's ppssible to load rather lengthy external htm pages into a defined area of a Flash site... Basically, I need to see if I can have large htm files load within a small space embedded within a Flash site at the click of a button. As it is now, the htm pages come up in a separate browser, but if I can contain it all, that'll be ideal.

I have preceise text formatting in the htm pages, so if it's possible to load these, that's what I'm curious about.

Any ideas? Thanks.

User Defined External Image Display?
this post can be deleted

Loading External Movie And Jumping To Pre-defined Frame.
Can anyone help with this piece of scripting?

At the end of an animated sequence of my 1st movie I would like to load in a 2nd external .swf file that replaces the 1st movie completely and at the same time jumps to a pre-defined frame of the new 2nd movie. Hope that makes sense..

I have found this related script that was suggested to another forum member (thanks to Benjer)

This goes into a blank movie clip onstage:

onClipEvent(load){
loadMovieNum("second_movie.swf",4);
targetFrame=94;
}
onClipEvent(enterFrame){
trace(_level4.getBytesLoaded());
if(_level4.getBytesLoaded()==_level4.getBytesTotal() && _level4.getBytesLoaded()>4){
_level4.gotoAndPlay(targetFrame);
}
}

I can't get this to work where it replaces the first movie completely and jumps to the required frame. Can anyone give me an idea of what I should do? I tried changing the levels to 0 but this doesn't seem to work - it just plays the imported movie from the beginning each time.

Thanks for any help.


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.

Load External Swf W/ External Doc Class
Hi guys, i'm new here to the forum so please be gentle :-)

I've recently made the plunge to AS3 and the OOP environment and i'm having this little headache... I have two SWFs, a main one a module i want to load in to the main one... both have their own document classes... the Module SWF, in turn accesses several external AS files in the same directory structure as my Main SWF...

Both individually compile and work fine.... but when i load the Module SWF into my main SWF project i get this message:

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

Which i guess is flash trying to tell me that it can't access the Module's SWF's document class?

I have read around on this subject and i think it's something to do with setting the class path for my project... so i did that in the publish settiings of the main flash flash file on the AS3 button, set the class path to include the same folder as the document class for the Module SWF, but still the same error...

Anybody have an idea what could be going on here?

Thanks,

N.

External Class
I am having problems with an external actionscript class which I have previously used with a good deal of success.

I downloaded and used these tutorial source files

I have checked it over and over and cannot figure out what I've done differently this time. Any hints would be fantastic, as it's driving me nuts now!

I have included my source files for reference

External Class
i know this is a stupid probably obvious question but after spending a ridiculous amount of time on it i give up. I have a class lets say Poker in an actionscript file called Poker.as. i want to use this class in an fla in the same directory. i instantiate it in the fla with the following line:
var myVar:Poker = new Poker();

This however gives me the errors:
1046: Type was not found or was not a compile-time constant: Poker.
1180: Call to a possibly undefined method Poker.

I have even tried doing "import Poker;" and that does nothing. What im doing i know works just fine in actionscript 2 but damn this actionscript 3. please help, i know this should be an easy answer, thanks in advance.

How Ot Ass Var To External Class?
Can someone tell me how to pass this? I have this action script in my flash file which is below


Code:
import graffiti.*;
stop();
Global.init();
this.init();

this.graffitiWall.loadWallBg(this.loaderInfo.parameters.i);

import fl.managers.StyleManager;
var tf:TextFormat = new TextFormat();
tf.font = "Verdana";
tf.size= "10";
StyleManager.setStyle("textFormat", tf);
Here is my external file called Global.as




Code:
package graffiti {

public class Global {

public static var jpegQuality:int;
public static var phpUrl:String;
public static var bgUrl:String;

function Global(){
}

public static function init() {

Global.jpegQuality = 75;
Global.phpUrl = "mydomain.com/raw.php";



}
}
}

Now What I want to do is be able to dynamically grab a variable using loaderInfo for my Global.phpUrl.

For some reason I cannot grab the variable from the embed parameter, when I try to use it, it really screws me up.


So here is my question, how do i get Global.phpUrl to grab my dynamic variable in the external class.

Thanks.

PaulB

<mod edit> - In the future, please post you question only once - gerbick *(supermod)

- ok sorry

Using An AS2 External Class
Hey all, I'm starting OOP and have created my first class for storing a users information ie is logged in, firstname, lastname and email etc.

When I access the login function of the class (calls loadVars, PHP, MySQL and Back) the Boolean return value specified in the script always returns false, I think it's a slight latency issue due to the fact that if I wait a second and call the same function it returns true.

Can anyone shed some light on how I can get around this?

Class:

Code:
// Login Function
public function login(eMail:String, pW:String):Boolean {
// Get login details
_userDetails[1] = eMail;
_userDetails[2] = pW;
// Callbacks for getting past scope issues
var sU = _userDetails;
var root = this;
// Initiate login
var user_lv:LoadVars = new LoadVars();
user_lv.onLoad = function(success:Boolean) {
if (success) {
if (user_lv.userMatch == 1) {
sU[1] = user_lv.userEmail;
sU[2] = user_lv.userPassword;
sU[3] = user_lv.userID;
sU[4] = user_lv.userFirstName;
sU[5] = user_lv.userLastName;
sU[6] = user_lv.userMatch;
root.setLoggedIn(true);
return true;
}
}
};
user_lv.useremail = _userDetails[1];
user_lv.pword = _userDetails[2];
user_lv.sendAndLoad("http://MYWEBSERVHERE/login.php", user_lv, "POST");
return _isLoggedIn;
}

// Check status of user login
public function get isLoggedIn():Boolean {
return _isLoggedIn;
}
On the Flash timeline I do this:

Code:
var submit:Button = Button(submit);
var userLogin:systemUser = new systemUser();
//
submit.onRelease = function() {
trace(userLogin.login("me AT antonmills.com", "passy"));
};
So pressing submit twice returns true, it has to be a latency issue?! I know if I use a onEnterFrame to trace the message that will work but it seems like a waste when it should just return true to begin with?

Can anyone put me out of my misery?

antonmills.
http://www.antonmills.com

XML From External Class
I am having some difficulties loading XML from an external class. I would like to place the firstChild into a Dynamic Text Box. In my Flash movie the text box is labeled LevelTitle. This is my code at the moment:


Code:
class SelectTest extends XML {
var Testlist: XML;
var curContainer:XMLNode

function SelectTest() {
var Testlist = new XML;
Testlist.load("TestList.xml");
Testlist.ignoreWhite = true;
Testlist.onLoad = getTest()

}

function getTest() {
trace ("success");
var LevelTitle= Testlist.firstChild
trace (LevelTitle);
}
}
It always traces "sucess" leading me to believe that the xml is loading successfully, but when I try to trace LevelTitle, (or Testlist.firstChild, or Testlist.toString()) I always get undefined. What am I doing wrong?

XML From External Class
I am having some difficulties loading XML from an external class. I would like to place the firstChild into a Dynamic Text Box. In my Flash movie the text box is labeled LevelTitle. This is my code at the moment:


Code:
class SelectTest extends XML {
var Testlist: XML;
var curContainer:XMLNode

function SelectTest() {
var Testlist = new XML;
Testlist.load("TestList.xml");
Testlist.ignoreWhite = true;
Testlist.onLoad = getTest()

}

function getTest() {
trace ("success");
var LevelTitle= Testlist.firstChild
trace (LevelTitle);
}
}
It always traces "sucess" leading me to believe that the xml is loading successfully, but when I try to trace LevelTitle, (or Testlist.firstChild, or Testlist.toString()) I always get undefined. What am I doing wrong?

External Class
I am having problems with an external actionscript class which I have previously used with a good deal of success.

I downloaded these tutorial source files

I have checked it over and over and cannot figure out what I've done differently this time. Any hints would be fantastic, as it's driving me nuts now!

I have included my source files for reference

Help Modify External Class
I'm an AS3 and OOP newb, but I need some help with something that should be quite simple.

I have a single frame movie that is based on AS3 that has been written AS2 style, as a timeline attached script. That script has a function which gets called by many different click events from many different buttons. Call it myFunction();

I also have a 3rd party class being imported that gives me any number of a particular Sprite based object. Each object has it's own internal button that I can add a listener to. How can I call myFunction with that button?

In other words, how can I add a click event to the external class that calls my local function?

TIA,

Len

Modifying External MC From Within A Class
Hi everyone! This is my first post so I'll try to make it good.
My problem is I want to to control the visiblity of a movie clip from a class. If a variable contained in the class is 0, then the MC should be invisible. So far all I can figure out (and it doesn't work) is _root.MovieClip._visible = false;
Does anyone know how to do this? Any help or tips would be really great.
Thanks, Barbalute

AMFPHP + External .as Class
Hello!

im trying to contain most of the AMF PHP things i do within a class, so basically i have a class that gets and sends data using AMF PHP...

For some reason im having problems compiling it, i think it doesnt like the re.ResultEvent object... but im unsure as to why. In all honesty im not amazing with actionscript atm, so any help or advice with this would be great, here is my current chat class which i want to get working before i make a generic .as class for it.


Code:

import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;

class chatManager
{
var strGateway:String;
var oService:Service;
var strChatText:String;

function chatManager()
{
strGateway= "http://localhost/flashservices/gateway.php";
oService = new Service(strGateway, null, "chatManager", null , null);
strChatText = "";
NetDebug.initialize();
}

public function getChatData()
{
var pc:PendingCall = oService.getChatData();
pc.responder = new RelayResponder(this, "GetChatResult");
}

function getChatResults(re.ResultEvent)
{
var arrChatText = re.result;

for(var i=0;i<arrChatText.length;i++)
{
strChatText += arrChatText[i]["name"];
strChatText += ": ";
strChatText += arrChatText[i]["chat_text"];
strChatText += "
";
}
}
}

Custom Class & External Swf
I am loading an external swf which uses a custom class to control the loadSound function.

On the main movie's timeline is there a way to tell the loadSound to unload or stop?

Building External AS (Class)
Hi,
I am in the middle of trying to build and external AS so I can use it back and forth because I found that I am re-using many of the stuffs so many times. Is there a tutorial for me to do this? Thank you

Writting First External Class
Hello.
I need help writing my first class (Main.as I suppose).actionscript3.o

I made a .fla. it has 4 layers and a named movie clip on each. I started naming some key frames and I want to start learning how to loop and increment counters etc. eventually buttons and action listeners. I am under the impression that writing a class would allow more control. I am not sure of the basic structure required
I think I need a package and constructor and possibly an include statement to access my fla.


Can someone show me how the class must read to be able to start working on code.
Thanks
-Steve

External Class Confusion...
Hey all, new to this site but if my first impressions are correct I have a feeling I'll be hanging around here A LOT more in the future. I have a fair amount of programming experience but I'm totally new to Flash and ActionScript 3.0 and as a result I've hit a small snag in the midst of teaching myself.

Basically I have two files, an actionscript 3.0 file containing a class I created and a Flash file that creates an instance of this class for testing. The class is called a movieLoader and it's just basically a tool for connecting to a YouTube RSS feed and parsing the movie information down into a small subset of information that I would like to eventually display. The code for each is below:

File: MovieLoader.as

Code:
package {

public class MovieLoader {

import flash.net.*;
import flash.events.*;

public var movieCount:uint;
public var movieXml:XML = new XML();
public var movieList:Object = {};

public function MovieLoader(xmlURL:String) {

//trace("Creating instance of movieLoader class");

var loaderYouTube:URLLoader = new URLLoader();
loaderYouTube.load(new URLRequest(xmlURL));
loaderYouTube.addEventListener(
Event.COMPLETE,
buildMovieList
);

}

public function buildMovieList(evt:Event):void {
movieXml = XML(evt.target.data);
movieCount = movieXml.channel.item.length() - 1;

var mediaNS:Namespace = movieXml.namespace("media");
for (var j:uint = 0; j <= movieCount; j++){

movieList[j] = {clipTitle:movieXml.channel.item[j].title.toString(),
clipDate:movieXml.channel.item[j].pubDate.toString(),
clipImageUrl:movieXml.channel.item[j].mediaNS::thumbnail.@url.toString(),
clipSwfUrl:movieXml.channel.item[j].enclosure.@url.toString()};

}

}

}

}
File: sitetests.fla (actionscript in frame one)

Code:
import flash.events.MouseEvent;

myButton.addEventListener(MouseEvent.CLICK, buttonClick);

function buttonClick(event:MouseEvent):void {
trace(myMovieLoader.movieCount);
for each (var movieIns:Object in myMovieLoader.movieList) {

trace(movieIns.clipTitle + "
");
trace(movieIns.clipDate + "
");
trace(movieIns.clipImageUrl + "
");
trace(movieIns.clipSwfUrl + "
" + "----------" + "
");

}
}

var movieXmlUrl:String = "http://youtube.com/rss/tag/TheJawnee+NewZealand.rss";
var myMovieLoader:MovieLoader = new MovieLoader(movieXmlUrl);

trace(myMovieLoader.movieCount);
In the Flash file I also have a button called myButton that I was using to help me figure out what was going on. Basically here is what happens. I instantiate the MovieLoader class by passing it the URL of a YouTube rss feed. The MovieLoader opens the link, downloads it and parses some information out of it into a generic object. It works, the problem I'm having is that there is a delay.... and I'm not experienced enough to understand how to make my flash file wait for the MovieLoader to be ready. The line trace(myMovieLoader.movieCount); from the sitetests.fla file shows 0 in the movie count... but then when I click the button it displays 9 (and outputs the entire object contents) I have a basic understanding of EventListeners (you can see I use one in my class) but I'm not sure how (or if) one will help me. I just need a way of letting my main flash file know when the buildMovieList function in the external class has finished building the movieList object.

I know questions from complete newbies can be frustrating but I would sincerely appreciate any help you guys could offer. I've been trying to figure this out all day.

External Class Not Working
Learning AS3, I've got a question on the way classes work. I've created a pretty simple scenario, an image loader class (ImageLoader.as), which is functioning properly when accessed through the document class in my .fla
However when I try to access it through other means, either from another class, or even from the timeline - using var my_ImageLoader = new ImageLoader(); an odd thing happens, no error messages, but the image no longer loads, although the trace("ImageLoader") that I put into the class does still work, so the class is operating, just no longer loading the image.
Here's the script:

package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.URLRequest;
public class ImageLoader extends Sprite {
public function ImageLoader() {
var loader:Loader = new Loader();
addChild(loader);
loader.load(new URLRequest("my_photo.jpg"));
trace("ImageLoader is working");
}
}
}


Then I created another class (Middleman.as) to attempt to run the ImageLoader class, say from a button or whatever:

package {
import flash.display.MovieClip;
public class Middleman extends MovieClip {
public function Middleman() {
var my_ImageLoader = new ImageLoader();
}
}
}


If I use the Imageloader as the document class in the .fla, I get both the image and the trace.
If I use Middleman as the document class, I get the trace output, but no image.
Also if I just remove all document class paths from the .fla and put on a frame:

var my_ImageLoader:ImageLoader = new ImageLoader();

I still get the trace, no image. By the way, the .fla, the class files and the photo are all in the same directory.

Thanks if you can clear this up. - David

Timeline Var Into External Class Var
Heya

Trying to get a MovieClip/DisplayObject var into an external class ... ?
and it aint workin out

fla Timeline :

ActionScript Code:
var myAverage = new ObjectVar();

var thisThing = new ThisThing();
myAverage.thisVar = thisThing;


my Class :

ActionScript Code:
public class average extends Sprite
    {
        public var thisVar:MovieClip;
       
        public function Average ()
        {
          trace(thisVar);
         }

thisVar = null ? yeah ... this would be so simple if i knew the answer

External Class Problem
Hi all,

I'm finding myself wanting to use the penner easing equations in MX2004, and sadly it doesn't seem to work the same way as it did in MX. It tells me that I must define new classes in an external file, so I link to my external .as files with #include but even when I do that it *still* tells me that I can only define new classes in an external file... That gets a big WTF from me, since that's presicely what I'm doing.

Is there some other way to point to classes? I've been searching for a while and I can't seem to find the code I'd use to point to an external file just for the purpose of new classes.

External Swf And The Tween Class
i have an external swf which i import into my main swf using the loadMovie command. my external swf has some tween class animations in it. if i run the main movie, the external swf movie runs fine of course...but the tween classes are not loaded. am i missing somthing?

here is the code from the external swf file which is applied to a clickable movie clip of course.

this.onRollOver = function() {
rewind = false;
play();
var squaretween = new mx.transitions.Tween(previewthumb, "_xscale", mx.transitions.easing.Elastic.easeOut, 0, 1200, .5, true);
var squaretween = new mx.transitions.Tween(previewthumb, "_yscale", mx.transitions.easing.Elastic.easeOut, 0, 1200, .5, true);
squaretween.onMotionFinished = function() {
loadMovie("hotairlarge.swf", "_root.homecontainer.printworkcontainer");
}
};

any help would be great!

Get A .as Class To Use An External Variable
hello,

i have an AS 2.0 class file which is associated to my FLA project. all working fine. there is, however, a *hard-coded* IP address INSIDE the class definition (.as file). i need to make this a dynamic value (so that i can change the IP address at runtime). i am already loading and using the value dynamically (from a config.txt file) within the larger FLA file. but i do not know enough about class definitions to be able to refer to that variable from within the .as file (everything i tried was silly and gave errors).

so basically, how do i reference the value of a dynamicly loaded variable from within a class definition?
there is something called dynamic classes in AS 2.0, does the solution involve that?

any help appreciated, thank you!

Accessing MC From External Class
Hi all. I'm just learning about external classes, so please be gentle.

I want to access a movieclip on the main timeline from an external class
(turn the MC invisible). My MC is named "mainframe"

my external class is this:

package {
public class MyClass{
public function MyClass() {
mainframe.visible=false
}
}
}


and in my fla I call it like this:

var myClass:MyClass = new MyClass();


This is the error I get:

1120: Access of undefined property mainframe.


Can someone please explain to me how to reference a movieClip on the main
timeline? I've spent 2 days looking for the answer and it's getting very
frustrating.

Thanks,
Brock

Help With Linking External Class
Hey guys,
Not exactly sure how to phrase this question - I've been having trouble searching for answers for hours. This is for AS 2.0. Basically the situation is that I've created a MovieClip in flash graphically (dragging textfields and labels into the gui and then using convert to symbol -> movie clip).

The idea is that I would then link this clip to an external class which would contain code for interacting with this clip.

After linking the class successfully, I went to writing the code. Now I'm trying to compile and I'm getting all sorts of errors, for example on a textfield in the clip, tx_Agree, I try to do

tx_Agree.htmlText = percentage + "% Agree";

and the compiler complains

There is no property with the name 'tx_Agree'.

In flash, the instance name for this text field is definitely set to tx_Agree. The same goes for all the other components in this clip - I have given each an instance name, but none are accessible from the external class which I have linked to the clip. Help please!

BitmapData From External Class
Hi,

I have an external class that extends MovieClip and adds a bitmap to the stage of my movie. I can't find a way to copy the bitmap data from the instance of that class in order to use/manipulate it. The instance keeps getting treated as a display object. How can I get the bitmap data from a display object that was added to the stage from an externally loaded class?

EXTERNAL CLASS:


Code:
package {

import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Loader;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.events.Event;
import flash.events.MouseEvent;

public class BitmapDataObject extends MovieClip{

public static const MC_ON_STAGE:String = "mcOnStage";
private var _loader:Loader;
public var bitmapData:BitmapData;
private var bitmap:Bitmap;
public var picMC:MovieClip;
public var activeJPG:String = "myPic.jpg";

public function BitmapDataObject() {
newLoader();
}

public function newLoader() {
_loader = new Loader();
_loader.load(new URLRequest(activeJPG + "?" + fileNameAddOn));
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addImage);
}

public function addImage(event:Event):void {

var w:Number = _loader.width;
var h:Number = _loader.height;

bitmapData = new BitmapData(w, h);
bitmapData.draw(_loader, new Matrix(), null, null, new Rectangle(0, 0, w, h));
bitmap = new Bitmap(bitmapData);
bitmap.name = "pictureBitmap";
bitmap.smoothing = true;
picMC = new MovieClip();
parent.addChild(picMC);
picMC.addChild(bitmap);

}
}

External Preloader Class
i have an external preloader class but im having some problems.

public function onProgress(erogressEvent):void {

var loaded:Number = e.bytesLoaded;
var total:Number = e.bytesTotal;
var perc:Number = loaded/total;
trace(perc + "-----------------");
preloaderMC.loaderBar.scaleX = perc;

}

basically it cant see the preloaderMC.
i get this error...

1120: Access of undefined property preloaderMC.

Problems With External Class
Hi

I've downloaded an external class and this works for the main application but now I want to add a contact form to the same Flash movie, I know the code for the contact form is OK but when I mix normal timeline code with this external class I get a multitude of errors.

I'm using flash CS4 and I'm connecting to the class called proximityMenu.as from the properties bar.

Can someone just explain to me why?

Can external classes not be mixed with timeline based actions?

Just starting to use AS3 but i don't fully understand OOP yet as you can no doubt tell.

Any help on this would be much appreciated.

AS3 - External Class Setup
Hi you guys,
I have a AS3 project with classes and a namespace "com.myCompany.classGroup"
Everything works fine... I wanted to reference a group of classes written by someone else.

However my flash application isn't finding those class groups. How should I arrange my folder structure to see theirs?

This is what I'm doing now..

Code:
AS project folder
> file.fla
> com
> myCompany
> main.as
> classGroups
> whatever.as
> whatever.as
> se (someone's class)
> manmachine
> rpc
> main.as
> and so on...
I'm setting my com.myCompany.class within my .fla movie ...
then within this class...


ActionScript Code:
package com.myCompany
{
    import flash.display.Sprite;
    import se.manmachine.rpc;
 
//other code goes here...
}

Am I doing something wrong on how my folders are structure? Does the .fla need to know about the other possible classes aswell? Any suggestions or guide would be fantastic. Thanks!

[F9] How To Access Variable On External Class?
Hello

I can't figure out what am I doing wrong. I'm loading XML file on external as file. The loading is successful (as you can see from Output below), but for some reason the boolean "xml_check" doesn't became true. Can you understand why?




ActionScript on external file videoflash.as:
class videoflash {
var xml_check:Boolean = false;
private static var myXML:XML = new XML();

public function videoflash() {

myXML.ignoreWhite = true;
myXML.onLoad = loadFunction;
myXML.load("tsekki.xml");

}



private function loadFunction(success:Boolean):Void {
if (success) {
xml_check = true;
trace("Loading was successful.");


}
}
}

ActionScript on frame 1:
import videoflash;
var XML_class:videoflash = new videoflash();

ActionScript on frame 2:
nothing here

ActionScript on frame 3:
trace("Is XML loaded? "+_root.XML_class.xml_check);
_root.gotoAndPlay(2);



Output when movie is running:
Loading was successful.
Is XML loaded? false
Is XML loaded? false
Is XML loaded? false
Is XML loaded? false
Is XML loaded? false
Is XML loaded? false
Is XML loaded? false
Is XML loaded? false
And so on

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