-
[RESOLVED] Global variables seemingly unavailable
Hi everyone,
I'm somewhat new to flash and AS3 (studying a HND with a multimedia module that uses flash, been using for about 5-6 months) so there's a chance i'm missing something basic, but i think i've understood the scope of variable declaration well enough to know that the error i'm receiving shouldn't be occurring:
1120: Access of undefined property SoundState
This is one of many iterations of the same issue, so i'll try to limit my code to just this one area to minimise this post. In my first frame i'm declaring the variable SoundState as a global variable for use in later frames:
Code:
import flash.events.MouseEvent;
import flash.media.Sound;
stop();
Begin.addEventListener(MouseEvent.CLICK, GoToMenu);
// Load tracking variables for UI elements
var HintTimerState:Boolean = true;
var SoundState:Boolean = true;
// Load sounds ready for use
var ClickSound:Sound = new Click();
function GoToMenu (e:MouseEvent) {
gotoAndStop("Menu");
}
I have a movieclip that i've added on my UI that has two frames of animation, one for sound on, another for sound off. Clicking alters the visual element and should set the SoundState boolean accordingly:
FRAME 1 OF MOVIECLIP ANIMATION
Code:
import flash.events.MouseEvent;
stop();
this.addEventListener(MouseEvent.CLICK, mute)
function mute (e:MouseEvent) {
this.removeEventListener(MouseEvent.CLICK, mute);
SoundState = false;
gotoAndStop("Muted");
}
The UI buttons are first introduced on frame 2 so the variables should be initialised in the first frame and therefore exist for the second.
If someone could please advise me how to correct my mistake (whatever it is) I would be greatly appreciative. Ideally i'd like to limit OOP as much as possible, as i designed my project to use a simple (if bloated) frame-by-frame structure and i'd like to keep to that if possible.
Many thanks!
David
Last edited by Davirtuoso; 03-14-2016 at 09:54 AM.
Reason: mention use of AS3
-
.
HI,
Try something like:
PHP Code:
this(parent).SoundState = false;
It helps to attach your fla sometimes, save us time having to try and mimic it.
-
Thanks very much for that, that did the trick. Also thank you for the note - i'll try to include files for reference in future! Your assistance is greatly appreciated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|