ActionScript 3.0 :: Interaction Between Two Class Files?
Sep 24, 2011how can i order a movieclip to do something at another class file?
ActionScript Code:
package {
import flash.display.*;
import test2;
[code]....
how can i order a movieclip to do something at another class file?
ActionScript Code:
package {
import flash.display.*;
import test2;
[code]....
Not sure that I understand how the Reader engine for AS 3.0 handles "load" requests. Following is a problem that I try to solve for a customer: there a three - 3 - swf files, each contains a short video of 10 sec's in full hd, stage is 1920x1080 px, let's call them a,b and c
The request is the following: start with swf a and let it run, loop, and during that time offer the possibility to select or swf b or swf c to run in stead of a when swf b runs, loops, offer the possibility to select or swf a or swf c to run in stead of b idem for swf c or with words: each of the swf's offer the possibility to invoke one of the 2 other swf's.
I tried various code snippits, and when running a it starts b but a contineous to run, so it seems ihe engine does not pass control to b. Maybe I have to put everything in 1 swf? But that is not what the customers want, he wants the 3 swf's.
how to open a new SWF(about.swf)(i used the addChild method) when clicking on a button. In the 1st original SWF(home.swf) i let a song begin to play via AS3. This piece of code consists of a play and stop button, which works according to if the song is playing or not. It automatically starts playing when the home.swf opens.
now here comes my problem...I need my play and stop buttons in about.swf to be able to control the song in home.swf when the addChild method was used.
Here is the code that loads the music:
import flash.media.Sound;
import flash.net.URLRequest;
var music:Sound = new Sound(new URLRequest("SoundTrack.mp3"));
[Code]....
To break it all down....in home.swf i load about.swf with buttons play_btn and stop_btn. These two buttons need to work with the song loaded in home.swf
I wish to be able to use a Flash animation (call it "one.swf, loaded into "one.html"") as a control panel to control the activities in another animation (say "two.swf" which of course will reside in "two.html")The control panel ("one.swf") will have 10 buttons for the navigation around "two.swf" and "on release" of the butons, I would like for BOTH 1. the navigation in "two.swf" to happen AND 2. "one.swf" to be (preferably) minimised or else closed.What sort of coding is needed to enable this interaction between the two swf files?here will be a button on "two.swf" which will be used to call up "one.swf", but presumably the coding there will need to be different if "one.swf" is minimised to how it is if it is closed. Whilst I can hack opening "one.swf" from fresh if it has been closed, how do I code the button to restore it from being minimised?
View 1 RepliesI know Shared Objects are the standard way to store data from flash, but these seem to have a number of limitations.I'm wondering if it's possible for the flashplayer to manipulate regular files.It's my understanding that through FileReference you can load a file of the user's choice into memory. My question is, would it be possible to manipulate this file then present it back to the user for download? Possibly using javascript to assist?
I understand that it might be possible using server-side technology, but I'm wondering if it can be done without taking hard drive space and bandwidth from the server.
How do you access every displayed object of a certain kind at once? Here's the code.
[Code]...
I want to replace the underlined part so that it refers to every instance of the dirt symbol without an insane number of iterations. From that, I plan to make the player capable of standing on each dirt symbol as they are being created, as well as move all of the dirt symbols with ease.
I have some files in my src directory, some are .class files (Java class files) and some are .properties files, when I create the Adobe air native installer these files are not included. Why is that? How can I work around that?
Also it excludes .mxml files, but that's good. I'm sure that's related, how to change what it includes or excludes?
Just wondering what is the standard in the Industry; does the client get the ActionScript Classes and the .fla file?
View 2 RepliesI've got an external .as file in the same folder as my flash file. In the process of writing the code, whenever I make a change and then test the movie, the flash movie is obviously still looking at the OLD information. I tried using the "Delete ASO Files" on the menu, to no avail.I can' find these ASO files anywhere on mycomputer.Aha! I tried something else. I quit flash,restarted and ran the same script with no changes. It returned the data correctly, but then gave me this unpleasant message:256 levels of recursion were exceeded in one action list.This is probably an infinite loop.Further execution of actions has been disabled in this movie.There are no loops of any kind in the code, which is below.
//This is the Person.as file:
class Person { public var HomName:String = "unknown"; public var HomEmail:String = "unknown"; public var HomPhone:String = "unknown"; public var HomSaveFreq:Number = 0;
[code]......
Sometime we write custom classes that are used by our FLA files, the custom classes are stored as .as files. Now when were create SWF files, what happens to the .as? Does the SWF itself contain the elements of both the FLA and .as, meaning can I say: SWF = FLA + as. noticed that the swf files were loaded in the directory in the server but not the .as files, even though at the development end there was both the FLA and the external .as Class file.So in the absence of the .as files in the server, I came to my above conclusion of SWF = FLA + as. Am I correct in assuming this?
View 2 RepliesI have this class called AD. Its attached to my stage. AD then calls a class file called setupBoxes.
setupBoxes sets up a box using box2d (which has nothing to do with my question so dont stop reading here), attaches a movieclip to it, and attempts to "addChild". No errors, but no results.The thing is, in setupBoxes i even tryed using this code which i found on another forum.
PHP Code:
improt AD;
//creation of class and brakets and things.
public static var ad:AD;
//long box2d and setup process and more brackets...
ad.addChild(container);
So, how do we write a class over several files in action script 3? In C# there's the "partial" keyword. In C++ it's natural (you just "#include ..." all files). In Flex 3, in a component, you add this tag: <mx:Script source="myfile.as"/>.
How do I split the following class into several files;
package package_path {
public class cSplitMeClass {
public function cSplitMeClass() {
} public function doX():void {
// ....
} public function doY():void {
// ....
}}}
For example I want to have the doX() and doY() functions implemented in another ".as" file.
I'm developing a tile engine with actionScript-3 for IOS machines. Is there a way to package JPG files with IP and then read them with Adobe Air's FileStream Class. I need to read files asynchronously.I understand how it works on desktop.
var file:File = File.documentsDirectory.resolvePath("myfile.txt");
On desktop, means:
[user_dir]/Documents/myfile.txt
[code].....
I am requesting a standard method, in compiling .AS Class files into a central FLA. I am not seeking to upload seperate .AS class files, in efforts to have the designated SWF, call simplistic actionscript in URLs, published outside of the designated SWF, in efforts to function.
View 5 RepliesI am requesting a standard method, in compiling .AS Class files into a central FLA. I am not seeking to upload seperate .AS class files, in efforts to have the designated SWF, call simplistic actionscript in URLs, published outside of the designated SWF, in efforts to function.
View 1 Repliesi feel difficult to use class files in games.. Can any one help me to start?
View 1 RepliesHow would you go about accessing a movieclip inside another movieclip using a class file?ould you have to export every single part of a movieclip? Can it be done by just exporting the main movieclip?
View 2 RepliesI'm working with Loader class in as3 and there comes some really strange problem. I have two swf files, one loading the other. In the first one, I have codes like this:
var loader:Loader=new Loader();
var context:LoaderContext=new LoaderContext();
context.applicationDomain=ApplicationDomain.curren tDomain;
var req:URLRequest=new URLRequest("Untitled-1.swf");
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,onCPL);
function onCPL(e):void{
trace("finish");
addChild(e.currentTarget.content);
}
And the second one, with the name "Untitled-1.swf", doesn't seem to work in the first one. I find out that as long as there are ANY codes in the second swf file, the first one will repeat tracing "finish" endlessly.
I have a photo gallery, with a thumbnail panel (a photo viewer page) that I made, coding the AS3 from the key frame. It just so happens that I saw some class files online that have some good stuff in the tutorial.I've never really worked with .as files and I am intimidated by them.Would it be easier to modify my photo gallery, with a thumbnail panel, from key frame to .as AS3 code or to go from .as to key frame code? I personally feel more comfortable with key frame AS3, but I am not scared to dabble.How can I practice adding a couple of class files to my key frame AS3 code- I'm using regular variables, but the interesting idea I saw uses private variables and public functions, and it imports some stuff?
View 1 RepliesI'm new to writing several different class files.. and trying to make a set of boxes that expand/collapse by mouse click and timer..
I have 4 class files, Box, BoxGroup, BoxTimer, and Main.
I can call the functions in Box class from BoxGroup class, but not the functions in the BoxTimer class. it keeps throwing this error. I don't understand why since i'm using the same method between the other 2 class files...
ReferenceError: Error #1069: Property timer_start not found on
CollapsingBox and there is no default value. at
CollapsingBoxGroup/on_click()
[Code].....
I've got a class that I create that extends the EventDispatcher class. My class has lots of variable declarations and getter and setter functions. I would love to split up the class into multiple AS files so that I can organize the variables and functions by category. Is there any way to do it and still maintain a relationship between all of the files so that one can easily call a function or a variable that exists in another? And so that other classes in my application can refer to one reference when accessing public functions in any of the AS files.
View 3 RepliesI know that a class definition can not extend to two .as files, it has to be in one.My question is, can 2 class definitions be on one .as file or, do all class definitions have to have their own exclusive .as file?
View 9 RepliesI'm new to writing several different class files.. and trying to make a set of boxes that expand/collapse by mouse click and timer.I have 4 class files, Box, BoxGroup, BoxTimer, and Main.I can call the functions in Box class from BoxGroup class, but not the functions in the BoxTimer class. it keeps throwing this error. I don't understand why since i'm using the same method between the other 2 class files..ReferenceError: Error #1069: Property timer_start not found on CollapsingBox and there is no default value.at CollapsingBoxGroup/on_click()
View 11 RepliesI have two class files that extend to movieclips......one targets _root.scrolling_mc, the other _root.messages_mc. I have multiple movieclips throughout the presentation with instance names scrolling_mc and messages_mc. This is where it gets interesting. After navigating from a scene with scrolling_mc to a scene with messages_mc, some of the behaviour of the scrolling_mc is still triggering. Its almost as if both class files are working side by side.
View 3 RepliesShort description of my project:I'm making a "flash-car-damage-registration-program" where a user can click on a part of a car, make two choices (from two comboboxes) that describes the damage, and then save it in a datagrid withing flash.I have split up the code in different class files:I have a damage.as class file that describes the damage and its properties.I have a carPart.as class file that extends the Movieclip class. This sets all the propertiesof each carpart and where the roll-over/out eventlisteners are, pluss som escriptive text to each carpart. This works the way I want it to. This is just to quickly give you an idea of what I'm working on.So to the real question or problem: I have a LoadMyXmlData.as class file where I load some xml data, this works fine. A function in this class takes a combobox and a xmllist as parameters.
I want to populate the mentioned comboboxes from the xml data. Both comboboxes are on the stage within another movieclip, but I can seem to access them. (yes, they have instancenames etc) I get error 1120: 'Access of undefined property'. I have tried ways like: containingMc.comboboxMc' and so forth but no luck. I have been searching the web for days for a solution to my problem, but nothing so far.
I use flash CS3 on Mac OSX and I'm creating several AS2 projects with .as class files. Everything code-wise is working perfectly. The problem comes when I make a change to a particular class file, save the file, and the republish the fla. The changes are almost never reflected in the published swf. The only thing I've discovered to work around this problem and actually get my changes published is to publish to a different flash player version, and then republish back to the version I really want. Somehow that seems to actually get flash to load the most recent version.
It seems like this might be some sort of flash caching problem, but I have no idea how to tell it to always check for the newest version of the file.
I'm trying to get the as3corelib to work as when I run my file at the moment it tells me: 5001: The name of package 'com.adobe.images' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. /Users/markbunyan/Websites/craftmagic.co.uk/JPG_encoder/JPGEncoder.as I thought I had imported the as3corelib fine but can't get this to work. Can I simply import the code from JPGEncoder.as???
View 3 RepliesI just got a copy of Flash CS4 and I can't find the fl.video classes... almost impossible to code without the need classes...
View 4 RepliesI'm making the game Breakout as an AS3 application using OOP. I am getting very confused though. I know that objects should be only responsible for themselves. But this is where I get stuck, they need to communicate as some level to add and remove screens, and I am getting majorly confused as to what is going too far, when it could maybe achieved in a simpler more OOP way.
I've worked out the hierarchy of my classes, in terms of where they are being added (I think). Here it is roughly drawn out below. Have I got the order right based on OOP principles? Like, Introscreen will listen for play being pressed then call a method of the document class that will remove introscreen and then attach gamescreen. Is that right?
Another thing that puzzples me. It seems to me if I made a level and put the paddle and the ball in that, then arranged all the bricks in that level, that I'd be duplicating work (based on the fact I need paddle and ball for level 2 also). So it would be best if I could have gamescreen with paddle and the ball and then add level1/2/3 to display list which would therefore set up the appropriate brick placement. But then, wouldn't that mean that I couldn't do hittests because my level 1/2 or 3 wouldn't be a sibling to the bat and the ball, them residing as a sibling in the level's parent class?
[code]....
In the Flash app I'm building, I have a "main" SWF that will load a variety of "child" SWFs.
All of the AS3 code for both the main SWF and child SWFs is contained in external .as class files.
In other words, each movie has it's own document class .as file.
There are also a number of .as class files for all of the common elements (e..g, UI buttons and controls).
So - for example - both my main SWF and all child SWFs use the "MyCommandButton" class; the code for this class is in MyCommandButton.as, which all SWFs reference (import).
Here's what I don't understand.
(Let's say that the code in MyCommandButton.as draws buttons that are red.)
First, I compile ALL of the child SWFs.
Next, I change MyCommandButton.as, so that the buttons it draws are blue, instead of red.
Then, I compile the main SWF.
When I run the app (main.swf), I would expect all of the buttons in the main SWF to be blue (since that's what MyCommandButton.as specified when main.swf was compiled), and all of the buttons in the child SWFs will be red (since that's what MyCommandButton.as specified when they were compiled.)
Instead, ALL of the buttons are blue, which means the change I made to MyCommandButton.as affected all of the child SWFs, even though I didn't recompile them.