ActionScript 3.0 :: Timeline Code And Separate AS File Code Working Together
Dec 27, 2010
Is there a way to make code on the timeline and code in a separate AS file communicate with each other?I have two buttons, a yes button and a no button.I have a confirm box which is a movie clip. In the movie clip I have the two buttons on it and code so that every time one of the buttons is clicked it runs a function.I have the rest of my code for the movie (so the code to make the confirm box appear) on a separate AS file.Is there a way I can define the functions on the movie clip and run the functions with the separate AS file?
View 7 Replies
Similar Posts:
May 18, 2011
I made a button a stage, and I want the button to take the user to a separate scene that I have named "Biography page" when it is clicked. The thing is, I want all my actions on one specific layer. So I made an instance name for my button, "aboutme". The thing is... I have no idea how to write the code.
[Code]....
View 3 Replies
Feb 17, 2009
I've just been following the Basics of Papervision3D tut, which is very good by the way, the only one I've ever managed to get working.And I'd like to write the code as a separate as file, but I'm having a bit of trouble.In the class definition, what should it extend?[code]I tried everything I can think of and looked at other tuts to see what they've done but nothing works.
View 1 Replies
May 22, 2009
I wanted to have this Zombie Penguin enemy use a walk sound (it would be odd if he moved and was silent) but because it is initializing the whole world, simply coding the sound into his animation state won't work because it will play the sound for every existing Zombie Penguin in the world, not just the one on the screen.
Now I've tried to get around this problem by using a SoundManager class [URL] to load and play/pause the sound when necessary. I've got this working by placing a movieclip above the world and hittesting everything and when it finds a Zombie Penguin activates the SFX. If it finds the enemy and you leave the room or kill the enemy (basically any way it is removed from the screen) it will pause the sound (not stop) and then unpause if you go back/find another instance of that enemy.
The problem is, though, that if I STUN the enemy (not kill it) it plays it's dizzy animation (which consists of hit sitting down with stars spinning around it's head) the walking SFX continues to play as the enemy is still on the screen.Now in the Zombie Penguins .as file it has a boolean that for being stunned or not (bStunned), and a function (public function getZPStun():Boolean -- returns bStunned). this bStunned boolean is set to a default of false.I figure that I just have to reference that somewhere in the following code, but I'm not sure where. The Zombie Penguin's .as is ZPEnemy, so I'm calling it like so:
ZPEnemy.getInstance().getZPStun()
I've tried calling it as part of an if statement a in a number of placesin hopes that calling it will relate the current state of the bStunned boolean, but I can't seem to get it to work.
Code:
var bNotPenguin = true;
for(var i = 0; i<this.numChildren; i++) //** Sound Manager Coding (May 15)
{
[code]....
View 4 Replies
Jan 12, 2011
As stupid as my question might sound, i have spent the last 2 weeks reading oop books; but could use some guidance. I have a flash project that is basically a supped up slide show. On the stage i have the following: main_mc (instance name = images_mc) = movieclip which holds "pictures" ui1 (instance name = ui1_mc) = user interface that allows user to draw on picture (when drawing is enabled) ui2 (instance name = ui2_mc) = activates invisible hit areas (buttons) on select pics, when hit area is clicked, we jump to another pic in the main_mc.
I accomplished all of this on the timeline, but am updating the code to OOP. I am having A HELL OF A TIME trying to figure out how to store references to the instances (images_mc etc..), so i can control them from varying class files. I have found it is easy to control the instances from the documentclass, but not from unrelated class files. Example: images_mc.stop(); works in document class; but ovieclip(Parent).images_mc.stop() doesn't seem to work from any class file.(ui2 class file for example);
[Code]...
View 2 Replies
Jan 29, 2012
I'm looking for a way to have my main timeline code interact with code inside of a symbol.I'm tying to get my timeline inside the symbol to gotoAndPlay(10) when something happens in my main timeline code.
View 3 Replies
Feb 9, 2009
I'm trying to move my code from thetimeline to an .as file. I have been doing pretty well for a fewmonths jumping in and learning AS3 in a professional, need to getthis online and working type environment, but I have yet to workwith .as files. One thing I'm wondering is: I have 61 lines of code for oneapp and they do a few different things. Do I put these all in thesame package? If I don't, how do I tell my .fla to load more thanone class? The examples of .as files I have found have beenhelpful, but they are all very rudimentary.As you can see from my questions I'm kind of in the dark hereand Ohe yeah - my timeline coderesides in it's own "actions" layer.
View 3 Replies
Dec 23, 2007
Here i'm actually not talking about a problem but rather wanted to raise a discussion thread. (Kirupa you may also move this thread to some other more relevant section. Few of my good colleagues till prefer writing code on the Flash timeline, on the frames (code as bigh as 100-150 lines), rather than using external AS files, when rest of the world has reached to AS 3.0 which is close to Java (OOP).I'm just wanted to know the big benefit of writing the code on the frames. I know that it is highly un-manageable and I have personally faced many instances of code not initializing, or behaving strange on a frame.
View 3 Replies
Mar 16, 2010
I am trying to find out how to make one .as file code interact with another .as file's code.like, if I had one .as file that specified options of movies and then when the user clicks on a movie (loaded through xml) it uses code from another .as file to load the correct movie.
View 5 Replies
Dec 8, 2010
Im currently trying to make an as3 fantasy football application for my uni course, but am finding it hard to seperate the code I have written into classes (which I have no been told is the only accepted method for the marking scheme). So far I have an external XML file containing player names load into a datagrid component, there is then an event listener on the table which loads the player images into their correct positions on a pitch when clicked. I need to write more functionality for it including saving to XML and error handling but feel I need to sort out the classes situation before I continue and it is in for this week.
Code:
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.controls.ScrollPolicy;[code]..............
View 0 Replies
Oct 22, 2010
I'm looking for some help with the following script:
Main Class:
Code:
package {
// Flash Classes
import flash.display.MovieClip;
import flash.events.Event;
[code]....
Now, I'd like to move the blue color coded script to the separate package. When I do that, I've got many reference errors. how the code should look like, when it's in separate package, with all the references to variables that work? And how to call this function from Main class?
View 1 Replies
Oct 14, 2011
I have an Actionscript coded flash file which run perfectly without any error. I am not getting why it shows an error after i do insert a scene before or a frame before the current frames;
[Code]...
View 1 Replies
Oct 22, 2010
Main Class:package {// Flash Classesimport flash.display.MovieClip;import flash.events.Event;import flash.display.StageAlign;import [code]........
Now, I'd like to move the script between --- Start --- and --- End --- comments, to the separate package. When I do that, I've got many reference errors. how the code should look like, when it's in separate package, with all the references to variables that work? And how to call this function from Main class?
View 5 Replies
Mar 26, 2010
I have an xml gallery sort of that works fine when I have the code not as a class, in first frame in Flash. So I decided I wanted to port it into a class and the problem I get is at:
thumb = new Thumbnail(xmlList[i].image);
It expects 0 arguments. How come that line of code works in first frame in flash but not as a class? There is a movieclip in the library called thumb with linkage of Thumbnail.
Below if the code when used in first frame:
PHP Code:
var urlRequest:URLRequest = new URLRequest("pics.xml");
var urlLoader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList;
urlLoader.load(urlRequest);
[Code] .....
View 4 Replies
Sep 6, 2011
Someone asked me an interesting question on Twitter about when one should have code on the timeline as opposed to a class. My answer was never unless you are controlling the timeline itself.
After thinking more about it, is that really the correct answer? Are there other situations where you may want to have code live on your timeline even if it doesn't have anything to do with the timeline itself?
View 5 Replies
Jun 13, 2009
I am makine my first attempt at coding a site with Actionscript 3. I have coded two buttons, both directing to another scene. The first one works. The second one stops the timeline and never gets read. Here is the code on frame 65:
[Code]...
View 11 Replies
Nov 17, 2011
How would I get to play backwards a timeline from a specific frame to another frame?
I need to be able to play back from frame 62 to 1 and from 101 to 62 depending on what frame I am on. I know I can do 2 if loops with if (currentFrame == 62) etc but what is the code to play the timeline in reverse for AS3?
View 2 Replies
Dec 4, 2009
I'm creating a simple banner for my site. I found some cool landing confetti code but it seems like after it hits the keyframe with the confetti actionscript it stops and the rest of my simple timeline animations don't play. I just wanted to have a few type animations and a logo fade in and out while the confetti is falling. I removed the stop on the confetti frame and after I do that the animations play but the confetti doesn't work. This code is on the main timeline that causes it to stop
Code:
// pause after how many seconds
vSeconds = 11;
vFPS = 20;
[code]....
View 6 Replies
May 11, 2010
I am using onLoad and onEnterFrame events to dynamically align my_mc. The problem I face is the following:When I put my code in the mc instance it works beautifully but when I put it in the timeline it does not work.[code]I assume it is something tiny, perhaps it is an issue with the correct paths of x and y. I tried in many ways changing paths to this._x and my_mc._x but unsuccessfully.
View 1 Replies
Nov 20, 2010
here's a part of my code:
player_mc.onEnterFrame = function() {
if (enemy0.hitTest(this)) {
enemy0.speed = 0;
} else {
[code]...
Note the red code, I need to repeat this an unknown amount yet multiple times but with the number on the end of enemy incremented by 1 each time. It starts with 0 as you can see the code just above the red. I heard about for loops using 'i' but im unsure about how to use it.
edit: ah, this forum isnt letting me highlight red. Everything in this editor is also failing. well, when I say code in red i mean this code:
if (enemy1.hitTest(this)) {
enemy1.speed = 0;
} else {
enemy1.speed = 1;
}
View 3 Replies
Jan 22, 2011
I'm looking for a workaround to the "AdSense does not let you choose only images but no flash" issue. I'm rather a newbie to JS, but is there any way for one script to prevent other scripts embedded in a site from detecting the presence of the flash plugin? Even if it doesn't work with AdSense, it would be nice to know if there's a hack to do this that might work in other settings.By the way, I suppose I wouldn't care if it failed to work on IE or obsolete browser versions.
View 1 Replies
Jul 10, 2003
I have attached a simple test fla.I am trying to centralize my code in all my movies using dot notation instead of spreading my code all over the place. It never works, I must be doing something wrong.The test .fla has a movieclip with a timeline animation. I used the linkage identifier to name it 'reload' AND named the instance 'reload'.
_root.reload.onRollOver = function() {
this.gotoAndPlay(2);
}
The pointer doesnt even change to a hand.
View 4 Replies
Mar 27, 2011
Got to the point where the hole in my AS3 knowledge is getting large!Realising I have confusion about the relationship of:Body of code on first frame of AS3 file.(Which I have so far used to create instances of library objects using addchild and make calls to class code).Is this code called the document code? What do people call it?Numerous classes linked together by extending each other etc.Library objects (usually graphical objects)Should it be done differently? have the following problems due to lack of understanding:Addchild complicated from a class but straight forward in main body code.Cant call functions on the main body code from classes, because class code does not know the main body code exists?
View 1 Replies
Feb 4, 2010
I have 2 tables,a main table with a field code as primary key, and other table detail, named p.e. DetailTable, with 3 fiels as primary key.What I want to do, it's a delete a row in MainTable, all the rows in DetailTable,where field code is the same as field code in MainTable should be deleted too.Here is the SQL to create the tables.
var sql2:String = "CREATE TABLE IF NOT EXISTS MainTable [code]....
when tables are created, insert data. I connect without problems, delete a row in MainTable (see the code), for example delete row with code=4, but in the DetailTable, all the rows with code=4 are NOT deleted Why?
[CODE]// Inside a class
private var conn:SQLConnection;
public function constructorClass(){conn = new SQLConnection();ConexionBD();}[code]...
View 3 Replies
Jun 9, 2011
I've literally been staring at this for 7 hours. I'm missing something.I have two movie clips on the stage. The instance name of the first is puzzleAK. The instance name of the second is pieceAK.The first is linked to a custom class called GeoPuzzle. The second is linked to a custom class called GeoPiece.The code compiles but throws an error (as explained).The code in the main timeline:
puzzleAK.fullName = "Alaska";puzzleAK.abbrev = "AK";puzzleAK.isLocked = false;trace ("made it through puzzle definitions: " + puzzleAK.fullName + " " + puzzleAK.abbrev + " " + puzzleAK.isLocked);
[code].....
View 7 Replies
Aug 25, 2004
What library/API or even a program for converting flash code into html 5 code automatically do you recommend me?
View 2 Replies
Jun 9, 2009
I'm making a mini-game, so ive got various scenes and stuff going on. I found this rain effect [url]... and it works fine and looks pretty good, the problem is I don't know how to get the damn thing to stop! I'm a beginner so know very little actionscript and can't figure this out myself. I do not want the timeline to stop playing only for the rain to stop.
View 5 Replies
Feb 17, 2011
I have a button named 'red_btn' which is placed on different keyframes at different positions on the stage. but the function of all the instances is same, on mouse over should move timeline to nextframe. [code]...
View 1 Replies
Oct 6, 2009
i need to code a button in the main timeline and this is the code im using:
ActionScript Code:
stop();
stuff = 0;
day = 1;
money = 50000;
[code]....
There is an error with line 9- the one in bold. its a syntax error- but whats wrong with it!
View 9 Replies
Oct 26, 2010
I am publishing an animation which needs to dispatch events from certain frames on the timeline. The document class is InteractiveAnimation - here's the important bit:[code]When I load it into my player application (into the same ApplicationDomain, I might add) all I get is:"Running constructor of InteractiveAnimation" the timeline trace doesn't happen. Or any other timeline code for that matter.What is killing the framescripts? Has anyone even got any suggestions as to how I might continue to track this down?
View 2 Replies