00:00
00:00
Newgrounds Background Image Theme

Our goal is for Newgrounds to be ad free for everyone! Become a Supporter today and help make this dream a reality!

as3 code not responding (symbol within a symbol within a symbol)

833 Views | 18 Replies
New Topic Respond to this Topic

so at frame 69 (just a coincidende) i have a movie clip, let's call it symbol1. symbol1 has symbol2 within it, which itself has symbol3 within it. All of them are movie clips. Back on frame 69 i put a code saying


symbol1.symbol2.symbol3.visible=false;


because symbol3 can only be visible when you press button1. So the code is not working for some fucking reason i can't understand. I quadruple checked instance names on all frames and symbols... and the weird thing is the code works if i put it in button1, you know? it just doesn't work when it's directly in the frame. Another weird thing is that if i make only symbol1.symbol2.visible=false; it also works, it's when it gets to symbol3 that flash simply decides to ignore me.


the error that appears is this one:


TypeError: Error #1010: A term is undefined and has no properties.

at projectName_fla::symbol0_44/frame69()

at flash.display::MovieClip/gotoAndStop()


If i don't manage to get this thing to work i can put the code insed symbol3 itself, but i rather do it on frame 69 because otherwise it'll complicate some things that i don't want to.... so i want to figure out this


So can someone please tell me what the ass is going on????

thanks a lot.


Making human hentai.

BBS Signature

so now i made it inside symbol2 and... well it sucks, because it's inside an if statement inside an ENTER_FRAME listener.

If (MovieClip(root).symbol0.variable1){symbol3.visible=true;} else{symbol3.visible=false;}


This way symbol3 appears for a frame and then disappears, which is compromising the animation... i guess i could pull out some more work around, but it's getting messier and messier.... so i'm still counting on some blessed soul to help me with this


Making human hentai.

BBS Signature

Frame scripts are messy and a better way to handle them is to use display list events. For now, what are you trying to do exactly? What do the variables mean? What's the structure of the movieclips? Is it:


/ root
|_/ symbol0
  |_/ variable1
|_/ symbol1
  |_/ symbol2
    |_/ symbol3

Also, are those the actual variable names?


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 9/9/20 02:20 PM, Gimmick wrote: Frame scripts are messy and a better way to handle them is to use display list events. For now, what are you trying to do exactly? What do the variables mean? What's the structure of the movieclips? Is it:

Also, are those the actual variable names?


I forgot to mention that all of that is happening inside symbol0. I used fake names for organization purposes. So basically there is symbol3 is inside symbol2, which is inside symbol1, which is inside symbol0, which is on stage. Just so it's clearer, i'll say what it is exactly. Symbol3 is the player's character's hand, which must appear only if the player wants his hand to hold the girl's head (they're... exchanging affection). So, inside symbol0, which is the symbol in which everything is (let's say, the scene symbol), there is the variable1 (which is also a fake name. it's a boolean variable that should determine if the hand is or is not be visible).


In symbol0, the scene symbol, there are 5 important frames here, one of which is a different cuddle speed. In which of these frames there are different symbols for different speeds. Frame1 for speed1, frame2 for speed2 etc. These different symbols are all named symbol1, for the code to work for all of them. Inside of each there is also symbol2, which is actually the exact same movie clip, not just the same instance name. Therefore, symbol3 is inside all of symbol2's.


So, variable1 is primarilly set to false, because you must click somewhere to but your hand on her head. This way, i first tried to make the code on each frame of symbol0, saying "if(variable1){symbol1.symbol2.symbol3.visible=false;}" but this didn't work for some reason. It didn't work even without the if statement... just telling the symbol there within not to be visible didn't work at all (which it's the main post).


Then i tried to make the code inside symbol2, with the "if(MovieClip(root).symbol0.variable1){symbol3.visible=false;}". This way it kinda works, but the hand still appears for one frame before disappearing, and i cannot let that happen. If i make it the other way, with the symbol hard set to be insivible from the beggining, the opposite occurs, with it being blank for a frame and then appearing afterwards.


I thought this wasn't supposed to happen because flash does the code before the visuals, am i not right? i mean i have no formal education on this but if you put a "gotoAndStop(1)" in the 12th frame, the 12th frame won't appear at all, am i right?


well i hope i'm being clear... if not, please let me know, and i'll do some prints.


Making human hentai.

BBS Signature

So your structure seems to be like

"stage": {
  "symbol0": {
    "Frame1": {"symbol1": {"symbol2": "symbol3"}}, 
    "Frame2": {"symbol1": {"symbol2": "symbol3"}}, 
    "Frame3": {"symbol1": {"symbol2": "symbol3"}}, 
    "Frame4": {"symbol1": {"symbol2": "symbol3"}}, 
    "variable1": true
  }
}


What happens if you try running

trace(symbol1.name) #in symbol0


trace(symbol0.name) #in stage

and

trace(symbol2.name) #in symbol1

It's a while since I used flash, but I guess you can try using

var mc:MovieClip = MovieClip(stage.getChildByName(name))

to get a reference to the movieclip currently playing on the stage, regardless of whether it's frame 1 or 5, and use that to make the symbols underneath it (in successive order) visible or not (e.g. replace "stage" with "mc" above)


Would it be possible to flatten the structure of your movieclips? I recall Flash has "scenes" so you could have one 1 speed per scene, thereby flattening symbol0 into multiple frames, making it easier to deal with symbol1, symbol2 and symbol3. Can the hand movieclip be moved outside any of the symbols - e.g. by overlapping them so that it looks connected even though it isn't?


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 9/9/20 06:48 PM, Gimmick wrote: So your structure seems to be like

What happens if you try running
: trace(symbol1.name) #in symbol0


trace(symbol0.name) #in stage

i tried this and it appeared their instance name


about this:

var mc:MovieClip = MovieClip(stage.getChildByName(name))

i didn't get what is it that i have to do actually. i have never seen this, what should it do?


Making human hentai.

BBS Signature

At 9/9/20 08:58 PM, Edeshye wrote:
At 9/9/20 06:48 PM, Gimmick wrote: So your structure seems to be like

What happens if you try running
i tried this and it appeared their instance name

about this:
i didn't get what is it that i have to do actually. i have never seen this, what should it do?

Well, there's multiple ways to refer to an object on the stage. The most common one is through a variable name, but for some reason if referring to it through a variable doesn't work (like in your case, where this could be happening because the variable is being redefined/reassigned each time) then another way is through getting its via its name.


What this means is that you can usually name any displayObject (movieclip, sprite, etc.) any name you want - so you can make it more memorable.


If you can use getChildByName() to refer to each symbol, then it might work.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 9/9/20 11:20 PM, Gimmick wrote:
At 9/9/20 08:58 PM, Edeshye wrote:
At 9/9/20 06:48 PM, Gimmick wrote: So your structure seems to be like

What happens if you try running
i tried this and it appeared their instance name

about this:
i didn't get what is it that i have to do actually. i have never seen this, what should it do?
Well, there's multiple ways to refer to an object on the stage. The most common one is through a variable name, but for some reason if referring to it through a variable doesn't work (like in your case, where this could be happening because the variable is being redefined/reassigned each time) then another way is through getting its via its name.

What this means is that you can usually name any displayObject (movieclip, sprite, etc.) any name you want - so you can make it more memorable.

If you can use getChildByName() to refer to each symbol, then it might work.


umm, i'm not sure if i got it (sorry >__< ), but i managed to reffer to the symbols when i made the code closer to them (if that makes any sense), my problem now is that the code is running late. It's supposed to hide the hand before it even appeared, but it's letting it appear for a frame and than hiding it, you know? this makes that every time the player changes the speed there is a hand blinking out of nowhere.


My final work around (lacking a more apropriate translation for the very eloquent portuguese word gambiarra - which is typical brazilian behaviour) should be making the hand primarily invisible on frame1 and then the loop goes from the last frame to frame 2 directly, skipping the reload of the symbol (thus skipping the blinking). I'll have to make a quite annoying work to re arrange the animation for this purpose, but i know it works because i did this already before in my first "game" i uploaded here.


Making human hentai.

BBS Signature

At 9/10/20 09:25 AM, Edeshye wrote:
At 9/9/20 11:20 PM, Gimmick wrote:
At 9/9/20 08:58 PM, Edeshye wrote:
At 9/9/20 06:48 PM, Gimmick wrote: So your structure seems to be like

What happens if you try running
i tried this and it appeared their instance name

about this:
i didn't get what is it that i have to do actually. i have never seen this, what should it do?
Well, there's multiple ways to refer to an object on the stage. The most common one is through a variable name, but for some reason if referring to it through a variable doesn't work (like in your case, where this could be happening because the variable is being redefined/reassigned each time) then another way is through getting its via its name.

What this means is that you can usually name any displayObject (movieclip, sprite, etc.) any name you want - so you can make it more memorable.

If you can use getChildByName() to refer to each symbol, then it might work.
umm, i'm not sure if i got it (sorry >__< ), but i managed to reffer to the symbols when i made the code closer to them (if that makes any sense), my problem now is that the code is running late. It's supposed to hide the hand before it even appeared, but it's letting it appear for a frame and than hiding it, you know? this makes that every time the player changes the speed there is a hand blinking out of nowhere.

My final work around (lacking a more apropriate translation for the very eloquent portuguese word gambiarra - which is typical brazilian behaviour)

Like a kludge?

should be making the hand primarily invisible on frame1 and then the loop goes from the last frame to frame 2 directly, skipping the reload of the symbol (thus skipping the blinking). I'll have to make a quite annoying work to re arrange the animation for this purpose, but i know it works because i did this already before in my first "game" i uploaded here.


Hmm. If it works then I guess that's good. If you haven't already aligned all the animation, though, here's something you _could_ try out to make it invisible in the beginning:


Attach a class to the movieclip - I'm rather fuzzy on how to do this and it seems like my google fu has utterly failed me at this because I can't find anything about it despite being one of the most common things in Flash; maybe it was so obvious nobody thought of it - right click on the hand symbol in the library, and see if you can search for something called "Actionscript Linkage" or something like that.


If you were creating a new symbol or using "Convert to Symbol", then it'd be under the "Advanced" section in the popup box.


Make a class name (in the textfield in that section) and name it anything. Name it Hand, for example. Then, in the code that pops up, set it to be invisible at the start, in the constructor function. The constructor is basically the thing that runs when the object is created. Here's some code - you can try copying it into the file if you want -


package
{
    import flash.display.*;
    public class Hand extends MovieClip
    {
        public function Hand()
        {
            stop();
            visible = false;
        }
    }
}

This would basically tell the hand to be invisible and stop the moment it's created - so that you don't (in theory) need to insert a blank frame in the beginning.


Just to make sure: Are your frame scripts on the same layer or a new one? Frame scripts REALLY get messed up if they occur only on one frame. That's why you see a separate "Actions" layer in most youtube tutorials.


(Also, I know that this is the programming forum, but questions related to AS3 and Haxe would be answered much faster in the Game Development forum)


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 9/10/20 11:23 PM, Gimmick wrote:
At 9/10/20 09:25 AM, Edeshye wrote:
At 9/9/20 11:20 PM, Gimmick wrote:
At 9/9/20 08:58 PM, Edeshye wrote:
At 9/9/20 06:48 PM, Gimmick wrote: So your structure seems to be like

What happens if you try running
i tried this and it appeared their instance name

about this:
i didn't get what is it that i have to do actually. i have never seen this, what should it do?
Well, there's multiple ways to refer to an object on the stage. The most common one is through a variable name, but for some reason if referring to it through a variable doesn't work (like in your case, where this could be happening because the variable is being redefined/reassigned each time) then another way is through getting its via its name.

What this means is that you can usually name any displayObject (movieclip, sprite, etc.) any name you want - so you can make it more memorable.

If you can use getChildByName() to refer to each symbol, then it might work.
umm, i'm not sure if i got it (sorry >__< ), but i managed to reffer to the symbols when i made the code closer to them (if that makes any sense), my problem now is that the code is running late. It's supposed to hide the hand before it even appeared, but it's letting it appear for a frame and than hiding it, you know? this makes that every time the player changes the speed there is a hand blinking out of nowhere.

My final work around (lacking a more apropriate translation for the very eloquent portuguese word gambiarra - which is typical brazilian behaviour)
Like a kludge?


haha, yes!! this word wasn't on google translator, i just suggested it xD


should be making the hand primarily invisible on frame1 and then the loop goes from the last frame to frame 2 directly, skipping the reload of the symbol (thus skipping the blinking). I'll have to make a quite annoying work to re arrange the animation for this purpose, but i know it works because i did this already before in my first "game" i uploaded here.
Hmm. If it works then I guess that's good. If you haven't already aligned all the animation, though, here's something you _could_ try out to make it invisible in the beginning:

Attach a class to the movieclip - I'm rather fuzzy on how to do this and it seems like my google fu has utterly failed me at this because I can't find anything about it despite being one of the most common things in Flash; maybe it was so obvious nobody thought of it - right click on the hand symbol in the library, and see if you can search for something called "Actionscript Linkage" or something like that.

If you were creating a new symbol or using "Convert to Symbol", then it'd be under the "Advanced" section in the popup box.

Make a class name (in the textfield in that section) and name it anything. Name it Hand, for example. Then, in the code that pops up, set it to be invisible at the start, in the constructor function. The constructor is basically the thing that runs when the object is created. Here's some code - you can try copying it into the file if you want -

This would basically tell the hand to be invisible and stop the moment it's created - so that you don't (in theory) need to insert a blank frame in the beginning.


Ok so i did this. I should click the pencil in order for the code to pop up am i right? when i did this, the code appeared as you wrote it, but without the function, of course. But it opened in another window, separated from the .fla i'm working on. Should i save it somewhere? i tried this as is, it didn't change anything, but i don't think the code is being applied, since it opened in a new window... i don't know.


Just to make sure: Are your frame scripts on the same layer or a new one? Frame scripts REALLY get messed up if they occur only on one frame. That's why you see a separate "Actions" layer in most youtube tutorials.


it's a separated layer just for code (there are more then one code layer though, for example there is one for sounds)


(Also, I know that this is the programming forum, but questions related to AS3 and Haxe would be answered much faster in the Game Development forum)


noted, next time i'll try it there, thanks


Making human hentai.

BBS Signature

At 9/11/20 08:04 AM, Edeshye wrote: Ok so i did this. I should click the pencil in order for the code to pop up am i right? when i did this, the code appeared as you wrote it, but without the function, of course. But it opened in another window, separated from the .fla i'm working on. Should i save it somewhere? i tried this as is, it didn't change anything, but i don't think the code is being applied, since it opened in a new window... i don't know.

Yes, you should save it in the project directory. Flash should usually create a template like the code I'd provided (without the stop() and visible=false though); below the "visible=false;" line can you add

trace("Created");

if you see the console output window show "created" then the code should've executed. When that happens, though, depends on when it's actually present on the stage - which should be the frame that it's introduced.

it's a separated layer just for code (there are more then one code layer though, for example there is one for sounds)

Okay. Can you paste the code, if possible? Doesn't need to be verbatim - feel free to rename any variables as long as there's consistency.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 9/11/20 10:50 AM, Gimmick wrote:
At 9/11/20 08:04 AM, Edeshye wrote: Ok so i did this. I should click the pencil in order for the code to pop up am i right? when i did this, the code appeared as you wrote it, but without the function, of course. But it opened in another window, separated from the .fla i'm working on. Should i save it somewhere? i tried this as is, it didn't change anything, but i don't think the code is being applied, since it opened in a new window... i don't know.
Yes, you should save it in the project directory. Flash should usually create a template like the code I'd provided (without the stop() and visible=false though); below the "visible=false;" line can you add
if you see the console output window show "created" then the code should've executed. When that happens, though, depends on when it's actually present on the stage - which should be the frame that it's introduced.
it's a separated layer just for code (there are more then one code layer though, for example there is one for sounds)
Okay. Can you paste the code, if possible? Doesn't need to be verbatim - feel free to rename any variables as long as there's consistency.


Shiiiiiiiiit it finally worked. I'm sorry about the delay, i was working on the demo i just launched and i came back to this scene today. I made what you said with the constructor code, and made an if statement right there.


If (hand){visible=true;}

else{visible=false;}


It worked. Thanks a lot Gimmick, seriously!


Making human hentai.

BBS Signature

At 9/16/20 11:41 AM, Edeshye wrote:
At 9/11/20 10:50 AM, Gimmick wrote:
At 9/11/20 08:04 AM, Edeshye wrote: Ok so i did this. I should click the pencil in order for the code to pop up am i right? when i did this, the code appeared as you wrote it, but without the function, of course. But it opened in another window, separated from the .fla i'm working on. Should i save it somewhere? i tried this as is, it didn't change anything, but i don't think the code is being applied, since it opened in a new window... i don't know.
Yes, you should save it in the project directory. Flash should usually create a template like the code I'd provided (without the stop() and visible=false though); below the "visible=false;" line can you add
if you see the console output window show "created" then the code should've executed. When that happens, though, depends on when it's actually present on the stage - which should be the frame that it's introduced.
it's a separated layer just for code (there are more then one code layer though, for example there is one for sounds)
Okay. Can you paste the code, if possible? Doesn't need to be verbatim - feel free to rename any variables as long as there's consistency.
Shiiiiiiiiit it finally worked. I'm sorry about the delay, i was working on the demo i just launched and i came back to this scene today. I made what you said with the constructor code, and made an if statement right there.

If (hand){visible=true;}
else{visible=false;}

It worked. Thanks a lot Gimmick, seriously!


hey @Gimmick, does the constructor code change anything in the instance name of the object or something? because now it compromised another code... it's showing that null object reference error :c


Making human hentai.

BBS Signature

At 9/16/20 02:50 PM, Edeshye wrote:
At 9/16/20 11:41 AM, Edeshye wrote:
At 9/11/20 10:50 AM, Gimmick wrote:
At 9/11/20 08:04 AM, Edeshye wrote: Ok so i did this. I should click the pencil in order for the code to pop up am i right? when i did this, the code appeared as you wrote it, but without the function, of course. But it opened in another window, separated from the .fla i'm working on. Should i save it somewhere? i tried this as is, it didn't change anything, but i don't think the code is being applied, since it opened in a new window... i don't know.
Yes, you should save it in the project directory. Flash should usually create a template like the code I'd provided (without the stop() and visible=false though); below the "visible=false;" line can you add
if you see the console output window show "created" then the code should've executed. When that happens, though, depends on when it's actually present on the stage - which should be the frame that it's introduced.
it's a separated layer just for code (there are more then one code layer though, for example there is one for sounds)
Okay. Can you paste the code, if possible? Doesn't need to be verbatim - feel free to rename any variables as long as there's consistency.
Shiiiiiiiiit it finally worked. I'm sorry about the delay, i was working on the demo i just launched and i came back to this scene today. I made what you said with the constructor code, and made an if statement right there.

If (hand){visible=true;}
else{visible=false;}

It worked. Thanks a lot Gimmick, seriously!
hey @Gimmick, does the constructor code change anything in the instance name of the object or something? because now it compromised another code... it's showing that null object reference error :c


The class code (constructor, etc.) is entirely separate from the scene, so it shouldn't change anything else, especially not variable names. Sounds like Flash is unable to get the reference to something, whether due to an incorrect variable name, or due to something else. What happens when you call

trace(varName);

for each varName in your code right before the error occurs?


---

If all else fails, you could try adding movieclips from the class itself. It's a bit involved, but it should prevent any errors from occurring:


Create a document class for the movie (this is the recommended way to program in AS3 instead of frame scripts, from what I've heard and experienced). This can be done by clicking on an empty part of the stage and in the Properties panel, selecting the "Document class..." button (or something similar). In that, you can have five instances of a Scene, and each movieclip has its own class so that you can add it when needed. For example:


Document class:

package
{
  import flash.display.*;
  public class Main extends Sprite
  {
    private var scenes:Vector.<MovieClip>;  //list of scenes as movieclips
    public function Main()
    {
      //creates a new list of MovieClips
      scenes = new <DisplayObject>[new Scene1(), new Scene2(), new Scene3(), new Scene4()]
      showScene(0);
    }
    public function showScene(scene:uint):void
    {
      removeChildren();
      addChild(scenes[scene])
    }
  }
}


Create a class called Scene (new ActionScript 3.0 File) in the "scenes" folder below the FLA and put this code in:

package scenes
{
  import flash.display.*;
  public class Scene extends Sprite
  {
    protected var objects:Vector.<MovieClip>;  //will hold all scene objects
    protected var locations:Array;  //will hold all their locations
    protected var active:Vector.<Boolean>;  //will hold their state: visible & playing, or stopped 
    protected var sceneSwitchButtons:Vector.<DisplayObject>;
    public function Scene()
    {
      stop()
    }
    protected function updateAll():void
    {
      var i:uint;
      for(i = 0; sceneSwitchButtons && i < sceneSwitchButtons.length; ++i) {
          addChild(sceneSwitchButtons[i])
      }
      for(var i:uint = 0; i < objects.length; ++i)
      {
        var currObject:MovieClip = objects[i];
        currObject.x = locations[i][0];
        currObject.y = locations[i][1]; //set x and y
        if(active[i] != currObject.visible)  //only runs code if there's a change
        {
          currObject.visible = active[i];
          if(active[i]) {
            currObject.play() //replace with gotoAndPlay(1) if you want it to restart each time it becomes visible
          }
          else {
            currObject.stop();
          }
        }
      }
    }
  }
}

And then create a class for each scene/frame you have (a new ActionScript 3.0 file again - not a movieclip with a class) and call it Scene1, Scene2, etc. and put this code in (it should be in the scenes folder again):

package scenes
{
  import flash.display.*;
  public class Scene1 extends Scene
  {
    public function Scene1()
    {
      //add your objects, eg person, woman, man, camera, TV
      objects = new <MovieClip>[new Person(), new Woman(), new Man(), new Camera(), new TV()];
      //and their locations - this you'll have to read the X and Y coordinate of each object in the property panel and copy it down here as [X, Y]
      locations = [[0,0], [100, 10], [30, 30], [10, 10], [90, 70]];
      active = new <Boolean>[true, true, true, true, false]; //TV is invisible and stopped
      sceneSwitchButtons = new <DisplayObject>[new Scene2Button(), new Scene3Button()]  //create scene switch buttons
      updateAll(); //updates states of everything
    }
  }
}


Well, this got much longer than expected, and it's still not complete - there's listeners that need to be added to the buttons to switch scenes, make the hand visible and invisible, etc... This is waay more involved but it is much cleaner to implement and maintain. If you do end up using this method - assuming the problem hasn't been fixed - then let me know and I think I'll finish it.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 9/16/20 03:45 PM, Gimmick wrote:
At 9/16/20 02:50 PM, Edeshye wrote:
At 9/16/20 11:41 AM, Edeshye wrote:
At 9/11/20 10:50 AM, Gimmick wrote:
At 9/11/20 08:04 AM, Edeshye wrote: Ok so i did this. I should click the pencil in order for the code to pop up am i right? when i did this, the code appeared as you wrote it, but without the function, of course. But it opened in another window, separated from the .fla i'm working on. Should i save it somewhere? i tried this as is, it didn't change anything, but i don't think the code is being applied, since it opened in a new window... i don't know.
Yes, you should save it in the project directory. Flash should usually create a template like the code I'd provided (without the stop() and visible=false though); below the "visible=false;" line can you add
if you see the console output window show "created" then the code should've executed. When that happens, though, depends on when it's actually present on the stage - which should be the frame that it's introduced.
it's a separated layer just for code (there are more then one code layer though, for example there is one for sounds)
Okay. Can you paste the code, if possible? Doesn't need to be verbatim - feel free to rename any variables as long as there's consistency.
Shiiiiiiiiit it finally worked. I'm sorry about the delay, i was working on the demo i just launched and i came back to this scene today. I made what you said with the constructor code, and made an if statement right there.

If (hand){visible=true;}
else{visible=false;}

It worked. Thanks a lot Gimmick, seriously!
hey @Gimmick, does the constructor code change anything in the instance name of the object or something? because now it compromised another code... it's showing that null object reference error :c
The class code (constructor, etc.) is entirely separate from the scene, so it shouldn't change anything else, especially not variable names. Sounds like Flash is unable to get the reference to something, whether due to an incorrect variable name, or due to something else. What happens when you call
for each varName in your code right before the error occurs?

---
If all else fails, you could try adding movieclips from the class itself. It's a bit involved, but it should prevent any errors from occurring:

Create a document class for the movie (this is the recommended way to program in AS3 instead of frame scripts, from what I've heard and experienced). This can be done by clicking on an empty part of the stage and in the Properties panel, selecting the "Document class..." button (or something similar). In that, you can have five instances of a Scene, and each movieclip has its own class so that you can add it when needed. For example:

Document class:

Create a class called Scene (new ActionScript 3.0 File) in the "scenes" folder below the FLA and put this code in:
And then create a class for each scene/frame you have (a new ActionScript 3.0 file again - not a movieclip with a class) and call it Scene1, Scene2, etc. and put this code in (it should be in the scenes folder again):

Well, this got much longer than expected, and it's still not complete - there's listeners that need to be added to the buttons to switch scenes, make the hand visible and invisible, etc... This is waay more involved but it is much cleaner to implement and maintain. If you do end up using this method - assuming the problem hasn't been fixed - then let me know and I think I'll finish it.


Oh boy... i don't think i'll try this actually, because damn i don't understand anything LOL. But i'm trying on some things here... what is happening is this(i'll dismiss the euphemisms):


There are 3 blowjob speeds. Each one of them is a different symbol inside a different frame in MovieClip(root).blowjobSymbol. For the animation to flow naturally, i set up two key points of her head in which the animation can change from one speed to another. They are when the head is way up on the top of the dick, and way down with the dick in her mouth. I made these frames identical in each speed, so that there would be no compromises on the animation.


So the speed buttons has only the code to set a variable number: speed = x; (x being 1, 2 or 3, of course)


then, inside the girl's symbol, there is this code in both key frames (one in the middle and one in the end of the loop):

if(MovieClip(root).blowjobSymbol.speed == x){MovieClip(root).blowjobSymbol.gotoAndStop("speedx");} (speedx being the instance name of each frame)


in the middle frame there is also a variable, "MovieClip(root).blowjobSymbol.middle = true;" because then in each speed frame there is this code:

if(middle){bj.gotoAndPlay("middleFrame"); (bj being the instance name of the girl in every speed frame and "middleFrame" being the instance name of the middle frame in each speed symbol.


Now this was working just fine until i added the hand thing. Now what happens is that it still works fine when there is no hand involved, but as soon as i click to make the hand visible, this code simply won't work and that error "TypeError: Error #1009: Cannot access a property or method of a null object reference." appears. So now the hand thing works just fine, but everytime i click a different speed button, if the girl is all the way down on the dick she just pops to the tip... (if the hand is visible).


weird shit



Making human hentai.

BBS Signature

in the middle frame there is also a variable, "MovieClip(root).blowjobSymbol.middle = true;" because then in each speed frame there is this code:
if(middle){bj.gotoAndPlay("middleFrame"); (bj being the instance name of the girl in every speed frame and "middleFrame" being the instance name of the middle frame in each speed symbol.


Using trace("asdasdas"); to find out where was it that the code wasn't working i found that it is this particular code ☝️


Making human hentai.

BBS Signature

At 9/17/20 10:20 AM, Edeshye wrote:
in the middle frame there is also a variable, "MovieClip(root).blowjobSymbol.middle = true;" because then in each speed frame there is this code:
if(middle){bj.gotoAndPlay("middleFrame"); (bj being the instance name of the girl in every speed frame and "middleFrame" being the instance name of the middle frame in each speed symbol.
Using trace("asdasdas"); to find out where was it that the code wasn't working i found that it is this particular code ☝️


I think the problem is with the way you used the variable "middle". Try calling "trace(middle)" and see what the output is - by default, Flash doesn't know that "middle" and "MovieClip(root).blowjobSymbol.middle" are the same. To fix this, just assign the value of blowjobSymbol.middle to a variable called middle:


var middle:Boolean = MovieClip(root).blowjobSymbol.middle
if(middle) {
 //code
}

And it should work. Alternatively, if you are already in blowjobSymbol's timeline, then try using

this.middle


That's another downside of using frame scripts. While using document class code to separate the various classes is tedious, it doesn't cause confusion between local variables and member variables - "middle" could refer to blowjobSymbol.middle (a variable belonging to the object "blowjobSymbol") OR an undefined, unbound local variable (a variable that isn't attached to anything)


--


As an aside, there's two types of variable referencing (in this context, anyways) - relative and absolute (like filesystem paths.) You're doing absolute referencing but it isn't necessary if you know the relative locations.


For example, you have the structure:


                  root
                   |
     -------------------------------
     |                             |
blowjobSymbol                 speedButton1, 2, 3
     |________________
     |       |       |
    head1   head2    head3
    ^--------------------------------you are here

If your code is in "head1" (indicated by the arrow) then you don't need to use the absolute address of

MovieClip(root).blowjobSymbol.speed

You can just go one level up and reference it:

parent.blowjobSymbol

"parent" is a function in the DisplayObject class that refers to the movieclip or sprite (more generally, a "DisplayObjectContainer") that it is inside. In this case, since head1 is on frame 1 of blowjobSymbol, head1.parent is the same as MovieClip(root).blowjobSymbol.


If you call "trace(this.parent == MovieClip(root).blowjobSymbol)" in the head1 frame code, then you should see "true" as the output - because "this" refers to head1 when you code in its timeline. If you are coding on the timeline such that you see the movieclip "head1", and on frame 2 you see "head2" (for the second speed), etc. then "this" will refer to blowjobSymbol as you're coding in blowjobSymbol's timeline.


If your movieclip structure is more or less finalized, then you can replace all "MovieClip(root).blowjobSymbol" inside "head1" and anything inside it with "parent" (e.g. parent.speed, etc.), which would make your code a lot more readable.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 9/18/20 12:13 PM, Gimmick wrote:
At 9/17/20 10:20 AM, Edeshye wrote:
in the middle frame there is also a variable, "MovieClip(root).blowjobSymbol.middle = true;" because then in each speed frame there is this code:
if(middle){bj.gotoAndPlay("middleFrame"); (bj being the instance name of the girl in every speed frame and "middleFrame" being the instance name of the middle frame in each speed symbol.
Using trace("asdasdas"); to find out where was it that the code wasn't working i found that it is this particular code ☝️
I think the problem is with the way you used the variable "middle". Try calling "trace(middle)" and see what the output is - by default, Flash doesn't know that "middle" and "MovieClip(root).blowjobSymbol.middle" are the same. To fix this, just assign the value of blowjobSymbol.middle to a variable called middle:

And it should work. Alternatively, if you are already in blowjobSymbol's timeline, then try using

That's another downside of using frame scripts. While using document class code to separate the various classes is tedious, it doesn't cause confusion between local variables and member variables - "middle" could refer to blowjobSymbol.middle (a variable belonging to the object "blowjobSymbol") OR an undefined, unbound local variable (a variable that isn't attached to anything)

--


Unfortunately this is not it. The code works just fine, it is only when the hand is visible that it stops working... i can't understand what is going on. Even when i unclick, for the hand to disappear, the code goes back to working just fine. This makes me believe it is something about that constructor code. Well, that and the error message... i'm gonna paste it here:


TypeError: Error #1009: Cannot access a property or method of a null object reference.

at p04facefuck2_fla::p04mina_44/frame67()

at flash.display::MovieClip/gotoAndStop()

at p04maoAtras()

at flash.display::Sprite/constructChildren()

at flash.display::Sprite()

at flash.display::MovieClip()

at p04facefuck2_fla::p03carachupandodentro_78()

at flash.display::Sprite/constructChildren()

at flash.display::Sprite()

at flash.display::MovieClip()

at p04facefuck2_fla::p04cabeca_chupandov2_104()

at flash.display::Sprite/constructChildren()

at flash.display::Sprite()

at flash.display::MovieClip()

at p04facefuck2_fla::p04velocidade2_102()

at flash.display::MovieClip/gotoAndStop()

at p04facefuck2_fla::p04velocidade1_70/frame27()

at flash.display::MovieClip/gotoAndStop()

at p04facefuck2_fla::p04mina_44/maoListener()


(this is the error that appear when i click another speed button while the hand is visible)



As an aside, there's two types of variable referencing (in this context, anyways) - relative and absolute (like filesystem paths.) You're doing absolute referencing but it isn't necessary if you know the relative locations.

For example, you have the structure:

If your code is in "head1" (indicated by the arrow) then you don't need to use the absolute address of
You can just go one level up and reference it:
"parent" is a function in the DisplayObject class that refers to the movieclip or sprite (more generally, a "DisplayObjectContainer") that it is inside. In this case, since head1 is on frame 1 of blowjobSymbol, head1.parent is the same as MovieClip(root).blowjobSymbol.

If you call "trace(this.parent == MovieClip(root).blowjobSymbol)" in the head1 frame code, then you should see "true" as the output - because "this" refers to head1 when you code in its timeline. If you are coding on the timeline such that you see the movieclip "head1", and on frame 2 you see "head2" (for the second speed), etc. then "this" will refer to blowjobSymbol as you're coding in blowjobSymbol's timeline.

If your movieclip structure is more or less finalized, then you can replace all "MovieClip(root).blowjobSymbol" inside "head1" and anything inside it with "parent" (e.g. parent.speed, etc.), which would make your code a lot more readable.


Damn, this is very useful. I always thought there would be something like this "parent" thing but i honestly didn't even know how to search for it. Now i'll be able to make self working symbols that i can just paste inside the game, not worrying about changing the codes for it to fit the symbol's new home, heh. Thank you!


Making human hentai.

BBS Signature

At 9/18/20 01:32 PM, Edeshye wrote:
At 9/18/20 12:13 PM, Gimmick wrote:
At 9/17/20 10:20 AM, Edeshye wrote:
in the middle frame there is also a variable, "MovieClip(root).blowjobSymbol.middle = true;" because then in each speed frame there is this code:
if(middle){bj.gotoAndPlay("middleFrame"); (bj being the instance name of the girl in every speed frame and "middleFrame" being the instance name of the middle frame in each speed symbol.

(Side note, "middleFrame" is technically called a "frame label" in this context - frames have no instance names themselves. Just mentioning this because I tend to get a bit confused by calling middleFrame an instance name)


Unfortunately this is not it. The code works just fine, it is only when the hand is visible that it stops working... i can't understand what is going on. Even when i unclick, for the hand to disappear, the code goes back to working just fine. This makes me believe it is something about that constructor code. Well, that and the error message... i'm gonna paste it here:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
(this is the error that appear when i click another speed button while the hand is visible)


Looks like I got ahead of myself. I'm finding it a bit difficult to wrap my head around all this through just text, but where is "middleFrame"? Is it a frame label of the blowjobSymbol clip, or of the head clip?


From what I gather, this seems to be the structure:

root
 blowjobSymbol
  animation_layer:
    frame1:
      head1 ---------> (key point 1) ----middleFrame---> (key point 2)
    frame2: head2 ---------> (key point 1) ----middleFrame---> (key point 2)
  button_layer:
    speedbutton (all frames)


Is that correct?


I have another suggestion:

  • Remove all the frames and collapse everything onto one frame. All the head speed movieclips should be on the same frame. Name them something like "head1", "head2" or something.
  • Give the speed changing buttons the variable name "speed1". "speed2", "speed3" or something. Remove all the code for those buttons.
  • Get rid of the code on the key points in the head mc. Just make sure that the "head" animations have NO code in them whatsoever. However, you can note down the frame number of those key points in the keyPoints array below.
  • Put the following code on the actions layer:
import flash.events.*;
var allSpeeds:Array = [this.speed1, this.speed2, this.speed3] //variable names of buttons
var girlHeads:Array = [this.head1, this.head2, this.head3] //variable names of heads
var keyPoints:Array = [1, this.head1.totalFrames]; //say the first and last frame of the head1 movieclip
var currSpeed:uint, prevSpeed:uint; //new speed and old speed
for(var i:uint = 0; i < allSpeeds.length; ++i) {
  allSpeeds[i].addEventListener(changeSpeedOnClick);
}
function changeSpeedOnClick(evt:MouseEvent):void {
  currSpeed = allSpeeds.indexOf(evt.currentTarget);
}
function setVisibleHead(index:uint, frame:int):void {
  for(var i:uint = 0; i < girlHeads.length; ++i) { //skip first head - keep it visible as default
    var currHead:MovieClip = girlHeads[i];
    currHead.visible = (i == index); //visible if it's the same as index.
    currHead.gotoAndStop(1);
  }
  girlHeads[index].gotoAndPlay(frame)
}
function checkForAnimationSwitch(evt:Event):void {
  if(currSpeed != prevSpeed) { //not strictly required, but an optimization. If this causes problems, remove prevSpeed and the condition check
    var currHead:MovieClip = girlHeads[prevSpeed];
    if(keyPoints.indexOf(currHead.currentFrame) != -1) { //checks if current frame is key point
       setVisibleHead(currSpeed, currHead.currentFrame) //seamlessly switches head at key point - same frame as the previous head
       prevSpeed = currSpeed
    }
  }
}

addEventListener(Event.ENTER_FRAME, checkForAnimationSwitch);
setVisibleHead(prevSpeed, 0); //sets the first head to visible and plays it, and everything else to invisible and stopped


In theory, this should make one switch to the next at a key point by making the next speed visible, and everything else invisible, giving the illusion of "changing frames". Instead of dealing with separate frames, they're all accessible to Flash since they're all on the same frame, and there *should* be no more errors because there's no frame switching going on. If this works, you can convert blowjobSymbol MC to a Sprite with only 1 frame, because it's more lightweight and faster. And comes with a guarantee that there won't be any multi-frame chicanery :p


This shouldn't take long, but I recommend you save it as a new file or something before trying it out. I wrote this code in about fifteen minutes so there may be some errors that might have slipped by, even though everything seems fine in theory.

Damn, this is very useful. I always thought there would be something like this "parent" thing but i honestly didn't even know how to search for it. Now i'll be able to make self working symbols that i can just paste inside the game, not worrying about changing the codes for it to fit the symbol's new home, heh. Thank you!


No problem! Flash follows a Display List style similar to the HTML DOM - so each visible object on the stage has a parent, a root, a getChildBy (name, index) method, and some other similarities - so you might be able to work more effectively knowing those analogues exist!


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature