ActionScript 3.0 :: Run Stage Function From AS File?
Jul 20, 2010
i am making a game in action script,i have the regular scene (stage) with actionscript code functions, game intialization etc,and external AS file the works with that (assigned to some movie clip)can i run function that is on the stage from this AS file?
i tried this:
var main:MovieClip = MovieClip(this.parent.parent); main.increaseScore();
this.parent.removeChild(this);
it workes inside a movieclip, but not in external AS (class) file...
View 6 Replies
Similar Posts:
May 14, 2011
- I have A.fla.
- A.fla includes buttons, movie clips and also B.swf is loaded in A.fla using a LOADER
- i want to access elements in A.fla, from the actionscript codes inside B.fla to modify those movie clips and buttons based on actions going on in B.swf
for instance, lets say there is a button X in A.fla, and there is a button Y in B.fla, B.swf is loaded into A.fla, and I want the button Y to erase button X when clicked.
general question: accessing elements in a stage, through a SWF file loaded into that stage.
View 2 Replies
Nov 20, 2009
All I'm trying to do is load an external .swf file into a precise location on the stage of my existing Flash file. I've spent an hour and a half on this site search and found nothing. What do I add to my loadMovie command to place the file at specific x,y coordinates?
View 3 Replies
Aug 12, 2009
I am trying to send a function to my SWF file via a HTML file, and every browser works fine except for Internet Explorer.The test file is supposed to animate the graph when you mouse over the word click, and come to a halt upon mousing off of it.Here is the example URL:[URL]
*** begin ***
<script type="text/javascript"> function sendToActionScript(str) { document["accelachart"].sendToActionScript(str); }</script>
<a href = "#" onmouseover="sendToActionScript('fast')" onmouseout="sendToActionScript('slow')">click</a>
[code]....
Like I said before, it works on all browsers I tested (Chrome, FireFox, Safari) except for IE (7 or 8).
View 7 Replies
Jun 12, 2010
i create three circles. if a circle is dragged to right side of the stage, it becomes invisible and vice versa. when MOUSE_UP is invoked, it must stay in its last position. so in the appear() function how can i assign the selected circle to current_mc?
[Code]...
View 1 Replies
Oct 30, 2009
I have a file in which I use this stage resize function. However if I resize really fast (like maximize button) it doesn't resize the Timeline.
Code:
stage.addEventListener(Event.RESIZE,resizeStage);
private function resizeStage(e:Event):void{
resetVideo();
_controlbar.resetControlBar(stage.stageWidth);
_barlength = _clickbar.width;
_levelstart = _level.x;
[Code] .....
View 2 Replies
Oct 13, 2010
I've begun development on a isometric game, and have what I thought to be the hard part out of the way - the map generation from external files, screen-to-isometric conversions, etc. However I'm getting stumped on the "easy" stuff.Basically what I'm trying to do is this. Create a function that will add an object to the map (stage), then add an eventlistener so when it's clicked on, it gets added to the player's inventory. Lets take this sample code:
Code:
public function addObjectToWorld(o:IsoObject):void {
// ...code to add it to the world
[code]....
View 1 Replies
Jul 22, 2010
I have a function in stage and need to call it from a child I do I do it...
// In main stage
var child_mc:mcChild = new mcChild();
addChild(child_mc);
[code].....
View 2 Replies
Oct 13, 2011
I want to know how to prevent the user from drawing outside my school board.
My board image sizes 709.15 X 499.5. So I thought of something like this...
if(stage.stageWidth <= 709)
But if my board image is being called as a variable on stage boardActiva it should be easier.
Here's the function that draws:
private function dibujar(e:MouseEvent){
trace(e.localY);
tizaActiva.x = e.stageX;
[Code].....
View 1 Replies
Jul 1, 2009
how would i write a function for rollOut from stage?ex:
ActionScript Code:
stage.onRollOut = function()
{
//code here
}
View 3 Replies
Oct 11, 2009
I have a swf that I'm compiling for flash player 9. There's a few text fields on it that are selectable. When the page first loads, I want the first field to already be highlighted and ready for input.I've added this in the main function, and it works when I run the debugger or load it on my windows machine:[code]However, when I run the same swf on my linux machine the first field doesn't "highlight" until I click somewhere on the screen. Must be a linux thing.What's an alternate method to trigger an event when the stage has finished loading that I can try?
View 5 Replies
May 10, 2011
I would like to make a function that lets me load a movie clip onto the stage like this:
ActionScript Code:
function callImage(i:Class):void {
var img_loader:i = new i();
stage.addChild(img_loader);
}
callImage(b0_base);
b0_base is the class name for my MC. Is this possible? or do I have to write a different function for each Movie clip?
View 5 Replies
Mar 31, 2004
i want to do a simple function and incorpore it into every mc in my flash movie.In mx, i use prototype, but in mx2004, you cannot use it.how would you assign a function to selected mc's on the stage.[code]how can i do the same in as2 using class or subclass ?
View 4 Replies
Aug 13, 2007
Does anyone know how to addChild(aMovieClip) to stage by using a static function, like:
public static var player
public static function LoadPlayer()
{
GameEngine.player = new Player
stage.addChild(player)
}
(Or better yet tell me how to run functions in different class without creating instances of them or using static function )
View 8 Replies
Apr 18, 2009
My requirement/need is the AS3 code for placing any type of Component(viz., Button, CheckBox, ComboBox, ListBox, radiobutton, Slider, Scrollbar,Label,TextField, etc.,) on the stage with desired width,height, X and Y parameters(values) which we mention in "Properties" tab of Properties Window in flash. Hence, What i need is, (say)a generic ActionScript 3.0 method/function, which places any of the components present in "Components Panel" onto the stage. the function prototype or signature may be like this:
function addComponent(int <width>, int <height>, int <XPos>, int <YPos>)
t is a general query i think so. i.e., A basic programmer's task for defining a function for my requirement.I think,if I want to add a Button onto the stage at 100,100 pixel position and the button component's width and height are 50,50 respectively, (i.e., button.X=button.Y=100 && button.width=button.height=50).So, a button must be placed at 100,100, then, the sample code looks like this:
Button <btn_instance> = new Button(); //creates Button instance
<btn_instance>.addComponent(50,50,100,100);// properties of button.
View 2 Replies
Feb 2, 2012
I have to call a function that is defined on the main stage of my project, and I have to call it from a MovieClip
View 3 Replies
Apr 26, 2010
I am using foll0wing code to fetch data from XML file to flash.
Code:
function xmlLoad(fileName:String){
var pagedata:XML = new XML();
pagedata.ignoreWhite = true;
[Code]....
The problem I am encountering is that when I call function "createVar()" it looses the stage reference and "pagedata", my xml object.
View 0 Replies
Dec 10, 2010
How do you access the stage from a function in a document class file? I tried a fairly simple:
ActionScript Code:
var main:MovieClip = new MovieClip();
addChild(main)
var _stage:Stage = main.stage;
trace(_stage);
The result was null.
View 5 Replies
Oct 11, 2011
I am trying to make a game, I have worked out all the movement, shooting, updating stats techniques, but I have a problem that is not so obvious to me. I need to go to new frame(stages' new frame) every time left mouse button is pressed.
How can I tell stage to do gotoAndStop(); function from a custom class?
View 9 Replies
Mar 3, 2012
1) In my program, I am wanting to create a function that would take in the height and width of a loader object, compare them to the stage dimensions, and then scale the object in question before it is added to the display list. However, I have several different types of classes that I want to make use of this functionality. So what would be better, to create a NEW class that would have to be created each time a resize needed to occur, and is imported by all needed classes, or just have a function within each already existing object and copy that function to every class's scope that needs it? Would this be resolved by placing the function in question inside of the default package?
2) When accessing stage properties, are they a global or a relative scope? i.e.[code]would those two statements produce the same value regardless of whether they were in the default package or inside of 1300 classes? Or is the stage scope relative to some degree?
View 6 Replies
Mar 29, 2012
[code]This is called as part of the die() function I've created for an enemy in the small game I'm making.The idea being that when the enemy dies, it attaches a movieclip of an XP orb.And it does this perfectly well.The issue is in the last bit of the code.I'm attempting to call the setType() function within the class that the XP orb is in.However, it isn't setting the type to 100.
View 3 Replies
Apr 25, 2007
I'm having issues with something wanted to accomplish involving qued amations that i can reuse in various situations throughout an application...
Basically, what I'm trying to get is a prototype or function that will allows for multiple instances on that stage that start at a specific x/y and size, animate to a specific x/y size and end at a specific x/y and size... the x/y and size information is defined for each of the instances in the function.
A good place for this would be with buttons... check the sloppy diagram attached.
View 13 Replies
Apr 18, 2009
I am new to flash and ActionScript 3.0.I am learning ActionScript 3.0. My requirement/need is the AS3 code for placing any type of Component(viz., Button, CheckBox, ComboBox, ListBox, radiobutton, Slider, Scrollbar,Label,TextField, etc.,) on the stage with desired width,height, X and Y parameters(values) which we mention in "Properties" tab of Properties Window in flash.
Hence, What I need is, (say)a generic ActionScript 3.0 method/function, which places any of the components present in "Components Panel" onto the stage. i.e., As per my idea, the function prototype or signature may be like this:
function addComponent(int <width>, int <height>, int <XPos>, int <YPos>)
i.e., A basic programmer's task for defining a function for my requirement. I think,if I want to add a Button onto the stage at 100,100 pixel position and the button component's width and height are 50,50 respectively,
(i.e., button.X=button.Y=100 && button.width=button.height=50).
So, a button must be placed at 100,100, then, the sample code looks like this:
Button <btn_instance> = new Button(); //creates Button instance
<btn_instance>.addComponent(50,50,100,100); // properties of button.
View 2 Replies
Feb 9, 2010
I want to make 5 buttons visible after a logo has animatedI have a function called vis that successfully makes the buttons visible.How do I call this from within the movie clip (instance name 'logo'?)first frame of main timeline code:
stop();
function vis () {
webMC.visible = true;
[code].....
View 1 Replies
Jul 16, 2004
I have a query regarding OOP and Movieclips and custom classes (something I haven't been able to get the hang of). I will try and demonstrate my question with an example (I can't think of how else to explain it).
1. I have created a custom class with a variables and a function
function myNote(myNumber){
var myNumber;
}
2. I have then added a prototype of the movieClip class
myNote.prototype = new MovieClip();
3. Created another function
myNote.prototype.onMouseUp = function(){
trace("The number of the note you have clicked is: "+ this.myNumber);
}
4. Finally I have registered the custom class with a movieclip in the library
Object.registerClass("note", myNote);
5. Then I create a few instances of the movieClip on stage
attachMovie("note", 'n0', 100, {myNumber: '1'});
attachMovie("note", 'n1', 101, {myNumber: '2'});
attachMovie("note", 'n2', 102, {myNumber: '3'});
THE PROBLEM: Now that I have three instances of the movieClip on the stage, so when I click on any of them, the function (onMouseUp...) is summonded and the number (myNumber) of the movie clip is traced in the output window.But instead of showing the number of the movieClip i clicked on, I get the numbers of ALL the movieclips on stage.Why is the function running for all the movieclips on stage? Where am I going wrong? You see ultimately I would like that whichever movieClip i click on, it should change a varibale flag (which will be defined in the class) to activated, but if I face the above problem, then all movieclips will have their flag values changed to activate irrespective of which i click on.
View 4 Replies
Jun 6, 2011
I'm having issues having a swf file with a sliding navigation controlled by as2 be functional when its housed within a lookbook/sliding slideshow employing as2 that's referencing the sliding navigation swf file. the swf file with the sliding navigation functions on its own perfectly, but when it's called within the lookbook file, only the arrow/graphic controlling the navigation/movement works. the image the navigation moves doesn't function when its housed within the lookbook swf file. Both files reference the same AS folder containing a greensock folder for tweening etc.
AS2 for lookbook functionality:
function hideIt(what){what._visible = false;}function showSlide(direction){if (direction == "next") {++position;}if (direction == "prev") {--position;}if (position == _root.totalSlides) {arrowNext.enabled = false;gs.TweenLite.to(arrowNext, 0.35, {_alpha: 0});gs.TweenLite.to(arrowNext.top, 0.35, {tint: arrowOffColor});}else if (position != 0) {arrowNext.enabled =
[code]....
View 12 Replies
Jun 6, 2011
I'm having issues having a swf file with a sliding navigation controlled by as2 be functional when its housed within a lookbook/sliding slideshow employing as2 that's referencing the sliding navigation swf file. the swf file with the sliding navigation functions on its own perfectly, but when it's called within the lookbook file, only the arrow/graphic controlling the navigation/movement works. the image the navigation moves doesn't function when its housed within the lookbook swf file. Both files reference the same AS folder containing a greensock folder for tweening etc. Does anyone have any idea what i'm doing wrong within the code i've provided below? I'm relatively new to AS,
[Code]...
View 5 Replies
Jan 2, 2010
I'm trying to wrapup a slideshow for a client and the client asked for keyboardEvents in addition to buttonEvents. So I went ahead and added a stage.addEventListener and it works but only if you click on the stage first. In Flash CS4 itself when you test a movie, the problem doesn't happen but when you test it in a browser, the problem exists. Go to [URL] and see what I mean. Try the keyboard left and right arrows first. Then click on the stage and try again. How can I make it get focus on the stage on startup?
View 21 Replies
Jan 23, 2010
my problem is I have a scrolling list. I applied a simple fade in on mouse Over and fade out on Mouse Out using tweenMax.The buttons etc within the list cause the mouse Out to fire when the mouse is still over the list. I can not set mouseChildren = false on the playlist as the buttons inside obviously need to work.
So I thought maybe I could detect if the mouse is inside a specific area and fire the tween functions that way.I could use a stage enterFrame event listener, but that would keep firing the Fade in tween while the mouse was inside the area, and same problem with Fade out tween.How can I set it up so the fade in fires only once when mouse enters the area, and fade out only once when it leaves.
PHP Code:
stage.addEventListener(Event.ENTER_FRAME, playlistFade);
function playlistFade(e:Event):void{
if(mouseX >= 160 && mousX <= 400 && mouseY >= -177 && mouseY <= 100){
[code]....
View 1 Replies
Jun 20, 2011
How stage.invalidate() function and Event.RENDER works?
View 6 Replies