ActionScript 2.0 :: Referencing To Class Members From OnSoundComplete?
Sep 28, 2010like at the object, i have a class like that:
class myClass
{
var sound:Sound;
var num:Number;
public function MyClass()
[Code]...
like at the object, i have a class like that:
class myClass
{
var sound:Sound;
var num:Number;
public function MyClass()
[Code]...
Are static members slower to access than instance members in AS3?
View 1 RepliesI have a class ABC:
class ABC
{
var l:Label=new Label();
var m:MovieClip=new MovieClip();
}
Given an instance of class ABC, e.g. obj:
var obj:ABC=new ABC();
I need to access both obj.m and obj.l. Say m has an eventlistener fl_listen which gets triggered on a mouse click:
function fl_listen(event:MouseEvent):void
{
var k=event.target;
}
Within this handler, I can access the MovieClip of ABC class. However, my requirement demands to access the object of Label in the ABC class too.
I have two objects, both brown squares. I want them to be members of the same class but one square to have a number "1" in the center and the other to have a number "2" in the center. Any ideas on how I might accomplish this? Any clues on how to instantiate a vector drawing (drawn in illustrator) from ActionScript 3 as opposed to dragging it on stage from the library in flash?
View 3 RepliesI'm working in CS4. I am trying to add 20 squares to the stage. Each square must have a different number in the middle(1, 2, 3, etc.).
This is my code so far:
ActionScript Code:
package {
import flash.display.Sprite;
[Code]....
Ideally, I would like the squares to be added automatically, with increasing numbers and 100 x 100 pixels apart. Possibly a 'for-loop' statement?
I have a class, ClassA which is a MovieClip. Inside of that I have about 20 other MovieClips that are associated with ClassB.
In my main timeline I have something like this, instantiating ClassA and then calling a setup function in it.[code]...
I have a class, ClassA which is a MovieClip. Inside of that I have about 20 other MovieClips that are associated with ClassB.In my main timeline I have something like this,instantiating ClassA and then calling a setup function in it.
Code:
var obA:ClassA = ClassA(attachMovie("ClassA", "classA", getNextHighestDepth()));
obA.setup();
[code]......
Let's say we have following class[code]...
In Flash Player runtime, is there a way I can get a list of all the static members of lass PlayerEvent.
Something like:
trace(PlayerEvent.staticMethods) // ["PLAYER_INIT", "PLAYER_MOVE", "PLAYER_USE_SKILL"]...
I have a class which deals with a lot of visuals, which essentially are movieclips. So I have around 50 privately declared movieclips in the class. Would it be a good idea to put them in a dictionary and retrieve them by their name (as key) , put them in an array or just leave them as they are?
My issue is the visual look of my class right now with that many private members, looks like a mess visually.
So i have a movieclip with a textfield in it. Also there is a class for this Movieclip. This all is exported to a swc that is linked into other projects for reuse purposes. However I cant access the textfield from classes in other projects. I get the 1009 error. Even when accessing ti from the Added to stage event.
View 3 Repliesi have a problem, here's the error code:
Code:
Warning: 1072: Migration issue: int is not a dynamic class. Instances cannot have members added to them dynamically.
and the source:
Code:
public function getStartUpData(param1:MovieClip, param2:MovieClip):void {
(null | null <= this)._111d = param1;
this._111f = param2;
_111e = new MainInterval(param1);
[code]...
Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.
I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().
I hate to be defiant, but what if I don't want to?
Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?
It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.
That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.
HERE ARE THE STEPS I'M TRYING:
- Create new flash document
- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage
- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()
- Set a name for that box using box.name = "test" let's say
- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great
- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";
That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?
I need to increment an integer variable in a function within the document class upon transpiring event in another class. I can't seem to figure out how to call the function and reference the variable.
View 2 RepliesI have an enemy on the stage that reads whether it's being hit by a bullet by a hittest. There's a for loop inside the enemy's class that looks for all the bullets and names the bullet that's hitting it "hitBullet". What I'd like to do have an easy way of seeing what type of bullet is hitting the enemy. I'm basically looking for something like
if (hitBullet == RegBullet) {
//do regular bullet dying
}else if (hitBullet == ClusterBullet) {
//do clusterbullet dying
}
, where RegBullet and ClusterBullet are classes. But I have no idea what hitBullet is equal to when a ClusterBullet or RegBullet hits it. I traced hitBullet to see what it would return and got "[object ClusterBullet]", but I'm not sure what that would be in the actual code.
I have a class called Circle and a class called ShapeFade, both with their own .as files. How do I add an instance of ShapeFade to Circle inside the Circle constructor? Like in the Circle file:
PHP Code:
public function Circle () {
this.addChild (ShapeFade);
}
Also, can I override a class function from the code window in the stage?
I have this script in a movie clip. It should go to the keyframe shown after sound completes, but it doesn't and I'm wasting too much time trying to figure it out.
FYI - the sound does play and the trace does appear. It just won't go to the frame I want.
//script***********************************************
applause= new Sound();
applause.attachSound("applause2.mp3");
[Code]...
I don't have the cash right now to get Flash CS3, so I'm limited to using Actionscript 2 and that's what I have here. What I'm trying to do is use the onSoundComplete(); function, or something similar but not getting any results.
I'm doing a basic sort of mp3 player, though it only rotates between 3 songs. I have a character walking on stage as a movie clip, he's carrying a radio which is a nested movie clip within the first, and within the radio movie clip is where I have it set that you can manually advance from one song to the other by hitting a forward button, and there's also a volume slider. The first default song playing is "letsDance", The second song playing is "outtasite" and the third song playing is "please". They all work perfectly, the forward button to advance works, and the volume slider works.What doesn't work is when one song finishes, I want the next song to start. For now, I only included code for going from song 1 to song 2, but that's not working so I decided to stop there.
Unfortunately, with the three .mp3s included even at 20 seconds each, my compressed .zip file is 1.2mb, bigger than the allowed 146kb .zip on the kirupa forum. Therefore, I cannot post it on the forum, but have it hosted on a web server. Anyone willing to look at the file, you can find it at:
http:[url]...
What's in this .fla file right now is just the radio button and the volume slider, nothing else. I didn't want to include any unnecessary extras so even the three songs that are included are even shortened down to about 20 seconds each. Each of these songs are located externally from the .swf file and are called in through the "loadSound" command.Anyone who could shine some light or advice on why this isn't working or a better way to follow on what's going on here. I've read other things online about onSoundComplete(); like being used with music in arrays which I guess I could do, but I want to be sure I have control of advancing one song to the next and also adjusting the volume. Other things I've read about onSoundComplete(); is that it just doesn't work.
In As 2 you were able to reference a linkage ID using a string.Example
Code:
var strName = 'home';
attachMovie(strName+'_mc', strName, 1);
[code].....
I usually would call the parent of my class by something like:
MyCustomClass1(parent).thisFunction();
My problem is this works if I know the class of my parent. How do you handle the case where you class could have a parent of 2 or more possibilities?
parent.thisFunction(); // throws error of course
A have two classes: Main and Navigation. I try to referenceobject in Main class from Navigation class based on the buttonnumber I clicked. Doesn't work as I want it to work. What can I do
View 1 RepliesI have externalized the actionscript code of a movieclip into a separate class files.This movieclip requires references to some other clips on the stage. What I am currently doing to reference those clips is by using Movieclip(this.parent).otherclip but somehow that feels wrong.Is there a better way to pass in the required references into a class extending from Movieclip inside of the constructor? Or what is the recommended pattern here?
View 2 RepliesI have a bunch of variables in a class. There are situations when I want to set then to null/ "temp" etc as per a well defined logic. The challenge is to list out the variables at multiple places- tedious and error-prone.
classname.speed=NaN
classname.speedtype="not_set"
classname.distance=NaN
classname.distancetype="not_set"
would prefer a way to refer to these variables programatically and set something like "for all class variables- if variable ends in type, set as "not_set"; for other variables set as NaN How can I achieve this?
I can import other classes to the timeline and use them just fine, but this class is giving me major problems? I am parsing XML data from my server on it and it is giving me errors that look like this.
The timeline reference and usage:
import networkScores;
var network:networkScores = new networkScores();
addChild(network);
score1Textfield.text = network.score1.toString();
[Code] .....
The errors I am getting:
Scene 1, Layer 'Actions', Frame 4, Line 149 1119: Access of possibly undefined property score1 through a reference with static type networkScores.
1067: Implicit coercion of a value of type networkScores to an unrelated type flash.display:DisplayObject.
I'm working on a game that pulls most of its information from an SQL table. The game itself has several different items that derive from a BaseItem class, and all have widely varying behaviors. While deriving these classes from the BaseItem class and scripting the correct behavior is easy enough, I'm having a bit of trouble trying to come up with an efficient way of storing the information for these items so that not only will the items be in the state that the user left them when they were last saved to the database, but they will be the correct item when loaded from the database in the first place. I'd like to do this with as little pollution of the iteminfo table as possible (for instance, I want a Truck item to have a "wheels" value of 4, but I don't want an item_wheels field on the row if the item is Pogo-stick).
So far, my best idea has been giving iteminfo an "itemtype" field that accepts an enumeration, like ITEM_TRUCK or ITEM_POGOSTICK, and using a switch statement in AS3 to instantiate the correct item based on the pulled value, but this seems rather sloppy.
The thread title says that I want to reference a class directly from a table, but if I knew how to fix this I'd have done so already, so I'd love to hear any solutions. And just for the info: I'm working with a combination of AS3, PHP, and MySQL.
Is it possible to use a class name stored in a string and pass it as a parameter??I'm using the push method in a flex mobile project. I have the name of the view I would like to pass into the push method stored in a string. But the push method only accepts it as a class not a string.How do I use a String to load or pass the class name to the method?
var NameClass:Class = "views.Contact";
navigator.pushView(NameClass);
just thinking out the setup of a sidescroll/platformer..i want the player not to fall through the floor or go through walls i know how to hittest with a single object, but what i have is various objects that extend the class wall. if I hittest with wall will that also apply to the serrated_floor and portcullis classes that extend wall?
View 1 RepliesI have a swf that is loaded into my main swf with the loader class. When I click a button in the main swf I want to call a function in the loaded swf Main class.
When I do a trace it is showing the loaded clip as [object Home] which is the name of the Main document class associated to the loaded swf. I have a public function in my Home.as called startAnimation() but when I try to call it I get
[quote]1061: 1061: Call to a possibly undefined method startAnimation through a reference with static type flash.display:Sprite.
How to access stage elements from within a class.
buttonControls.as
Code:
package {
import flash.display.Sprite;
public class buttonControls extends Sprite {
// Navigation Hover Color
var hover = "0xF1E960";
var normal = "0xFFFFFF";
public function changeColor(object, color){
[Code] .....
and I'm trying to add an event listener and a function to the class, but I keep getting errors of undefined, I tried just about everthing to be able to refference obj0
objGroup.obj0.addEventListener(MouseEvent.CLICK, onClick)
private function onClick (event:MouseEvent):void{
trace ("Click");
}
I'm developing a Hygrometer in Flash CS4. The Hygrometer is a Movie Clip currently on the stage with 16 Movie Clips inside with instance names like segment01_mc, segment02_mc.. segment16_mc. I'm trying to make a class for the Hygrometer MC and I need to access the "segment" MC's. But I can't find a solution.
Is there any way to reference the "segment" movie clips? How can I assign instance names to the "segment" movie clips?
Here's my current Hygrometer class code:
[Code]....