View Full Version : calling external scripts with functions
Using AS 3.0..
If I have a project, lets say that I want to manage more easilly without so much scrolling, (and more efficiency)can I call on certian scripts to execute with a function and event listener, it makes sense at a first glance.
Then the question would be how.
Any tutorials or examples that demonstrate this?
Medyman
05-22-2008, 04:24 PM
I'm not sure what you mean. Can you provide some pseudo-code of what you would logically like to see happen?
Specifically, what do you mean by "scripts" being called by functions?
User scenario:
clicks tool bar --icon changes(I have not shown that here) --script from external actionscript file added and will only become active with mouse_up -I imagine with a boolean value, or any kind of condition it doesn't matter
I am thinking about keeping my project in pieces that I only need when I call them. It may make work easier later
1--
so here is what I more or less have in mind:
var a:Number =1;
if (a == 1);{
trace("option a");}
-saved it is "hello.as"in the same directory as "project.fla" and in the target window I selected "project.fla"
could I then include some code like this (not exactly -because it's incorrect)
hello
//include hello.as file link here
var confirm:Boolean = false;
activate_btn.addEventListener(MouseEvent.MOUSE_UP,include_script);
//call script
function include_script(evt:MouseEvent):void{
var confirm = true;
}
--that would use activate_btn to activate the code from hello.as
is this done?
2--
not to mention am I attatching scripts the right way? Namely creating an .as script and "targeting" the .fla -Is there any code that needs to call that script as with classes?
Medyman
05-22-2008, 09:37 PM
Ahh, I see.
So you want to dive into Object Oriented Programming. Let me point you towards some video tutorials on the subject. If you have any more questions after watching these, feel free to ask.
In "Introduction to Object Oriented Programming (http://gotoandlearn.com/player.php?id=48)", Lee Brimelow of gotoAndLearn() goes over the basics of OOP in ActionScript 2.0. In it, he scripts a basic menu and explains how OOP can be a time/effort saver as well as allows for cleaner code.
Flash CS3 is really intened to be used for OOP projects. At least, it allows for easier integrated OOP techniques -- hence the Document Class. In "Objected-Oriented Scrollbar" (part 1 (http://gotoandlearn.com/player.php?id=71) and part 2 (http://gotoandlearn.com/player.php?id=72)), Lee goes over the implentation of OOP techniques in AS 3.0 to create a reusable scroolbar.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.