Communication Between Classes
Is it possible to comunicate between classes using some kind of technique, either custom events .???What i want is one class dispaches an event and i can catch it with any of my classes, and use it as i wish and dispatch other , it is used to load secvencially the entire content.Tnx,
KirupaForum > Flash > ActionScript 3.0
Posted on: 04-20-2008, 08:38 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Communication Between Classes
Hi folks
I have stumbled over a quite confusing question concerning classes by just playing around for one of my projects...
I have a package of classes as follows:
package(folder) contains:
-classA (imports classB and classYA)
-classB (imports class XA and XB)
folderX
--classXA
--classXB
folderY
--classYA
[classA creates instances of classB and classYA]
[classB creates instances of classXA and classXB]
Code:
import classB;
import folderY.classYA;
classA {
public var __b:Object;
public var __ya:Object;
public function classA() {
this.__b = new classB();
this.__ya = new classYA();
}
}
//----------------------------------
import folderX.classXA;
import folderX.classXB;
classB {
public var __xa:Object;
public var __xb:Object;
public function classA() {
this.__xa = new classXA();
this.__xb = new classXB();
}
}
The problem is when creating the instance of classYA (meaning in its constructor and I also need that in its methods) I need to get the value of classXA.somewhat! ... which exceeds my understanding of actionscript somehow? After playing around for hours... I am not really aware wether I am just missin something or missunderstanding or whatever... but I can't find a solution on my own and on google Any hints or workarounds are appreciated!
Big thxs in advance
PS: Ah... before I forget that. I can't do that in the fla, it has to be in the as file...
Communication Between Classes
Hi Guys,
I only started using classes a while ago, and am still trying to get my head around some aspects of them. Currently my biggest problem seems to be getting information from one class from another. Is there a simple way to do this?
Im sure theres tutorials out there but i haven't found one yet that does exactly what a need.
Basically if you have a class, say ClassA and it contains a variable called Var1 could another Class, ClassB make a call to ClassA to recieve that variable Var1.
Any help would be much appreciated, even pointing me towards something to look up. I have been looking into getters and setter, but haven't been able to use them quite how i want! But are they the way forward?
Much thanks
LK
Communication Between Classes
Honest. I am slowly learning stuff, but sometimes it seems like 4 steps forward, 5 steps back. I'm working more with classes and understand how to PASS a variable from one class to another, but I'm not getting how to retrieve a value. I'm trying to write a separate class for my input board that will spit out a # based on light input every 5 secs. I then want to ACCESS that number from various other classes. So the class that needs to output that (Make.as) # has this code:
Code:
function onMessageIn(event:McEvent):void{
msg = event.data;
msgNum= msg.args[0];
}
This works just fine. I'm thinking I need a return or a set?? in there. But I don't understand the syntax or how to call it from the main class. I've properly instantiated the Make.as in the classDoc and it's there, but not getting that info. Help appreciated.
Communication Between Classes
http://www.nutrixinteractive.com/blog/?p=33
This may help some coders looking to buff up on writing classes. I have written a tutorial on communicating between classes using the EventDispatcher class, this class really helped me progress in OOP and I have based this around importing XML data as well which is a pretty common request these days so should prove useful....
Hope it helps,
Simon
Communication Between Classes
I'm trying to wrap my head around this and need some help. The scenario is this:
I have a main movie with it's Document class, the document class loads a few other classes
- Class 1 holds all of the file information, for example a few xml files and arrays
- Class 2 just a movie on the stage with a dataGrid
- Class 3 another movie on the stage with a button and text box
What looks so simple is hard for me to grasp, how do I get Class 2,3 to communicate with Class 1? So for example when button in class 3 is clicked it retrieves some text from Class 1 and displays it in the text box. Or lets say from the document class a method is called from Class 2 to retrieve info from Class 1 to display in the dataGrid.
Should I just include the Class 1 in every class that I need to use it? I would think that would weigh the file down but maybe flash only loads Class 1 into memory once and then if it is included again it just re-uses it.
Maybe a custom events class? Have no idea if that is the right track or even where to begin with that.
Or should I just write one giant Document class and forget the whole OOP idea.
Please help!
Attach Code
package
{
import flash.display.MovieClip;
import Class1;
import Class2;
import Class3;
public class DocumentClass extends MovieClip
{
private var mcClass1:Class1;
private var mcClass2:Class2;
private var mcClass3:Class3;
/*
Construct
*/
public function DocumentClass():void
{
mcClass1 = new Class1();
mcClass2 = new Class2();
mcClass3 = new Class3();
/*
I could write a listener to listen for the button press in Class 2 like below,
but then what is the point in writing a a separate class
*/
mcClass2.button.addEventListener(MouseEvent.CLICK, boooooo);
}
}
}
Communication Between Classes
Hey...
Well... i have another problem...
I can't call a function within a document class from another document class whose movie is loaded inside this first "document class".
So that you can better picture my problem, here is a sketch
Well this is the main problem...
Second problem... i did solve it but i am still wondering if there is a better way... so.. i have a FLA file... and two classes (ClassOne, ClassTwo)... i create an instance of both clases in my main FLA, now i would like to call a function form one class in another..
i did it this way... in my FLA i gave a name form document class.. Main, and than in ClassTwo i called: Main(parent).instanceNameOfClassOne.functionName() ;
Is it possible to just call class directly... like:
form ClassTwo: ClassOne.functionName();
I hope someone will enlighten me
thank you in advance...
J.
AS3 - Classes Communication
How do you communicate among a 2nd or more level of classes?
Lets say I have this Main.as, I imported in Logo.as. And I have this Shadow.ac classes that I wanted to apply on to several classes too.
Main.as
ActionScript Code:
package {
import flash.display.MovieClip;
import classes.*;
public class main extends MovieClip {
public var logo:FlashBlogLogo = new FlashBlogLogo();
public var dropShadow:DropShadow = new DropShadow();
public function main():void {
addChild(dropShadow);
addChild(logo);
}
}
}
Logo.as
ActionScript Code:
package {
import flash.display.MovieClip;
import classes.*;
import fblog_logo;
public class Logo extends MovieClip {
public function Logo():void {
public var dropShadow:DropShadow = new DropShadow();
var fb_logo:fblog_logo;
fb_logo = new fblog_logo();
addChild(fb_logo);
trace("FlashBlogLogo loaded");
fb_logo.filters=new Array(dSF); **shadow applied
}
}
}
DropShadow.as
ActionScript Code:
package {
import flash.display.MovieClip;
import flash.filters.DropShadowFilter;
public class DropShadow extends MovieClip {
public function DropShadow():void {
var dSF:DropShadowFilter = new DropShadowFilter();
dSF.color=0x000000;
dSF.blurX=5;
dSF.blurY=5;
dSF.angle=2;
dSF.alpha=.6;
dSF.distance=2;
//fb_logo.filters=new Array(dSF); ** or should I applied here?
}
}
}
If I put it all under 1 as file, it would be no problem detecting the target, but now I'm separating the classes and loading all into "main.as", how could 1 communicate with other classes without having to put it all together?
Communication Between Classes - AS3
Hi Guys, I have a question that I havent found too much written about.
Im building my first OOP project with classes in AS3, Ive done a lot of tutorials and Im grasping the concepts well.
Im just having trouble with the concept of communicating between classes.
Whats the best way for a class to talk back to its parent once its instantiated?
It seems when your inside a class, you're kinda stuck there as far as scope goes? ie one way street.
Or am i missing something? Im used to the days where I was coding on the timeline and could just use this._parent etc. But obviously those days are gone.
Or should I not need worry about this If I have planned the structure/heirachy correctly?
Any insights or resources would be much appreciated.
thanks!!!!
Communication Between Classes
Hey...
Well... i have another problem...
I can't call a function within a document class from another document class whose movie is loaded inside this first "document class".
So that you can better picture my problem, here is a sketch
Well this is the main problem...
Second problem... i did solve it but i am still wondering if there is a better way... so.. i have a FLA file... and two classes (ClassOne, ClassTwo)... i create an instance of both clases in my main FLA, now i would like to call a function form one class in another..
i did it this way... in my FLA i gave a name form document class.. Main, and than in ClassTwo i called: Main(parent).instanceNameOfClassOne.functionName();
Is it possible to just call class directly... like:
form ClassTwo: ClassOne.functionName();
I hope someone will enlighten me
thank you in advance...
J.
Custom Classes Communication
do you communicate among a 2nd or more level of classes?
Lets say I have this Main.as, I imported in Logo.as. And I have this Shadow.ac classes that I wanted to apply on to several classes too.
Main.as
ActionScript Code:
package {
import flash.display.MovieClip;
import classes.*;
public class main extends MovieClip {
public var logo:FlashBlogLogo = new FlashBlogLogo();
public var dropShadowropShadow = new DropShadow();
public function main():void {
addChild(dropShadow);
addChild(logo);
}
}
}
Logo.as
ActionScript Code:
package {
import flash.display.MovieClip;
import classes.*;
import fblog_logo;
public class Logo extends MovieClip {
public function Logo():void {
public var dropShadowropShadow = new DropShadow();
var fb_logo:fblog_logo;
fb_logo = new fblog_logo();
addChild(fb_logo);
trace("FlashBlogLogo loaded");
fb_logo.filters=new Array(dSF); **shadow applied
}
}
}
DropShadow.as
ActionScript Code:
package {
import flash.display.MovieClip;
import flash.filters.DropShadowFilter;
public class DropShadow extends MovieClip {
public function DropShadow():void {
var dSFropShadowFilter = new DropShadowFilter();
dSF.color=0x000000;
dSF.blurX=5;
dSF.blurY=5;
dSF.angle=2;
dSF.alpha=.6;
dSF.distance=2;
//fb_logo.filters=new Array(dSF); ** or should I applied here?
}
}
}
If I put it all under 1 as file, it would be no problem detecting the target, but now I'm separating the classes and loading all into "main.as", how could 1 communicate with other classes without having to put it all together?
Function Communication Between Two Classes
I'm trying to do some sort of socket connection, using VB (fscommand). My project is simple: I have 3 frames, and 2 classes.
One is called Connection, the other DataProcessor. Connection will handle connecting, sending packets, receiving them, disconnecting. DataProcessor has one function, ProcessData(sPacket) that scans the packet and determine what it is supposed to do. In the main frame, I have
var myConnect:Connection = new Connection();
I'm new to flash. All functions are public. Let's say ProcessData received a packet saying Welcome, it will send it to the Connection class, function ReceiveWelcome. I can't however manage to make them 'contact'. In the ProcessData function, I tried calling it with: ReceiveWelcome(), myConnect.ReceiveWelcome(), and Connection.ReceiveWelcome().
My function ReceiveWelcome is calling another function in the same class, and set some variables defined on top of it. ReceiveWelcome() isn't working, myConnect.ReceiveWelcome() either. Connexion.ReceiveWelcome() gives me an error saying something like 'Reference element doesn't have static attribute'. When I add the static thing, it doesn't execute my function :/...
So: How can I make two functions from different class communicate (and those functions calling other functions in the same class), or does someone has a good class documentation somewhere?
AS3 - Communication Between Unrelated Classes
Hi,
I'm building an interactive which consists of a scrollable map. Clicking on a hotspot plays a specific type of media in a media module. Hotspots can either be panoramas, videos or images.
My class structure is as follows
MainClass --> Map class --> Map node --> (specific node class - extends mapnode)
also from the main class i instantiate my media module.
Main Class --> info panel class --> media module class
I hope that is kind of making sense so far.
So the thing I'm not sure about is passing an event from (for example) a panorama node to the media module, say to tell it which file to load in.
I've been looking at the EventDispatcher class and custom events but do I need to pass class instance references when using it. Do I have to go right up the chain to mainclass and back down?
I know this would be better supported with code examples but its more the theory that I'm after. I'm not sure I have the time to restructure my classes with an upcoming deadline. I'm just looking for a way that a listener in my media module can listen to events fired from the hotspots. As one class doesn't instantiate and store a reference to the other directly I'm not sure how to get it working.
Many thanks in advance
Ant
Classes Structure And Internal Communication
Hi, I am trying to start wraping my mind around the OOP and event driven architecture in AS3.
Situation:
Assuming I have 5 classes, A, B, C, D, E.
D would perform an action (event?) and set a private property that A will need that data set by D to pass
to class E instance created within class A.
Questions:
1. I'd like to know if it's good practice to have class A (Document Class) create an instance of B and E, then B
creating an instance of C which then will have an instace of D.
2. Is Having several events taking that data from D to A the best way?
e.g: C registers its D instance as a listener for D events, then when the eventListener is called
within C. Class C would fire another event to be listened by C's instance within B which would go
through the same process and trigger another event to be listened by B's instance within class A.
Each step (event object being created by each event in the chain) would be creating a member to hold
the data pulled of the origin (the initial event triggered by D). After the event chain finishes class A
will be able to access the data pulled from D and then pass as a parameter to E instance creation.
Custom Classes: One Class Tracks Multiple Other Classes?
I'm working on a coloring that allows kids to place objects on a scene and then color them so the image can be printed out. So assume you have sky background, the child can select a bird object, drag it into place and once they have it in place, color everything on the page (with a given palette of colors.)
So far it going great. However I want to track what objects have been added to the drawing on the fly. I have a potential solution using arrays but I'm thinking this is perfect opportunity to start using custom classes.
I'm thinking that I'd create a new instantiate a copy of the object class each time an object is added to the scene. However to track the objects added to the scene I'm thinking I'll also use an listing class to track them.
What I'm not sure about is the would the listing class simply contain an array of object identifiers? Any thoughts on the structure of the listing class?
I'm very new to oop as I've mainly been doing procedural programming up to this point but I'm eager to give this a shot.
Thanks!
Using Flex Classes In Classes Linked To Symbols
Hi all
I have a fla file where I link a symbol to an action script class. This action script classes references mx.collections.ArrayCollection; so when I attempt to publish the fla file, I get the error message:
1017: The definition of base class ArrayCollection was not found.
I then tried to add a class path (this folder contains the mx... classes):
C:Program FilesAdobeFlex Builder 3sdks3.0.0frameworksprojectsframeworksrc
and the the above error 1017 wasresolved, but now I get the error:
Version.as, line 18 1004: Namespace was not found or is not a compile-time constant.
So now I am pretty much stuck. What do I need to do for this to work ? Please note that the code compiles fine in flex, so it is not som basic coding error ?
Instantiating Classes Inside Classes
I have a class called spaceship in which i have instanciated another class weapon. However, when i call on a method of weapon (which at this point is just simply trying to trace "hello"), it doenst work and the object basically doenst exist. It's delcared in the class as:
Code:
private var ShipWeapon:weapon;
Note that when I instantiate a weapon class on the main timeline the thing works and "hello" is printed to the output panel. However, nothing at all happens when instantiated the weapon class inside my spaceship class. Both traces come up "undefined". Do i need to declare the class as some sore of special class or somethings? Thanks in advance
[classes] Best Method To Communicate Between Classes
Here's the scenerio:
I have a component that is associated with a class. Inside the component is an empty movieclip.
-component (part of a class)
-mc
The main component's class upon init will load a movie from a remote server into the mc movieclip. System.security.allowDomain is in there...
Now, inside the swf that gets loaded into the mc is an empty movieclip that's associated with it's own class:
-component (part of a class)
-mc (contains loaded movie)
-mc (part of a separate class)
Now here's the challenge... I need to have the loaded movie > mc's class be able to communicate with the main component's class.
What's the best setup to be able to communicate between the two classes directly? That is, if I don't have loaded movie > mc > class inherit from the component's class.
thanks in advance...
Nathan
Best Flash Classes (Taught Classes)
I think this site is great for newbies in the flash world to Advanced flash developers. I am an intermediate flash designer/developer and I have been using flash since 1998. My strengths are more on the design side for sure. I am just curious what your experience is with going to a week long flash class. I have been to several classes and my last one was a week long one with Joshua Davis on advanced actionscript in NYC a while back. This was still coding in AS1 with dot syntax so only some of it is relevant to what we are doing today. I am wondering what are the best classes out there today and what your experiences are if you have been to any. I wish another event like this: grant skinners FITC flash 8 workshop or this Colin Moocks actionscript bootcamp were available but I can't find anything like it. My friend went to Colin's workshop a while back and mentioned how he went into design patterns with AS2 and it would be great to learn about that. ANyhow any suggestions would be great. Post your thoughts.
Instantiating Classes Inside Classes
I have a class called spaceship in which i have instanciated another class weapon. However, when i call on a method of weapon (which at this point is just simply trying to trace "hello"), it doenst work. The compiler obviously didn't flag anything, but i also get "undefined" for all my weapon class varibles. Do i need to declare the class as some sore of special class or somethings? Thanks in advance
Accessing Classes From Classes
ok something I don't get. In as2 I used to have a main class, which I created an instance of my Useful.as Class in. And then when I created say a monster instance from my monster class, I used to pass it a reference to the main class, so I could access the Useful instance from a function in my monster class like this
Code:
main.Useful.RandomNumber(1,100);
But this doesn't seem to work in as3
It just gives me a reference error, even though when you look with debug mode the Useful instance is sitting there in the main class, and there is also a reference inside my monster instance to the main class. I found that if a pass a direct reference to the Useful instance to the monsters constructor, and setup a var called Useful inside my monster instance then I can just do this
Code:
Useful.RandomNumber(1,100);
but why doesn't the old AS2 way of things work?
Accessing Classes From Other Classes
Two Classes: Tile, Map
I know Tile works and is accessible from the main timeline because I can create and object and trace properties, so the timeline is able to import it.
When placing the same import statement in the Map class I get: 1046: Type was not found or was not a compile-time constant: Tile.
Here is code
ActionScript Code:
package layout
{
public class Tile
{
public var filename:String;
public var myX:int;
public var myY:int;
public var ext:String;
public function Tile(sFilename:String)
{
filename = sFilename;
var nPos1 = sFilename.indexOf('_');
var nPos2 = sFilename.indexOf('.');
myX = Number(sFilename.substring(0, nPos1));
myY = Number(sFilename.substring(nPos1+1, nPos2));
ext = sFilename.substring(nPos2, sFilename.length);
}
}
}
ActionScript Code:
package layout
{
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
import layout.Tile;
public class Map extends Sprite
{
// tiles[y][x]
public var tiles:Array = new Array();
public function Map()
{
if (map == false)
{
var map:Sprite = new Sprite();
this.addChild(map);
}
}
public function AddTile(sFilename:String)
{
var Tile:Tile = new Tile(sFilename); //This line causes issue
tiles[Tile.myY] = new Array();
tiles[Tile.myY][Tile.myX] = new Array(Tile, false);
}
}
}
Using Classes Inside Of Classes
I have created a custom sound class called MySoundClass that extends the Sound class... it is declared as class com.stickyMatters.WineGlassPiano.MySoundClass. I also have another class called SongPlayer that is declared as com.stickyMatters.WineGlassPaino.SongPlayer... my question is.. how do i use the MySoundClass inside of the SongPlayer class... when I try to import it says I cannot use the import statement inside of a class file. I know in AS3 you can use the package keyword to create packages and do that... but as far as I can see there is no package keyword in AS2... because I tried, and it just tells me htere is a syntax error on the line with the package declaration... can you use one custom class inside another? and if so... how?
P.S. just to be sure... i am using flash CS3 and writing AS2 files. Thanks!
Classes In Mx 2004 (new To Classes)
hi everyone, Im Nubis, from Argentina.
I´m new to woking whit classes, Im using flash mx 2004 pro.
Ive created a class, that works correctly, it creates a square, a textbox, and uses a variable to pupulate the textbox.
(im sorry for my english)
in my library i have a MC (an empty MC) that is linked to that class.
I use this script to place the clip on the stage
attachMovie("card", "card", 1)
iknow the class works fine, but, I dont know where to pass the parameters to the class.
And if I use : Card = new MyCard("this Card´s Name or label ")
both the clip and the textbox are not created.
could anybody please help me?
thanks in advance :)
(feel free to make comments about my code)
this is my class code:
// MyCard
class MyCard extends MovieClip {
var thisCardName:String;
//method for creating the square
function gen_sqr (){
this.createEmptyMovieClip("Square",2);
with(this["Square"]){
beginFill (0x0099FF, 100);
lineStyle (1, 0x003399, 100);
moveTo (0, 0);
lineTo (100, 0);
lineTo (100, 70);
lineTo (0, 70);
lineTo (0, 0);
endFill();
}
}
//method for generating the textfield
function gen_txt(my_text){
this.createTextField("mytext",3,0,0,50,20);
with(this["mytext"]){
text = my_text;
multiline = true;
html = true;
}
}
//constructor
function MyCard (thisName:String){
//set the name or label for the card
thisCardName = thisName;
//
gen_sqr()
gen_txt(thisName)
//
trace("newclass Created")
trace(thisCardName)
}
}
Importing Classes In To AS3 Classes?
I am not sure how to import multiple classes into an AS3 class. Also I am bit confused on how "package" works now.
This is currently what I have and its wrong:
Code:
package {
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
class LoadImage {
public function LoadImage() {
var container:Sprite = new Sprite();
addChild(container);
var pictLdr:Loader = new Loader();
var pictURL:String = "catfishSMv.jpg"
var pictURLReq:URLRequest = new URLRequest(pictURL);
pictLdr.load(pictURLReq);
pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
function imgLoaded(e:Event):void {
container.addChild(pictLdr.content);
}
}
}
}
How should I actually do this?
Thanks
Classes In Mx 2004 (new To Classes)
hi everyone, Im Nubis, from Argentina.
I´m new to woking whit classes, Im using flash mx 2004 pro.
Ive created a class, that works correctly, it creates a square, a textbox, and uses a variable to pupulate the textbox.
(im sorry for my english)
in my library i have a MC (an empty MC) that is linked to that class.
I use this script to place the clip on the stage
attachMovie("card", "card", 1)
iknow the class works fine, but, I dont know where to pass the parameters to the class.
And if I use : Card = new MyCard("this Card´s Name or label ")
both the clip and the textbox are not created.
could anybody please help me?
thanks in advance :)
(feel free to make comments about my code)
this is my class code:
// MyCard
class MyCard extends MovieClip {
var thisCardName:String;
//method for creating the square
function gen_sqr (){
this.createEmptyMovieClip("Square",2);
with(this["Square"]){
beginFill (0x0099FF, 100);
lineStyle (1, 0x003399, 100);
moveTo (0, 0);
lineTo (100, 0);
lineTo (100, 70);
lineTo (0, 70);
lineTo (0, 0);
endFill();
}
}
//method for generating the textfield
function gen_txt(my_text){
this.createTextField("mytext",3,0,0,50,20);
with(this["mytext"]){
text = my_text;
multiline = true;
html = true;
}
}
//constructor
function MyCard (thisName:String){
//set the name or label for the card
thisCardName = thisName;
//
gen_sqr()
gen_txt(thisName)
//
trace("newclass Created")
trace(thisCardName)
}
}
Accessing Classes From Classes
Hi... I'm having some trouble with these bits of code... I got some help before from wangbar to sort it out when the var stored was in a class of its own. But trying to access it from another class isn't working...
class Ipa{
var c : Settings;
function Ipa() {
}
}
class Settings {
var currSubs:Boolean;
function Settings (s:Boolean) {
currSubs = s;
}
function getSubsOn ():Boolean {
return currSubs;
}
function setSubsOn (s:Boolean):Boolean {
currSubs = s;
return currSubs;
}
}
then at root level:
var dpp : Ipa = new Ipa();
dpp.c.setSubtitlesOn(false);
and level 3:
_global.subtitles = _level0.dpp.c.getSubtitlesOn();
if ( _global.subtitles == false){
_level3.speech._visible = false;
};
And nothing happens...subtitles still showing...
Thanks in advance for help.
silverswim
AS1 Classes And AS2 Intrinsic Classes
Anyone ever mess around with writing an AS1 style class (so that it can be used prior to your class export frame) and writing an intrinsic AS2 class to go along with it, to enable compile-time checking?
It's working well, at least for instance members. (The trick is you need to define your constructor like so:Code:
var MyAS1Class = function... and NOTCode:
function MyAS1Class...)
But for static members, I can't seem to get the compiler to recognize the AS1 static members as validating against the AS2 intrinsic classes static members. In other words:
Code:
import the.intrinsic.class.Foo
#include "the/actual/as1/class/Foo.as"
var myFoo:Foo = new Foo();
// This cause the compiler to complain:
myFoo.nonExistentProperty = "moo";
// This goes by undetected:
Foo.NON_EXISTENT_STATIC_PROP = "moo";
// This gets caught:
the.intrinsic.class.Foo.NON_EXISTENT_STATIC_PROP = "moo";
// But doesn't help because it's referencing the intrinsic class, which
// doesn't actually have any code and never gets compiled
(obviously the properties mentioned are not defined in this example intrinsic class)
It's apparently a problem of the actual AS1 class being a var on the timeline and the AS2 intrinsic class existing in a different namespace.
I've tried putting my AS1 class in the _global.the.intrinsic.class.Foo variable, like it would if it were a regular AS2 class.
I've tried Object.registerClass("_global.the.intrinsic.class.Foo", Foo), which I thought would work, but maybe I'm doing it wrong.
So far the best workaround is this:
Code:
Foo.__resolve = function(name:String):Void {
trace("Oops, the member you've accessed, " + name + ", does not exist");
}Which at least provides run-time checking, but not compile-time checking, which is obviously why I'm doing this intrinsic thing at all.
I know this is a very esoteric question...any suggestions?
PS
Man, I do NOT miss writing AS1 OOP! I tend to forget how great AS2 OOP is when I use it exclusively. But coming back to AS1 OOP...<napoleonDynamite>Gawh!</napoleonDynamite>
Using Custom Classes Inside Of Custom Classes
I have created a custom sound class called MySoundClass that extends the Sound class... it is declared as class com.stickyMatters.WineGlassPiano.MySoundClass. I also have another class called SongPlayer that is declared as com.stickyMatters.WineGlassPaino.SongPlayer... my question is.. how do i use the MySoundClass inside of the SongPlayer class... when I try to import it says I cannot use the import statement inside of a class file. I know in AS3 you can use the package keyword to create packages and do that... but as far as I can see there is no package keyword in AS2... because I tried, and it just tells me htere is a syntax error on the line with the package declaration... can you use one custom class inside another? and if so... how?
P.S. just to be sure... i am using flash CS3 and writing AS2 files. Thanks!
Using Custom Classes Inside Of Custom Classes
I have created a custom sound class called MySoundClass that extends the Sound class... it is declared as class com.stickyMatters.WineGlassPiano.MySoundClass. I also have another class called SongPlayer that is declared as com.stickyMatters.WineGlassPaino.SongPlayer... my question is.. how do i use the MySoundClass inside of the SongPlayer class... when I try to import it says I cannot use the import statement inside of a class file. I know in AS3 you can use the package keyword to create packages and do that... but as far as I can see there is no package keyword in AS2... because I tried, and it just tells me htere is a syntax error on the line with the package declaration... can you use one custom class inside another? and if so... how?
P.S. just to be sure... i am using flash CS3 and writing AS2 files. Thanks!
PHP Communication
Hi !
I guess I am not the first with this problem but I have not found where the solution is... ;-(
I have a swf file that use some php programms to communicate values. Every thing is allright on my hard drive but I put the swf file on a http server, it apparently don't read datas...
Where is the solution ?
Thanx a lot...
Communication Between Two Swf.
I´ve got several text variables within a .swf and I´d like to know if there is a way to send them to another .swf
Thanks in advance
.swf To .swf Communication ?
I spent hours on this swf to swf thing and still failed. I will not give up but I could use some help?
IM trying to link My two flash movies(that are on the same page) together. I would like my bottom flash movie buttons to open a pop "upmenu" out of the top flash movie. I was told I could do this from nerdinside with this link http://www.polar-lights.com/fla/fla/sendcommand.zip
and I havent heard from him sense.
Here is my button code
on (release) {
// Notice the Decoy A / WIN1
if (_root.decoyA._currentFrame == 1) {
_root.draglines.swapDepths(10);
_root.WIN1.swapDepths(10);
tellTarget (_root.decoyA) {
gotoAndStop (2);
}
tellTarget ("WIN1") {
// Notice the WIN1
loadVariables ("text.txt", "text_box");
// load from txt file
loaded = 1;
}
} else if (_root.decoyA._currentFrame == 2) {
tellTarget (_root.decoyA) {
gotoAndStop (1);
}
tellTarget ("WIN1") {
loadVariables ("blank.txt", "text_box");
// loads a blank text file when closed to kill text
loaded = 0;
}
}
tellTarget ("click") {
gotoAndPlay (2);
}
}
How would I integrate the code from this zip file http://www.polar-lights.com/fla/fla/sendcommand.zip that (NURD INSIDE) sent me into this to add to my bottom buttons to link to Win1(which is my popup menu in the top flash section).
This is what I tryed so far:
on (release) {
getURL ("javascript:go()");
}
I added this to the top of my button code.
I also tried making my bottom buttons from the zip file and just deleting the starwars pic and loading....
Any comments would be appreciated.
Thanks,
Communication SWF To SWF
Alrighty
I have two SWF files (file1.swf and file2.swf), and I have two different frames (frame1 with frame1.html, and frame2 with frame2.html) each of them holding their respective swf's.
I want file1.swf to act as a menu... when a button is clicked, I want it to change the url of another frame: (name: main, filename: content.html) and at the same time, I want it to execute a function in file2.swf.
1. How would I make file1.swf talk to file2.swf?
2. How would I make the frame main change content.html to something else?
I realize that it requires javascript, but I seem to have trouble with my target= and it seems to pop a new window everytime...
Any help would be greatly appreciated.
Communication Between Two .swf's
Hi
just wandering if it is at all possible to have two .swf files, one with navigation, one with the content, then when the button id pressed in the navigaion .swf the content changes.
thanks
Communication Between Two .swf's?
Hi,
I was wondering if it's possible for two separate .swf files to exchange information and work together. If so, what's the basic idea behind it?
For example, if you had a webpage with two .swf movies in it (call them top.swf and bottom.swf), could you have a button in top.swf that changes the background color of bottom.swf when it's clicked?
Thanks!
Communication Between SWF's
Hey there,
I've hit a block and need a bit of knowledge...
I've got 2 sfw's on a page, I need to unload or goto and play to have it unload on keyframe inside it on sfw #2. When I choose a menuitem in #1 I should be able to do this right?
I've tried various method’s and no luck yet...
I thought that a simple
on(release)
Unload("http://site.com/#2.sw");
But no
Tried levels to but not in same movie so didn't figure this to work.any tips i'm probably missing obvious things but tries a bunch and no luck!
Help would be great!!!
Thanks for any i get!
mmeye
Swf To Swf Communication
I want to make two swf files to be communicated. for example::
I've two files "a.swf" and "b.swf". in a.swf i have one varaiable named "myVal" and itz value is "true"... ie (myVal="true").. i vant to pass this value from "a.swf" to "b.swf".... I've used LoadMoviennum , nbut it needs explorer... i want to do it with swf files alone
Communication Between 2 .swf's
Is it possible for a swf loaded in level 1 of the main swf to control the main swf?
I am trying to get a button in level 1 to make the main swf to goto frame 30.
I am using Flash MX
Communication
If I have two swf files on a web page...say one that lets the user enter information and another with shapes on it (for simplicity) is there a way for the two movies to communicate without having to sent info to a server and back? (directly) thanks!
mikell
Communication
If I have two swf files on a web page...say one that lets the user enter information and another with shapes on it (for simplicity) is there a way for the two movies to communicate without having to sent info to a server and back? (directly) thanks!
mikell
.swf Communication
If you have 2 different .swf on the same HTML page, can these 2 .swf files send commands back and forth to each other using tell target?
IN other words can i have a button in one file that tells the other one to load the movie. OR can this only be done in the same movie?
Thanks..
Swf To Swf Communication
using flash mx
Does Anyone know how I can send a message from one swf (level_10) to change the value of a variable the caller swf (level_1)?
Cheers
Communication?
what do i need to do to get 2 separate swf 's to communicate with each other, if they are placed in two separate table cells on the same html page?
rat
XML Swf Communication
i have one XML doc, and two swfs
accessing it. the swfs are both loaded into MCs in the
main timeline. the nodes in the XML are grouped into
sections with children who are items with info in attributes.
Code:
EX:
<project label="Misc">
<item label="Mural" url="images/projects
/project_img.jpg" link="www" resp="info">My description is here</item>
</project>
one swf("navSwf") goes through the XML and generates a
menu of link using html textboxes and hrefs. thats
fine. the other swf("displaySwf") take the nodes info
and displays it. that works fine. on the nav hrefs i
currently have asfunctions(which do nothing, i am
thinking its the way to go), and i am trying to pass
the info of the selected item from the navSwf to
displaySwf.
EX:
in navSwf i click on item 3, so i need to tell the
displaySwf to access that item 3 node and
parse/display its attributes.
it is here where i am lost, how can i do this?
let me explain a bit about the swfs. in my main timeline i have 3 empty MCs. one loads a main nav swf, one that loads a sub nav swf, and one that loads content...so if i someone clicks on the "project section", the subnav project swf loads, parses the project XML. the content swf also parses the project XML to load the first project's info. which works fine, but the subnav swf is a html text box with hrefs, and i need to pass the node info that selected in the subnav to the content swf.
i may not be setting this up the best i understand,
but any help to get this working is greatly
appreciated. thanks
Swf Communication
I have a flash movie for navigation, and a movie for the page it self....is there anyway to have the navigation send as to the main page movie...like a gotoAndPlay......
I want to do an outro play on a hybrid site.......
Possible?
Help XML Swf Communication
bear with me here. i have one XML doc, and two swfs accessing it. the swfs are both loaded into MCs in the main timeline. the nodes in the XML are grouped into sections with children who are items with info in attributes. EX:
Code:
<project label="Misc">
<item label="IPS Mural" url="images/projects /project_img.jpg" link="www" resp="info">My description is here</item>
</project>
one swf("navSwf") goes through the XML and generates a menu of link using html textboxes and hrefs. thats fine. the other swf("displaySwf") take the nodes info and displays it. that works fine. on the nav hrefs i currently have asfunctions(which do nothing, i am thinking its the way to go), and i am trying to pass the info of the selected item from the navSwf to displaySwf. EX: in navSwf i click on item 3, so i need to tell the displaySwf to access that item 3 node and parse/display its attributes. it is here where i am lost, how can i do this?
i may not be setting this up the best i understand, but any help to get this working is greatly appreciated. thanks for taking the time to read this.
Swf Communication To Another Swf
I've been on the verge of tears with this... so.. I saved in it all back in mx and got rid of the 2004 coding (got rid of the loader (2004 loadMovieClip) and replace it with loadMovieNum), and figured I try my luck with mx... well, once again I've hit the wall and find myself dazed and confused. All I want to do is get the about button... hell, at this point, any button in the nav swf to communicate with the dataBox swf and gotoand play a label on the data_mc timeline.
frame1 of nav.swf :
code: stop();
trace("nav.swf file is LOADED and resides on Level: "+this._level);
about_btn.onRelease = function() {
trace(pic_mc);
_level15.pic_mc._alpha = 0;
//trace(_level15.data_mc); ???
_level0.data_mc.gotoAndPlay("textboxLG"); ???
// trace(data_mc);
};
I'm hoping, if ya get a free moment, you might help rescue me before I pull the rest of my hair out. : /
I attached the 3 fla's that I built and a text file that the data_mc utilizes..,can ya give these the once over and help me to get this working. I think once I overcome this situation... I can apply it to the other buttons and things down the road.
actually to be sure I stay within the upload limit..I have broken down the files into 2zip files ..
(var.fla, text.txt) 2.zip
(master.fla, dataBox.fla) 1.zip
GOD BLESS ALL that help me overcome this!
.SWF -TO- .SWF Communication
I thought this would work, but unfortunately it doesnt.
I am trying to get one .swf file to talk to another. The only data I need to pass, is when you release inside of one movie clip, it calles on the a function in another.
Here is the code.
Buttons SWF
============
sender = new LocalConnection();
_root.forward.onRelease = arrowForwardOnRelease;
{
myLoad = 0;
_root.sender.send("ldMovieConnection", "onReceive", arrowForwardOnRelease);
}
_root.back.onRelease = arrowBackOnRelease;
{
myLoad = 1;
_root.sender.send("ldMovieConnection", "onReceive", arrowbackOnRelease);
}
Now I need this to call the function arrowForwardOnRelease in the Holder.swf file.
Holder.swf
================
_root.createEmptyMovieClip("movieHolder",1);
receiver = new LocalConnection();
receiver.onReceive = function(myLoad) {
_root.movieHolder.loadMovie("nav.swf", 1);
}
receiver.connect("ldMovieConnection");
Everything was working until I broke those 2 button calls out to the buttons.swf so the only problem is transferring the data.
Can anyone tell me what I have done wrong here?? Any help is much appreciated.
Thank you
--J
Swf-swf Communication
I thought this would work, but unfortunately it doesnt.
I am trying to get one .swf file to talk to another. The only data I need to pass, is when you release inside of one movie clip, it calles on the a function in another.
Here is the code.
Buttons SWF
============
sender = new LocalConnection();
_root.forward.onRelease = arrowForwardOnRelease;
{
myLoad = 0;
_root.sender.send("ldMovieConnection", "onReceive", arrowForwardOnRelease);
}
_root.back.onRelease = arrowBackOnRelease;
{
myLoad = 1;
_root.sender.send("ldMovieConnection", "onReceive", arrowbackOnRelease);
}
Now I need this to call the function arrowForwardOnRelease in the Holder.swf file.
Holder.swf
================
_root.createEmptyMovieClip("movieHolder",1);
receiver = new LocalConnection();
receiver.onReceive = function(myLoad) {
_root.movieHolder.loadMovie("nav.swf", 1);
}
receiver.connect("ldMovieConnection");
Everything was working until I broke those 2 button calls out to the buttons.swf so the only problem is transferring the data.
Can anyone tell me what I have done wrong here?? Any help is much appreciated.
Thank you
--J
|