Parent And Classes
Hello,
I have searched for this problem, and found no solution. I am sure it is not an uncommon question, however.
I am having difficulty with 'parent' in Actionscript 3 accostiated with items that are added via addChild().
The following call to 'tracer' from the MC 'Box' works:
Code:
// Document Class
package {
import flash.display.MovieClip;
public class MyProject extends MovieClip
{
public function MyProject()
{
}
public function tracer():void
{
trace("Testing...");
}
}
}
// Box Class - An instance of 'Box' was added manually to the stage in Flash
package
{
import flash.display.MovieClip;
public class Box extends MovieClip
{
public function Box()
{
MovieClip(this.parent).tracer();
}
}
}
HOWEVER, when the 'Box' movie is NOT added to the stage manually, but added via addChild() from the document class, like this...
Code:
// Document Class
package {
import flash.display.MovieClip;
public class MyProject extends MovieClip
{
public function MyProject()
{
var b:Box = new Box();
addChild(b);
}
public function tracer():void
{
trace("Testing...");
}
}
}
... it returns the error:
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Box()
at MyProject()
Is it possible to call 'tracer()' from 'Box' when the 'Box' is added via addChild()?
Thank you for your help!
KirupaForum > Flash > ActionScript 3.0
Posted on: 12-08-2008, 12:50 PM
View Complete Forum Thread with Replies
Sponsored Links:
Access Parent Swf Classes
Hey Everyone,
I'm trying to make a swf loader that has all the classes in the main loader swf, and have all the loaded swf's reference the classes in the parent. I'm having some problems.. This is what i have so far:
SwfLoader (swfloader.as --> document class)
Code:
package {
import flash.display.*;
import flash.events.*;
import flash.system.*;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import com.testLoader;
public class Document extends MovieClip {
public function Document() {
// Constructor
btnTest.addEventListener(MouseEvent.CLICK, fireTest);
}
private function fireTest(evt) {
var x:testLoader = new testLoader();
var swfLoader:Loader = new Loader();
var swfLoaderContext:LoaderContext = new LoaderContext();
var swfToLoad:String = "test1.swf";
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
swfLoaderContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
swfLoader.load(new URLRequest(swfToLoad), swfLoaderContext);
x.helloWorld();
}
private function loadComplete(evt:Event){
var swfInfo:LoaderInfo = evt.target as LoaderInfo;
mcLoadFrame.addChild(evt.target.content);
}
}
}
externalSwf (externalSwf.as -- document class)
Code:
package {
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.system.ApplicationDomain;
import flash.events.*;
public class externalMovie extends MovieClip {
public function externalMovie() {
// Constructor
this.btnTest1.addEventListener(MouseEvent.CLICK, testFunction);
}
private function testFunction(evt:MouseEvent){
trace("button clicked");
var xy:testLoader = new testLoader();
xy.greetings();
}
}
}
TestLoader.as (class file that i import in the main swf and would like to use in the external swf)
Code:
package com {
public class testLoader {
public function testLoader() {
// Constructor
}
public function helloWorld() {
trace("hello world");
}
public function greetings() {
trace("hello world from inside a swf!");
}
}
}
According the flash liveDocs i should be able to reference my testLoader class in the external swf using a simple
Code:
var x:testLoader = new testLoader();
however whenever i do that, the compiler complains about
Code:
1046: Type was not found or was not a compile-time constant: testLoader
?
Any help would be greatly appreciated.
Thanks!
RaViD
View Replies !
View Related
Communicating Between Parent And Child Classes
I've already asked a few questions about this but i'm still having problems with removing a child and having it's hitbox remain so i'm trying to remove the event listener from the child instance from the parent class.
I tried:-
cubeToDie.removeEventListener(Event.ENTER_FRAME, cubeToDie.cubeMove);
cubeToDie.removeEventListener(Event.ENTER_FRAME, cubeToDie.cubeHit);
It ran but came up with the error: ReferenceError: Error #1069: Property cubeMove not found on CreateCube and there is no default value.
Is there a way to do this cause it's really bugging me how i get on with the rest of the game now
Cheers
Rich
View Replies !
View Related
Understanding Parent/child Classes Vs Nested Symbols And Accessing Their Variables
G'day, this problem has been doing my head in for the last 2 days. I've got a button and two text fields located inside a loginBox movieClip which is linked to the class loginBox. The textfields are named username and password. The button is called loginBoxButton and when it is pressed all I want it to do at this stage is trace the value of username and password. Later I'll be sending data over a XMLSocket to a python backend.
My code looks like this:
Code:
package
{
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.text.TextField;
import loginBox;
public class loginBoxButton extends SimpleButton
{
public function loginBoxButton()
{
this.addEventListener(MouseEvent.CLICK, clickHandler);
}
public function clickHandler(event:MouseEvent):void {
trace("clickHandler detected an event of type: " + event.type);
trace("the event occurred on: " + event.target.name);
trace(loginBox.username);
}
}
}
which throws up 1119: Access of possibly undefined property username through a reference with static type Class. on the trace(loginBox.username); line.
I've also tried
trace(this.parent.username);
which gives me this: 1119: Access of possibly undefined property username through a reference with static type flash.displayisplayObjectContainer.
which after some thought brought me to the conclusion I was confusing class inheritance with nesting objects inside each other.
So looking through the documentation on DisplayObjectContainner I though loginBox should act as a container for the 2 textfields and the login button but when i tried trace(loginBox.getChildByName("username")); It threw back
1061: Call to a possibly undefined method getChildByName through a reference with static type Class.
Which was a similar error to the first one.
At this point I'm completely stuck, and stuck because I don't understand how flash's implementation of object orientated programming works (although I have done a lot of c++ OO work), or how it nested stage objects should be accessed within code. Also, and this is a more basic question, was i right in assuming everything on stage if exported / given a name has a corresponding class in code.
Any help very, very, very much appericated
View Replies !
View Related
Dynamically REMOVING Children From Parent Containers? MovieClip(this.parent.parent...
EDIT: actually, this isn't really dynamic... it should be really simple!
I can get a nested swf to add a movie to the root timeline, but in order to replace it with a new movie, AS3 first requires that I clear the old one. I can't figure it out!
This does not work, though it is the exact same format I use to add a movie to the root successfully:
Code:
MovieClip(this.parent.parent.parent).removeChild(MovieClip(this.parent.parent.parent).loadMovie)
Any idea why this doesn't work?
View Replies !
View Related
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!
View Replies !
View Related
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 ?
View Replies !
View Related
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
View Replies !
View Related
[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
View Replies !
View Related
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.
View Replies !
View Related
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
View Replies !
View Related
AddChild To This.parent.parent?
Greetings.
I have a movie clip on the main timeline called fullContainer with an instance name of fullCont_mc.
Trying to use the addChild method from a different movie clip to load a jpg into fullCont_mc .
I've traced this.parent.parent from within the 'different' movie clip to confirm it brings me to [Object MainTimeline]
I've used the following code: this.parent.parent.fullCont_mc.addChild(imageLoade r);
I'm getting the following error:
Access of possibly undefined property fullCont_mc through a reference with static type flash.displayisplayObjectContainer.
I'd think AS3 would recognize fullCont_mc by its instance name on the main timeline. What am I missing here?
Ultimately, I'm trying to use fullCont_mc as a mask for the loaded image. Please help.
Thank you for your time.
brookchef
View Replies !
View Related
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?
View Replies !
View Related
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);
}
}
}
View Replies !
View Related
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!
View Replies !
View Related
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)
}
}
View Replies !
View Related
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
View Replies !
View Related
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)
}
}
View Replies !
View Related
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>
View Replies !
View Related
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!
View Replies !
View Related
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!
View Replies !
View Related
OO... I Want To Be A Parent
Calling all yOOu Gurus
I am just starting to learn how to OOP.
I have an object called Frame and it has a method to draw a frame.
I now want to make a subClass of Frame which also gives me control of the lineStyle variables.
I know I could just add Thickness, RGB and Alpha to the Frame class, but I want to understand how to start a family of methods going.
I have tried the tutorial at www.debreuil.com/docs/ but dont get how to apply it to methods.
Many Thank Yous
Tim.
Code:
function Frame () {}
Frame.prototype.draw = drawFrame;
function drawFrame (x1,x2,y1,y2){
lineStyle (2,0xFF0000,100);
moveTo(x1,y1); lineTo(x1,y2); lineTo(x2,y2); lineTo(x2,y1); lineTo(x1,y1);
}
//Test it../////////
firstFrame = new frame ();
firstFrame.draw(50,350,50,150);
View Replies !
View Related
Parent
how do you call a movieclip that is one movieclip "up".. i can't remember.. i recall you could do it either by the root command or by something like "../"
thanks
View Replies !
View Related
Parent.parent.parent.parent?
Is there a easier way to get back to the main time line for a nested clip?
I have to call to a flex api fuction form a loaded swf thats in a scroll bar (I know.. but thats the way it is) I have to always do a name trace to see where I am and then once I get to the root it wont cal the function? Is there a easy way to do this?
Here is what im doing wrong
Code:
clip1.addEventListener(MouseEvent.MOUSE_UP,clip1Click);
function clip1Click(event:MouseEvent):void {
//trace("click");
trace(event.target.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.name);
trace(event.target.parent.parent.tip1.text);
trace(event.target.parent.parent.title.text);
event.target.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.AddClipping("event.target.parent.parent.title.text",event.target.parent.parent.tip1.text,"");
}
those children arnt lonely with all those parents and flash seems to be giveing instance names on the fly to some clips like instance_284 and stuff. WTF ?
Any help would be cool
View Replies !
View Related
Get Var From Parent
Hey i need to get values from a parent.
But it keeps saying the parent is a static type.
I have not set any static type.
code on DocClass
ActionScript Code:
publice var size:Number = 8
ball:Ball = new Ball();
addChild(ball);
in Ball.as
ActionScript Code:
trace(parent.size)
but i get this error
1119: Access of possibly undefined property size through a reference with static type flash.displayisplayObjectContainer.
View Replies !
View Related
Parent In Cs3 ?
Hi there
in Flash Cs3 i cant get the variables of the parent movieclip??
In flash 8 it was no problem with
_root.variable = ....;
oder parent.variable....
and now in CS3 it doesnt work? Cann anyone say me if there is another way to get the variables of the parent movieclip?
View Replies !
View Related
Parent Of The Parent?..
Root
|---Home
| |------Container
|
|---Movie2
| |------Sub1
| | |------Sub2
| | | |------Button
How do I refer to the "Container" from the "Button"? But not through Root though, I don't want to use "_root.Home.Container".
View Replies !
View Related
Parent Of The Parent?..
Root
|---Home
| |------Container
|
|---Movie2
| |------Sub1
| | |------Sub2
| | | |------Button
How do I refer to the "Container" from the "Button"? But not through Root though, I don't want to use "_root.Home.Container".
View Replies !
View Related
OO... I Want To Be A Parent
Calling all yOOu Gurus
I am just starting to learn how to OOP.
I have an object called Frame and it has a method to draw a frame.
I now want to make a subClass of Frame which also gives me control of the lineStyle variables.
I know I could just add Thickness, RGB and Alpha to the Frame class, but I want to understand how to start a family of methods going.
I have tried the tutorial at www.debreuil.com/docs/ but dont get how to apply it to methods.
Many Thank Yous
Tim.
Code:
function Frame () {}
Frame.prototype.draw = drawFrame;
function drawFrame (x1,x2,y1,y2){
lineStyle (2,0xFF0000,100);
moveTo(x1,y1); lineTo(x1,y2); lineTo(x2,y2); lineTo(x2,y1); lineTo(x1,y1);
}
//Test it../////////
firstFrame = new frame ();
firstFrame.draw(50,350,50,150);
View Replies !
View Related
Does Anyone Know About The Parent Script?
hey everyone, inside my movie i made another movie which is a jukebox and i was hoping that when you choose a song the movie that the jukebox is in would pause. i have used the parent action script before but how can i pause the origional movie then unpause within the jukebox again? thanks for your help.
View Replies !
View Related
Parent Scripts ?
Hi,
I'm trying to use action script to design a piece that has multiple accessibility options(e.g different languages, visually/aurally-impaired friendly etc)
So the template is the same but each mode calls on different variables(txt,img) to give you that mode(eg irish version-whatever)
I'm thinking parent scripts is the way forward- but I'm not an actionscript whizz like you guys.
If there's easier ways or better still- examples I could use, it would mean a lot.
Cheers.
View Replies !
View Related
Targeting Parent
Hi,
How do you target the parent (or a parent of a parent) of an instance?
I've tried
_root.name = _parent.obj; (where obj is an instance), but it doesn't give me the parents instances name.
thanks for any help
phil.
View Replies !
View Related
UnFocus Parent Swf
im making a site, in this site i have a gallery, the gallery contains thumnails that popup a window with an image or a flash movie.
the gallery works fine
the swf's in the popups work fine
BUT
the dont work together!
because when my gallery is on and the popup is on they are using to much system resources together!
how can i disable all animations and scripts in the gallery while the popup is open?
thanks,
thomas
View Replies !
View Related
Loadmovie Into Parent From MC
Hello,
The following code works great in a button on the main stage - but I now have the button in MC2 that sits in MC1 that sits on the main stage (if you follow me!!)
code:
picture.picture2.loadMovie(pictures.childNodes[0].childNodes[0].attributes["jpegURL"])
so I added a _root infront of the script to make it work but it doesn't - am I just doing something fundamentally wrong or similar???
Osc
View Replies !
View Related
Parent Problem
Hi there,
I made a simple rollover,rolloutbutton like this.Placed a button in an mc.On rollover it should play frame 2 to 12.On rollout frame 13.
Now here's the prob.At first I had a button placed inside an mc that used this code:
on(press){
_parent.noPass45 = true
this.gotoAndPlay(40)
unloadMovieNum(2);
}
But now this button would be the rollover,rolloutbutton.So it would be an mc placed inside an mc.Now the script above doesn't function.
So this is probably a _parent prob. Wright?Someone can help me out on this.
Big thx in advance,
Modulater
View Replies !
View Related
Getting Instance Name Of Parent MC?
Hi,
I have several instances of a movie clip with a button in side (amoung other things). I would to tell the function which is called by this button in the MC the instance name or something else that could identify *which* button (insance of the movie clip) has been pressed.
Does anyone know or have any suggestions on how I could do this?
Thanks.
View Replies !
View Related
How To: Swap The Parent Of A MC?
hi all,
I have got a problem in my program.
I want to change the _parent of the existed MC, from root to other MC, anyone can help me to solve the problem...@@..
description:
There are two movieclips on the stage, one is called temp_mc1, one is call temp_mc2, and I want to change the _parent of temp_mc1 from root to temp_mc2, that mean the final result I want is _root.temp_mc2.temp_mc1 instead of _root.temp_mc1, is it possible to do that without using duplicate a new movieclip??
Thanks,
Jack
View Replies !
View Related
Parent Loading
Hi,
The title I guess say it all, huh?
But just to be sure.
I have a main menu wich goes right or left. Depends what categorie you choose. When it goes left I have to load a arrow movie wich goes left and for right has to load a moviw arrow which goes right (and not wrong). Thats means that there are two movies: arow left movie and arrow right movie. And both have to react at the moving menu, which were to load and play.
So first level would be the menu which ships from right to left.
Second level (under the menu) one of the arrow movie has to load depending which direction the movie goes.
(now Im confused. What was there I wanted??? A, right!)
I figured out that maybe its more confortable to load it from the library but also if it can be loaded from external files I dont mind. (I did the container thing before so I understand it a bit.
The arrow movies are movies played in the background, as the menu remains on top all the time.
The script for animating the menu is:
onClipEvent (load) {
_root.newposition = "null";
}
onClipEvent (enterFrame) {
current = getProperty(_root.drop, _x);
if (_root.newposition<current) {
distance = current-_root.newposition;
setProperty("_root.drop", _x, current-(distance*.1));
}
if (_root.newposition>current) {
distance = _root.newposition-current;
setProperty("_root.drop", _x, current+(distance*.1));
}
}
Any help accepted.
Thanks
View Replies !
View Related
Parent/root
can anyone help me here. ive had this problem before and i just scraped through it.
this is the As for a scrolling text box. the scrolling button works but its not scrolling the text when i move it up/down.
the MC for this is inside just one Mc on the main stage. ive changed all sorts and it wont scroll the text.
onClipEvent(load){
var objetivo:String = _parent.mi_objetivo;//entre comillas aquí escribe
var sostenido:Boolean = false;
var razon:Number = this._parent._parent[objetivo]._height / this._height;
var deslizar:Number;
razon = int(razon);
}
on(press){
startDrag(this, false, this._parent.barra._x, this._parent.barra._y, this._parent.barra._x + this._parent.barra._width, this._parent.barra._y + this._parent.barra._height - this._height);
this.sostenido = true;
}
on(release){
stopDrag();
this.sostenido = false;
}
onClipEvent(mouseMove){
if(this.sostenido){
deslizar = (this._y - this._parent.barra._y);
deslizar = int(deslizar);
this._parent._parent[objetivo]._y = -(razon * deslizar) / 2;
}
}
View Replies !
View Related
How To Control A Parent MC?
I've got a complex heirarchy of MCs...say I need to put a script in MC-1.1 to gotoAndStop(1) of MC-1...so there are 2 ways to do it as to what i know, one is _root.MC-1.gotoAndStop(1); and the other is the other way around like going one step up from the child ...i know it has something to do with '/' but cant figure out the syntax..could someome help me out? Let me know if im making sense.......
View Replies !
View Related
Parent Tutorial
Hi people
I need to know where can I find a tutorial about ussing parent command, I need to control the "y movement" of a big movie trought the movement of a small movie or a button,
thanks
Dave
View Replies !
View Related
Attachsound In Parent Swf
I have a swf with sounds attached to a sound object.
When I load this swf into a (parent) main swf it won't find the sounds from the library, except when I place the sound files in the lib of the main swf.
Is there a way to have to external swf keep the sounds in it's own library so the main swf won't get burdened with these files ?
View Replies !
View Related
Parent Script Help
Hi guys, I appoligise for such a stupid question. Im not the best scripter in flash, all i need is a script that will let a button in a graphic thats also inside of a movie work. I use to have the script but i lost it, if someone would be so kind and help me out, I would really appreciate it.
Thanks
Frank
View Replies !
View Related
Parent To A Null?
Hello, I'm fairly new to Flash 8, and have a question about an effect I'm trying to achieve.
Example:
In After Effects, I can parent one object (child) to another object (parent). When I move the parent, so does the child.
How would I accomplish this with two movie clips in Flash 8?
Speficifallly, I'm scripting a tween for one object after a mouse click, but want to move a second object to move 90% of the x and y position of the first object.
I'm not sure where to start with the parenting/following bit.
The end goal is to achieve a multiplaning effect in my interface with "closer" objects moving slower than "further" objects.
thanks,
-SF
View Replies !
View Related
Parent Window Help
I have created a pop up map in flash
The code I have applied to the buttons is:
on (release) {
//Goto Webpage Behavior
getURL("http://classifieds.rgj.com/category/1682","popUpParent");
//End Behavior
}
this works great on the first click...the current browser refreshes to the url in the code. yay. however, when you click another button, the url populates the map popup window. ugh.
I have tried several variations, but nothing is working.
bottom line: I'd like all buttons to populate and refresh the parent window.
thank you in advance all flash gurus!!
View Replies !
View Related
|