[vet-mm] global and local variables

Stoney, Marian Sy stoney.marian.sy at edumail.vic.gov.au
Wed Sep 5 10:34:03 EST 2007


Thanks Paul!
I'm with you on declaring timeline variables on the first frame, and have never really needed global variables, but thought I had better investigate the area a bit, seeing the "course" expects our students to understand scope and there was a question on it in the 2004 exam.
The way you approach variables as objects is new to me, but it makes a lot of sense,
Marian

________________________________

From: vet-mm-bounces at edulists.com.au on behalf of Paul Sijpkes
Sent: Wed 5/09/2007 9:16 AM
To: VET Multimedia Teachers' Mailing List
Subject: RE: [vet-mm] global and local variables



I know this is an old topic but I thought my input might be useful.

I tend to declare all variables on the first frame in the _root timeline, I don't use the _global option because it is bad programming practice.  

Global variables can easily become confused with locals, especially in bigger programs, it also makes your code less portable so you can't reuse it as easily.

Anyway, this is a huge topic, and I'm sure people will debate this with me, but in my opinion it's the best way to go.

 

I find the best practice is to create an object for each major part of your code in the _root timeline.

 

var presentation:Object = new ObjectI(); 

var audience.Object = new Object();

 

and then declaring the variables relating to that part inside the objects.

 

presentation.slides = 5;

presentation.boring = true;

audience.sleeping = true;

 

etc...

 

You can now reference these objects anywhere in your application using _root.presentation.slides, _root.audience.sleeping etc...

Hope this helps.

 

Cheers,

 

 

Paul Sijpkes
VET Coordinator
THE KNOX SCHOOL
Independent Co-educational International
Wantirna South VIC 3152
Phone: +61 3 9801 9233 
Fax: +61 3 9887 1850
Website: <http://mail1/exchweb/bin/redir.asp?URL=http://www.knox.vic.edu.au> www.knox.vic.edu.au <http://www.knox.vic.edu.aucricos/> 
CRICOS Provider No: 00151G ABN: 16 095 158 222

________________________________

From: vet-mm-bounces at edulists.com.au [mailto:vet-mm-bounces at edulists.com.au] On Behalf Of Stoney, Marian Sy
Sent: Wednesday, 22 August 2007 4:35 PM
To: VET Multimedia Teachers' Mailing List
Subject: RE: [vet-mm] global and local variables

 

Thanks, John. I haven't loaded Flash 8 yet but I'll have to now!  The advice on declaring them on the main timeline is good,

Regards,

Marian

________________________________

From: vet-mm-bounces at edulists.com.au on behalf of Mr John Parlas
Sent: Tue 21/08/2007 3:26 PM
To: VET Multimedia Teachers' Mailing List
Subject: RE: [vet-mm] global and local variables

Hi Marian,

 

Not sure what you mean but I suspect it has something to do with how the variables are declared. Hopefully the attached file can clear the water a bit. Basically, when variables are declared properly, globals can be used in other parts of the movie where as locals cannot. I tend to always declare globals main timeline - not within a function and just use them within the function.

 

Look in the frame script to see the code.

 

Hope this helps????? Flash 8 format.

 

Regards

John

________________________________

From: vet-mm-bounces at edulists.com.au [mailto:vet-mm-bounces at edulists.com.au] On Behalf Of Stoney, Marian Sy
Sent: Tuesday, 21 August 2007 12:20 PM
To: vet-mm at edulists.com.au
Subject: [vet-mm] global and local variables

 

Hi there all you Actionscript types!

I'm wondering why, if I declare a global variable on the timeline, it's available to a function on a movie clip, but if I declare a global variable inside a function on a movie clip, it's not available to the timeline, whilst still being available to other functions on other movie clips. I thought global functions were supposed to be available everywhere? I've attached my file, but it's a bit of a mess.

Grateful for any insights!

Thanks,

Marian

Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.

_______________________________________________ 
http://www.edulists.com.au <http://www.edulists.com.au/> - FAQ, resources, subscribe, unsubscribe 
VET Multimedia Mailing List kindly supported by 
http://www.vcaa.vic.edu.au/vet/programs/multimedia/multimedia.html <http://www.vcaa.vic.edu.au/vet/programs/multimedia/multimedia.html%20> - Victorian Curriculum and Assessment Authority and 
http://www.pixeled.org.au <http://www.pixeled.org.au/> - PixelEd Multimedia Teachers Association

_______________________________________________ 
http://www.edulists.com.au <http://www.edulists.com.au/> - FAQ, resources, subscribe, unsubscribe 
VET Multimedia Mailing List kindly supported by 
http://www.vcaa.vic.edu.au/vet/programs/multimedia/multimedia.html - Victorian Curriculum and Assessment Authority and 
http://www.pixeled.org.au <http://www.pixeled.org.au/> - PixelEd Multimedia Teachers Association 

DISCLAIMER:

This email and any files transmitted with it are confidential and intended solely for the use of the individual to whom they are addressed.

If you have received this email in error, please notify the sender immediately by return email and then delete this message. 

Any views expressed in this email are those of the individual sender and may not necessarily reflect the views of Yarra Valley Grammar.

_______________________________________________ 
http://www.edulists.com.au <http://www.edulists.com.au/> - FAQ, resources, subscribe, unsubscribe 
VET Multimedia Mailing List kindly supported by 
http://www.vcaa.vic.edu.au/vet/programs/multimedia/multimedia.html - Victorian Curriculum and Assessment Authority and 
http://www.pixeled.org.au <http://www.pixeled.org.au/> - PixelEd Multimedia Teachers Association 

Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 13680 bytes
Desc: not available
Url : http://www.edulists.com.au/pipermail/vet-mm/attachments/20070905/28457664/attachment.bin


More information about the vet-mm mailing list