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




Using Classes That Inherit From MovieClip?



Hello all.

I was wondering if the wonderful people at kirupa could shed some light on how I would go about creating a new instance of a class that inherits from the MovieClip class. Rather, I know how to adjust linkage properties inside the library, and can create new instances that way.... but my main problem is that a good number of times I find I want to create a new instance using the Constructor function, which is chock full of parameters that I use inside the class. I currently have a class called MenuButton, and if I use Linkage properties, I can make it all work just fine... But I also have a class called Menu, which arranges those MenuButtons... by creating them using MenuButton's Constructor. According to my code, these instances are created... but they are not visible and do not show up in the debugger.

Any help anyone could provide would be greatly appreciated.



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 07-17-2004, 01:34 PM


View Complete Forum Thread with Replies

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

Using Classes That Inherit From MovieClip?
Hello all.

I was wondering if the wonderful people at kirupa could shed some light on how I would go about creating a new instance of a class that inherits from the MovieClip class. Rather, I know how to adjust linkage properties inside the library, and can create new instances that way.... but my main problem is that a good number of times I find I want to create a new instance using the Constructor function, which is chock full of parameters that I use inside the class. I currently have a class called MenuButton, and if I use Linkage properties, I can make it all work just fine... But I also have a class called Menu, which arranges those MenuButtons... by creating them using MenuButton's Constructor. According to my code, these instances are created... but they are not visible and do not show up in the debugger.

Any help anyone could provide would be greatly appreciated.

AS3 How To Inherit From 2 Classes?
Hi, I know that in AS3 there is no multiple inheritance. So, what in general can be don in the following situation: someone has written a class that extends Sprite and has some cool methods and features. But someone else has written another cool class that also extends Sprite. I would like to reuse features from both classes. What is my option here? the obvious solution would be to create an object that extends both classes.

Subclass Doesn't Inherit Superclasses Imported Classes?
If you have several subclasses all depending on an identical import statement, and you can't just plug the import statement into the super class to access the imported classes public methods/members, then what is considered best practice?

I don't want to have to import Globals in each subclass....consider me lazy = ]








Attach Code

package{
import Globals;
public class classA{
public function classA(){};
};
};


package{
public class classB extends classA{
public function classB(){
/////////////////////// 1172: Definition Globals could not be found
trace(Globals.sayHi());
};
};
};

























Edited: 09/15/2007 at 10:58:00 AM by cayennecode

Duplicated Movieclip Doesn't Inherit Loaded Movieclip
I'm loading an image into a blank_mc within a movieclip called 'background_mc' using the MovieClipLoader object; when the onLoadInit for the MovieClipLoader object is fired, i then attempt to clone my 'backgound_mc' object and the loaded image it contains so i can do something with it (i,e a funky masky/blur thing, not important right now)

I'm successfully loading my image into the blank clip within background_mc, the onLoadInit behaviour fires and duplicates background_mc once the image has been loaded, but in a disappointing turn of events, my clone of background_mc no longer has an image attached, and has instead reverted back to it's original form, just as ti was before it had the jpeg image loaded in.

Has anyone ever encountered something like this this before regarding the duplicateMovieClip command, and if so can anyone suggest a workaround?

*goes off to boost karma by helping others*

Thanks!

Chris

Constructor Of Class The Inherit MovieClip
How can I pass parameters to a constructor of class the inherit MovieClip?

Constructor Of Class The Inherit MovieClip
I am linking a movie clip with a class the extends it.
The constructor of this class should get parameters.
How can I pass the parameters to the constructor?

Editing A Movieclip Inside A Movieclip & Classes
Hey guys,
iv created a movieclip (let call it movieclip ParentClip) inside my .fla file, and i made my movieclip out of 3 other movieclips (Lets call them ChildClip1, ChildClip2, ChildClip3). I have made a parent class called 'BaseMovieClip' and each Child Movieclip has its base class set as 'BaseMovieClip'.

So does anyone know how 2 access the movieclips that are in ParentClip?

thanx in advance



btw, im creating a 3d flash engine, what does everone think of that? worth it? its going well so far, about 80% done.

Movieclip Classes
Im building a movieclip class and it works fine if I do this

_root.attachMovie("vmGlyph","visual_VM",recycleBin.newLevel())


but if I do this... it just breaks.

_root.createEmptyMovieClip("origin", recycleBin.newLevel())
origin.attachMovie("vmGlyph","visual_VM",recycleBin.newLevel())

does anybody know why this is? Any suggestions?

When I trace "this" in the class code, it does have the correct name (if _root is used)

[F8] Movieclip Control Through Classes
hi,

I have a movieclip which has a linkage identifier and a subclass, called respectively 'user' and 'ClickableUser'.

I created a class called ClickableUser which extends the MovieClip class.

So after this I assumed that I would be able to control the movieclip which I added to a timeline using the attachMovie("user" ...) method.

But I can't! I used the onLoad function inherited from the MovieClip class in my ClickableUser class, wherein I traced the _currentframe property to check if my class was actually attached to the movieclip, and it worked!

So somehow I can read the properties of the MovieClip class, but I am not able to use the movieclip control methods like stop(); or gotoAndStop(); does anybody has an idea what's happening here :S?

How To Create Movieclip Using Classes?
Hi,

I m new to Flash. I need to develop Flash application for mobile devices.
I have created a class and using that class i created a movieclip.

I have created one more class. And whenever the enter key of the mobile device is pressed i need to create a movie clip using the second class.
How to do this?

this.attachMovie("PieChart_mc", "pie_chart"+vPieChartDepth_num+"_mc", vPieChartDepth_num, vPieChartProperties_obj);
var vThisPieChart_mc= this["pie_chart"+vPieChartDepth_num+"_mc"];

keyListener.onKeyDown = function() {

switch (Key.getCode()) {
case Key.UP :
vThisPieChart_mc.highlightPreviousWedge();
break;
case Key.DOWN :
vThisPieChart_mc.highlightNextWedge();
break;
case Key.LEFT :
vThisPieChart_mc.highlightPreviousWedge();
break;
case Key.RIGHT :
vThisPieChart_mc.highlightNextWedge();
break;
case Key.ENTER :
vThisPieChart_mc.removeMovieClip();

var newDepthNumber:Number;
newDepthNumber = vPieChartDepth_num + 1;
trace("New depth Number : " + newDepthNumber);

this.attachMovie("Displaydetails_mc", "display_details"+newDepthNumber+"_mc", 1);
var vDisplaydetails_mc= this["display_details"+newDepthNumber+"_mc"];
trace(vDisplaydetails_mc);
//// This trace gives the result as 'Undefined'

default :


break;
}
};




I dont know what's the problem? I want to remove or unload the previous movie(Which shows a piechart) and to load another movie(which shows details in a table).

Can anyone please help me?

Thankfully,
jmukunth

Dynamic Classes Like MovieClip? How?
Hey guys,

Recall how the following is valid:


Code:
var myClip:MovieClip = this.attachMovie("MyClip", "MyInstance", 1);

myClip.name = "Jack";

trace(myClip.name); // yields an output of "Jack"
How is it that this works? And when you do something like the following, that it does not work?


Code:
var myClass:SomeClass = new SomeClass();
myClass.name = "Jimmy" // given that name is not a defined method/property of SomeClass

// yields an error of :There is no property with the name 'name'
If anyone can shed some light on this, it would be very much appreciated.

D.

How To Code MovieClip Classes Properly
Hey, I'm trying to code classes in actionscript that will define custom movieclip objects. So I can then, say, have a movieclip that will have its own functions and variables, and will let me create instances of it dynamically with actionscript.

Here's a basic template:

/**********/
TestClass.prototype = new MovieClip();

function TestClass(){
_rotation = 45;
/*I put this in to test whether
the movieclip itself or the
entire main timeline is being
set as an instance of this
class.*/
}

TestClass.prototype.doNothing = function(){
//does nothing;
}

Object.registerClass("testClass_movie", TestClass);
/**********/

Now I've done just the bare bones- I've defined a new object, given it a constructor, a function, and registered the class with the Object object.

Now my question is: I've heard people say all your code should be in one segment, and the corollary to this I guess is that you can put a movieclip class definition outside of the movieclip itself. Is this possible? And if so, how do you link the class definition to the movieclip so that you can create new instances with the custom classes functions and properties available to that instance?

Next: what the hell do #initclip and #endinitclip do and where do I need to put them and in what situations are they used? I still haven't figured out what they're for and they just seem to screw up my code whenever I try to put them in.

Also, in the past I've taken my class definitions and put them on the first frame of my movieclip, like some tutorial told me to do way back when.

However, I can't get the movieclip to act as an instance of that class unless I add the following line:

this.onLoad = {new TestClass()};

and then the constructor will magically work when I create an instance of that object.

So.... any ideas?

Thanks for any input.

-Lars

Edit: This is Flash MX I'm using, by the way.

Is There Anyway To Distort A MovieClip Without So Much Code Or Classes?
Hi I am trying to disport an image. and make it a perspective.. That looks like this.. http://theflashblog.com/?p=224

It will start flat, then skew or perspective scale to that shape, then go back to its flat form?




but it has to scale along with this function. and tween. I dont want it to be a class, because when I am finished with this function, I will then make it a class. Can anyone help or shed light on this for me?




PHP Code:



//-----------------start flip pane function ------------------------

function fadeFlipPaneIn():Void {
    nTimesFlipPane++;
    if(nTimesFlipPane<= 1)
    {clearInterval(nIntervalFlipPane);
    }
    
    var yTween:Tween = new Tween(mcFlipPane,"_y",Regular.easeIn,0,0,68);
    var yTween:Tween = new Tween(mcFlipPane,"_x",Regular.easeIn,288,288,68);
    var yTween:Tween = new Tween(mcFlipPane,"_yScale",Regular.easeIn,100,100,68);
    var xTween:Tween = new Tween(mcFlipPane,"_xScale",Regular.easeIn,-100,100,68);
    var alphaTween:Tween = new Tween(mcFlipPane,"_alpha",Regular.easeIn,100,100,68);
    yTween.onMotionFinished = function() {
      
    }
}

var nTimesFlipPane:Number = 0;
var nIntervalFlipPane:Number = setInterval(fadeFlipPaneIn, 3000);

Can't Get Movieclip Animate Using Accessors Between Classes
Hi,

I'm trying a very simple test where one class updates the property of another class using implicit accessors. I'm trying to animate an object on stage when I press a button. The testTween class is supposed to animate the object along the x axis, and testButton is supposed to set up a CLICK listener and send a value to testTween. My scene consists of a "circle" movie clip and a "button" Movieclip and that's it. Everything fires fine, (all my traces return the proper values), but the "circle" does not animate. Any ideas?



Code:
package {
import flash.display.*;
import flash.events.*;
import SceneNavigation;
import fl.transitions.TweenEvent;
import caurina.transitions.*;

public class testTween extends MovieClip {

private var _testVar:Number;

public function testTween() {
//The circle will animate if I call testFunction() from the constructor like this
//so it should be working when the function is called from the accessor.
//_testVar = 30;
//testFunction();
}

public function testFunction(){
Tweener.addTween(this, {x:_testVar, time:3});
trace(_testVar);
}

public function set testVar(whichBtn:Number){
_testVar = whichBtn;
testFunction();
trace(_testVar);
}

public function get testVar(){
return testVar;
}
}
}

Code:
package {
import flash.display.*;
import flash.events.*;
import testTween;
import caurina.transitions.*;

public class testButton extends MovieClip {

private var _newTween:testTween = new testTween();

public function testButton() {
this.addEventListener(MouseEvent.CLICK, moveCircle);
}

public function moveCircle(event:MouseEvent) {
_newTween.testVar = 30;
trace("changed property of testTween class");
}
}
}

Running Classes From Whithin A Movieclip
is it possible to run a class from whithin a movieclip? and does anyone know how ot go about calling it. any help is much apprieciated thanks

How To Use Classes To Create/attach Movieclip?
Hi,

I m new to Flash. I need to develop Flash application for mobile devices.
I have created a class and using that class i created a movieclip.

I have created one more class. And whenever the enter key of the mobile device is pressed i need to create a movie clip using the second class.
How to do this?

this.attachMovie("PieChart_mc", "pie_chart"+vPieChartDepth_num+"_mc", vPieChartDepth_num, vPieChartProperties_obj);
var vThisPieChart_mc= this["pie_chart"+vPieChartDepth_num+"_mc"];

keyListener.onKeyDown = function() {

switch (Key.getCode()) {
case Key.UP :
vThisPieChart_mc.highlightPreviousWedge();
break;
case Key.DOWN :
vThisPieChart_mc.highlightNextWedge();
break;
case Key.LEFT :
vThisPieChart_mc.highlightPreviousWedge();
break;
case Key.RIGHT :
vThisPieChart_mc.highlightNextWedge();
break;
case Key.ENTER :
vThisPieChart_mc.removeMovieClip();

var newDepthNumber:Number;
newDepthNumber = vPieChartDepth_num + 1;
trace("New depth Number : " + newDepthNumber);

this.attachMovie("Displaydetails_mc", "display_details"+newDepthNumber+"_mc", 1);
var vDisplaydetails_mc= this["display_details"+newDepthNumber+"_mc"];
trace(vDisplaydetails_mc);
//// This trace gives the result as 'Undefined'

default :


break;
}
};




I dont know what's the problem? I want to remove or unload the previous movie(Which shows a piechart) and to load another movie(which shows details in a table).

Can anyone please help me?

Thankfully,
jmukunth

Inherit From Several Objects Not Possible?
Inherit from several objects not possible?
Isn't it possible to inherit from several objects?
My code:

function SimpleObject(){
this.name="Simple Object";
}

function StrangeObject(){
this.strange="strange";
}

function Weapon(){
}

Weapon.prototype = new SimpleObject();
weapon.prototype= new StrangeObject();

The simple object seem to disapear from the weapon and is replaced by strangeobject.

/Andreas

Inherit / Extends
class Master {
var Needed="Xeef"
???
??
...

class Circle(){
function getRadius(){trace("Hallo"+Needed)}
...
..


stage :


Q=new Master()
trace(Q.Circle.getRadius())
or simply
trace(Q.getRadius())


how to do this ???



i am on a bigger project wich will by one class but it's growing to big
i woud like to sorce out the functions to diferent smaler "classes"

something in the direction of

class Master extends Circle, Box , Point ........

in other words how to make out of X clases ONE

Custom Child Classes Of MovieClip--how To Add An Instance?
I'm using Flash MX, and I've got the following class:

PathAnimator = function(){
}
PathAnimator.prototype = new MovieClip();

PathAnimator isn't supposed to have any graphical content--it's just got some custom methods. I made it a MovieClip because it needs the onEnterFrame event.

I'm trying to create an instance, _root.animator. I managed to do it by putting a blank MC in the library with the linkage "AnimatorMC", then using the following code:

Object.registerClass("AnimatorMC", PathAnimator);
attachMovie("PathAnimator", "animator", 2);

But I don't want to have to put that blank MC in the library--I want to be able to paste the code into a new movie and have it work without the extra step. Is there any way to do it?

Thanks for your help!

[F8] Proper Syntax To Removie MovieClip In Classes
Would you be able to help me with the syntax to remove a movieClip within a movieclip in a class instance?

How would I write it?

You'd think inside the class it would be:

code:

public function unloadIt(){

myInstance.removeMovieClip(myClip);

}



...and in the main timeline, I'd write:

myClassObject.unloadIt();

Clarification Of Senocular FAQ Regarding Classes Which Extend MovieClip
I'm interested in created a superclass with supporting subclasses where the superclass extends MovieClip. I'm familiar with assigning an AS 2.0 class to a linked library MovieClip. I was interested in generating the clip dynamically and associating it with said superclass. So, I started hunting down information on doing just that and ran across Senocular's FAQ item about why extending the MovieClip class is different.

In Senocular's tutorial FAQ, he explains how to avoid using attachMovie and an init private function with a class in this fashion:


Quote:




It is also not uncommon to have a static create method in your class to generate movie clip instances for you. Having such a method lets you avoid any confustion that might result in using attachMovie as well as provides you a means to pass all arguments for instantiation into one function call as opposed to 2, which is what you get with attachMovie + init.




His code sample is as follows:


Code:
class MyClass extends MovieClip {
static var symbolName:String = "MyClassLinkageID";
static function create(timeline:MovieClip, name:String, value1:Number, value2:Number):MyClass{
var instance = timeline.attachMovie(symbolName, name, timeline.getNextHighestDepth());
// use value1 and value2 as you would in the constructor only on 'instance' and not 'this'
return instance;
}
function MyClass(){
// no arguments passed
}
}
However, he notes:


Quote:




Note that a depth parameter was omitted in favor of having the new instance's depth controlled from within the create method. It could have just as well been passed with the others of the values. The same also applies to the movie clip linkage. However, if you plan to use more than one movie clip symbol, you would need to make sure you use Object.registerClass to associate the class to each symbol before using attachMovie.




What does the comment about using Object.registerClass mean? I'm still going to have a movieclip in my library with a linkage to use the code above, right? Would I not also then associate my AS 2.0 superclass to said linked library item?

Senocular -- you answered a similar question from me earlier this week, I think. 'ppreciate any clarification you might have on the above. If anyone else has this same sort of question, read his FAQ/tutorial on the subject:

http://www.senocular.com/flash/tutor.../#newmovieclip

Thanks,
IronChefMorimoto

Problem With Linking Classes To Movieclip Symbols
If anyone interested in checking this problem, please download the zip file and take a look at the "project": http://www.kelemenszerviz.hu/test.zip

My main problem is that I want to add the same class as a base class for two movieclip symbols, a few instances from one of them is included in one of the containers and a few instances from the other is included in the other container instance. My problem is that they have the same name in those containers and the compiler says: "Warning: All instances named 'text1' will be automatically declared as rowgreen in symbols that use Containers as their base class. In symbols that are linked to user-defined base classes, instances with the same name must be of the same type."
If I want to test the movie, it throws an exception because of the same names, if I change one of the container's row's name it won't be a problem anymore, but why? Sorry for the inability to describe the problem in depth, I'm not realy good in English, you can explore the problem by yourself if you take some time to download and take a look at the files I attached.


Dan

Using Flash CS3 MovieClip Classes In Flex Builder
Hi,

after seeing a tutorial on the gotoAndLearn website for using Flex Builder to code projects (the editor of which is vastly superior to Flash's) I've tried to migrate one of my projects to a Flex ActionScript project. However I've run into a problem.

I have a MovieClip in my FLA which has a graphic and a button component. The button is called btn.
I've linked that MovieClip to a class called 'tester'.
In that class I use this simple code :

Code:
btn.label = "yay";
Im able to compile into a SWF easily from Flash (and the button's label changes as expected).
However when I move the project to Flex, Flex tells me in the tester class that 'btn' does not exist (which is understandable).
However I CAN use code like this in my main class:

Code:
var t = new tester();
t.btn.label = "yay"
and that compiles fine (by the way, I've created an SWC that contains my tester MovieClip which I've told Flex to link to).

Is there any way to get around this?
I've tried creating a property called 'btn' in the tester class but this creates an error when I try and compile in CS3.

Can anyone help?

How To Inherit From A UI Component - Skins And All?
Hi,

If I like to create a component that totally inherit from another UI component, for example, says FPushButton:


Code:
#initclip

function MyPushButtonClass() {

super();

}

MyPushButtonClass.prototype = new FPushButtonClass();
Object.registerClass("MyPushButtonSymbol", MyPushButtonClass);

#endinitclip
If I create a new instance of MyPushButtonSymbol, this should produce a PushButton on the stage, but at the moment there is nothing there.

Is there any way I can inherit all the skins/images from this UI component as well, or do I have to re-skin everything for my button?

I need to make minor changes to the FPushButtonSymbol, but don't want to change it directly , so I am trying to inherit from it.

BlueTree

Inherit A Masks Properties?
If I animate a mc's alpha and use it as a mask..... is it possible for the masked mc to inherit the alpha of the mask mc?

The reason I need this to happen is because I am loading a mc into flash and I need it to fade in and out.

If anyone knows please let me know as I need to figure this out quiet urgently otherwise I will have to use a looping AS script and i'm not keen on doing it that way

[F8] Inherit Formatting From One Textfield To Another...
Hey peeps & bods,

What I've done is load a string into flash from an external .xml file with formatting contained in the .xml file, enclosed in a CDATA tag.

The string appears in a dynamic text box on the stage, with all colour, bold, underline and href present and correct.

Now, what if I want to split this string up and create a movieclip for each letter... but keep the formatting as it appears in the original?

var strArr:Array = new Array();
if (getText.loaded) {
var newStr = strTxt.text;
//trace (newStr);
for (var i=0;i<newStr.length;i++) {
strArr.push(newStr.charAt(i));
addL = _root.createEmptyMovieClip("let"+i,i);
addL._x = 10 + (10*i);
addL._y = 50;
addL.createTextField("txt"+i,1,0,0,autoSize,autoSi ze);
addL["txt"+i].autoSize = true;
addL["txt"+i].html = true;
addL["txt"+i].border = true;
addL["txt"+i].htmlText = strArr[i];
}
}

The above doesn't work... no formatting at all.

Am i pinning my hopes too high?

Any insight appreciated. Thanks

Amal

AttachMovie To Inherit Actionscript
I am using attachMovie to place a movieclip in the center of my root level. I need for the newly loaded movieclip to already contain 'on(press)' and 'on(release)' events when loaded. How might I go about this?

Lets Start Basic... Movieclip To Object To Classes
Hey all,

I have a question. When we used to use flash, we would use a movie clip to do everything for us pretty much, either the main timeline _root would execute the code or we would put the code in a movieclip and then would be aware of how that code would execute.

There is a vital building block im missing right now so lets just start basic.

Pretend i know nothing, apart from flash 5 syntax and i have never worked with any future versions.

I originally learned off many different sources, deconcept used to like clips (me too) and colin moock had a chapter on objects that i never understood because people use object and movieclip as though they mean the same thing. They do but they really dont.

So if its flash 5 im using, what is an object in flash 5, why would i use an object over a movie clip?

(this is part 1 of my questions!)

(essentially, i cant see past this, a movieclip has _x,_y and a name. If i create a new object, it has only a name..... that is the source of my confusion. myObject.attachMovie(blah). Again totally confusing because if an object is anything in programming terms, then all i have done is basically added a clip to something somewhere in memory? Since theres no physical representation of a object on screen in the first place, im simply adding a movieclip to something that is somewhere in my program. Its this very missunderstanding at the basic level thats destroying my patience and has been for years.)

Displaying Custom Classes That Extend MovieClip In Flash CS3
I'm pretty new to Flash CS3 and Actionscript 3, and I have just come over from Java so please bare with any knowledge shortcomings I'll most likely have...

I'm trying to create a simple game and to do so I'd like to have a custom class that extends the MovieClip class and can do such things as move and play a move animation, shoot, etc.
So I created a class called Player extended it off of MovieClip, and supplied all the necessary code. The only problem is I can't figure out how to create a graphic that is an instance of my Player class in Flash CS3... To sum it up I want to create a symbol that is not an instance of Button, Graphic, or MovieClip, but of Player.

I can make a regular symbol of a MovieClip class do all the stuff I need by frame scripting... but I rather not frame script an entire game due to the obvious organizational havoc.

I have been researching this problem and I had thought that Linkage was my solution but when I tried to put that into practice I couldn't get what I wanted out of it... Was I on the right track, and just couldn't figure it out completely?

Thanks in advance for any help in the matter...

Accessing MovieClip Textfields Through Extended MovieClips Classes
I am having difficulty locating textfield in MovieClips in extended classes that I link the movies to. I need to be able to access from the MovieClips:

1. The native variables of the MovieClip class.
2. The Text fields created for the MovieClip.

My experience so far is that my Classes created as extentions of the MovieClip class do not have visiblity to the text Field I created inside the MovieClip from the Flash GUI interface. It might be my misunderstanding of what is required to enable this visiablity, but I tried to view the text field instance by its instance name.
The code:
class Menu extends MovieClip{
var gameScore:Number;
_x = 150;

public function Menu(){
gameScore = 0;
score.text = gameScore;
...

The error I recieved for this is:

"**Error** C:Menu.as: Line 12: There is no property with the name 'score'.
score.text = gameScore;

where "score" is the instance name of the textfield that I created for the menu movieClip which is linked to the menu.class

Attached MC's Inherit Undefined Properties
When my vqResponse clips are attached, they've got all the properties associated with the responseObj, but they're undefined. Seems that when they're put on the stage, instead of taking the data from the initObject parameter of attachMovie, it's getting a new instance of the responseObj.

How come? How can I get it to take the data from the initObject passed to it, rather than create a new instanec of responseObj?

PM/Email, I know this is a toughie.

Code:

code:
responseObj = function (resp, quest, clip) {
this.responseLetter = vqXML.firstChild.childNodes[clip].childNodes[quest].childNodes[1].childNodes[resp].attributes.letter;
this.responseCorrect = vqXML.firstChild.childNodes[clip].childNodes[quest].childNodes[1].childNodes[resp].attributes.correct;
this.responseText = vqXML.firstChild.childNodes[clip].childNodes[quest].childNodes[1].childNodes[resp].firstChild.nodeValue;

}

responseObj.prototype = new MovieClip();

responseObj.prototype.onLoad = function () {
this._x = _root.vqResponseX;
this._y = _root.vqResponseY + (_root.vqResponseYInterval *(this._name.charAt(this._name.length-1)));
trace("New Response Added: " + this._name);
}

function vqDisplayQuestion(){

for(r=0;r<VQ[vqCurrentClip].clipQuestions[vqCurrentQuestion].responseList.length;r++){
_root.quiz_MC.attachMovie("vqResponse","response_M C"+r,r+10,VQ[vqCurrentClip].clipQuestions[vqCurrentQuestion].responseList[r]);
}

}

Object.registerClass("vqResponse",responseObj);

Does MenuBar Really Inherit Menu Events?
Does MenuBar really inherit Menu events? As far as we can read from flash help, it does. "Event summary for the MenuBar class > Events inherited from the Menu class" contains events Menu.change, Menu.menuHide, Menu.menuShow, Menu.rollOut, Menu.rollOver. On practice this simple task is impossible - MenuBar broadcasting all events it have to broadcast (ex. draw), but none from Menu class.

How this problem can be solved? Is it my stupidity or is it macromedia's?

How Do You Control LoadMovie Placement? Or To Inherit...
How do you control loadMovie placement? Or to inherit the placement of the Movie Clip its loaded into?


Need help on Random placement and loadMovie into a MC

I have 5 Movie Clips on the Stage with this code on each:

Code:
onClipEvent (load) {
this._x = random(665);
this._y = random(400);
}
so it basically places each MC randomly on the stage.

In each of these movie clips there is a a "loadMovie" command in the first frame:

Code:
loadMovie("shell_03.swf", 3);
But as you know, this will only place the swf in the top corner of the stage, not following the directions of the random placement of the movie clip its loaded into.

how can I control the loadMovie to follow the random placement of the Movie Clip its being loaded into?

Inherit / Extend Class Calls Constructor...
Hi,

Class A extends class B like so:

public class A extends B{}

Why is class B's constructor called? I thought when A extends B, A gets all of B's methods and variables, great; but I don't need the constructor called because class B has already been created. I just want class A to inherit all of B's methods and variables. Can a class have two constructors, so when I extend class B an empty constructor is called but when I instantiate it the constructor with code is called?

I feel like I’m missing something here.

Thanks,
4dplane

Load External SWF And Inherit Frame Rate
Here's what I can't figure out how to do:

Essentially, the user will be able to post the loader swf on their website, and the swf will load my game from within it from my website, so I can keep it updated as such without having to ask every website to keep updating my game whenever there is a small update. I know of mochiads and GameJacket, however I do not wish to use those for this purpose.

However, I need to be able to also determine the FrameRate of the loaded swf game dynamically through the loader swf. If it's possible to actually get the stage width and height of the loaded swf also, dynamically through the loader swf, that would be very helpful also.

I have looked at various resources and cannot determine how to achieve this, or if it is even do-able. Any help is much appreciated!

Inherit / Extend Class Calls Constructor...
Hi,

Class A extends class B like so:

public class A extends B{}

Why is class B's constructor called? I thought when A extends B, A gets all of B's methods and variables, great; but I don't need the constructor called because class B has already been created. I just want class A to inherit all of B's methods and variables. Can a class have two constructors, so when I extend class B an empty constructor is called but when I instantiate it the constructor with code is called?

I feel like I’m missing something here.

Thanks,
4dplane

Simple But Eluding Problem With Creating Classes Extending UIObject Or MovieClip
I recently started to make custom classes in actionscript, I'm not new to programming but what has so far confused me is how I actually instance an object visually.

for example;

var Com1 = new MyComponent();

This works, and indeed creates an instance of my class, but since the object is also required visually, how do I add this to the controls of; for example, the root.

I'm sure it's not complicated, but I just can't see how, the actionscript really appears to be coded heavily to creating movieclips only as visual.

Sorry this is my first post, and I am asking a lot, but I thought this forum would be the best place to go for my problem.

Hope that makes sense, and thanks in advance.

Stevo.

Why Doesn't ActionScript 3.0 Language And Components Reference Mention Movieclip As Being One Of The Classes
hello;

at http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/index.html why is 'movieclip' not listed in either the 'Top Level' or as a member of 'fl' or 'flash'??

likewise, why isn't 'sprite' listed?

thanks
dsdsdsdsd

Html Text Doesn't Inherit Parents Property
a dynamic text field with html is not inderiting it's parent Mc's _alpha property.
this is getting frustrating.
goto http://www.alteregomedia.net/dev
to take a quick look at what i'm talking about
(no preloader and alot of content isn't outside yet
so it's a 400k download sorry, i just started this on thursday.)
when it loads click on about then move the mouse up (over the nasty black text)
the text should fade in with it's parent, being that it's loaded dynamically and from another MC on top of that.
thanks in advance.

Problem: Attached Movies Inherit Parent's Scale
I have a navigation bar whose buttons are drawn dynamically at run-time from info in an XML file, using attachMovie. The remaining width of the movie is then filled with a strip of colour. This much was easy. Problem is this: I want the movie to be the width of the browser client area so I have width=100%, but I don't want the physical size of the buttons to vary - I'd rather just lengthen the strip in code. Is there a way to stop attached movies from inheriting the _xscale property of their parent? Just setting _xscale=100 after attaching doesn't seem to work. I'm starting to bang my head over this so any help would be greatly appreciated...

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!

[AS3] Making An Auto-generated Class Inherit From Custom Class?
hi, just wondering if this is possible

i was hoping to find a way to get a bunch of objects in my library to inherit from (or even be) one class that i have made, but without having to make .as files for every single one

is this possible, or is there any other way to give objects another classes functionality in an auto-generated class?

cheers

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 ?

LoadMovie In A Target Without Inherit Of Target Properties?
hi,

I load a SWF-FILE in a target MovieClip with loadMovie(). After that I want to read the _width and _height of loaded MovieClip (from the SWF-FILE), but I only get the properties of the target MovieClip.

loadMovie ("test.swf", "dummySwf");
trace("height:"+dummySwf._height+"width:"+dummySwf ._width);
//put out the properties from target, not from new clip :-((

any idea?

thanks

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)
&nbsp;&nbsp;-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)
&nbsp;&nbsp;-mc (contains loaded movie)
&nbsp;&nbsp;&nbsp;&nbsp;-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?

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