Refrencing External AS Function - Not Working
I'm having trouble accessing a function in the _root timeline from the timeline of a loaded movie.
The main site is on one server - say called 'serverone.com' and it loads another movie from another server address using a direct http:// address:
loadMovie("http://www.anotherserver.com/myfile.swf "_root.shackHolder_mc.Group_mc.holder_mc");
I have a function in the main _root site timeline called 'swapSound' I am trying to execute this function from the last frame of myfile.swf the code i've used it
_root.swapSound(18);
This code works when the file to be loaded is in the same directory as the main site - ie. 'myfile.swf' is in the same folder as 'mainsite.swf' but I am hosting all the sound swfs on another server for bandwidth purposes. Once the file is loaded in from another location it doesnt work.
i've tried directly adding in the swapSound function into the 'myfile.swf' and using an external actionscript file with the .as prefix and using the #include script but neither of these have worked.
would it make a difference if 'myfile.swf' was loaded into a _level instead of a target movie clip on the _root file?
Would really appreciate some help, its been driving me a bit nuts!!
thanks
Robyn
FlashKit > Flash Help > Flash MX
Posted on: 12-21-2003, 08:35 PM
View Complete Forum Thread with Replies
Sponsored Links:
Drag Function Not Working In A External.swf
Hi, I have a swf. called "menu" that load a external .swf "sitios" with the conteiner method, and that movie have a drag button inside a movie clip called "sitiosmov" it works well draging that movie clip, but when "menu" loads "sitios" the drag button doesnt work, I check the route but I cant find the problem this is the code:
on (press) {
startDrag("/sitiosmov");
setProperty("/sitiosmov", _alpha, 30);
}
on (release) {
stopDrag();
setProperty("/sitiosmov", _alpha, 100);
}
thanks
View Replies !
View Related
Drag Function Not Working In A External.swf
Hi, I have a swf. called "menu" that load a external .swf "sitios" with the conteiner method, and that movie have a drag button inside a movie clip called "sitiosmov" it works well draging that movie clip, but when "menu" loads "sitios" the drag button doesnt work, I check the route but I cant find the problem this is the code:
on (press) {
startDrag("/sitiosmov");
setProperty("/sitiosmov", _alpha, 30);
}
on (release) {
stopDrag();
setProperty("/sitiosmov", _alpha, 100);
}
thanks
View Replies !
View Related
Refrencing In AS3
im trying to make a grid in flash where i got a square in the librray classed as Unit. i also have the class Grid with this in it:
Code:
package{
import flash.display.*;
import flash.events.*;
public class Grid extends MovieClip {
private static const rows:int = 16;
private static const cols:int = 16;
public function Grid(){
for (var i:int=1; i<=cols; i++){
for (var j:int=1; j<=rows; j++){
var unit:Unit = new Unit();
unit.name = "U"+i+"_"+j;
unit.c = i;
unit.r = j;
unit.x = i*28;
unit.y = j*28;
addChild(unit)
}
}
}
}
}
and this as the document class:
Code:
package{
import flash.display.*;
import flash.events.*
public class Main extends MovieClip {
public var grid:Grid = new Grid();
public function Main(){
addChild(grid);
}
}
}
in AS2 when you attached a movieclip to wherver, you could trace it and identify where it was and it existed. but now i cannot refrence an individual block on my grid outside of the Grid function let alone the grid class. where is it gone and where does "addChild" put the instance?
View Replies !
View Related
Refrencing Movieclips
Hi
I have a tutorial on how to preload external content by clicking a button.
I manage to make it work, but only when it is in the main time line, once I put it into a movie clip I cant seem to get the referencing right, and was hoping someone could help me out?
I know it shouldn't be to much of a problem, it is just I cant figure it out.
The script I use is on the first frame in the main timeline, the buttons that the user can click, will be inside a movieclip called, " mainmovie "
the button is called " movie1_btn " and I have tried like :
_root.mainmovie.movie1_btn.onPress = function(){
startPreload("load/tankoverhead.swf");
}
but it doesnt work.
Anyway here is the script I use appreciate any help I can get. Thanks in advance
// this function runs the preloader
// it is to be used with the onEnterFrame
// of the preloader animation
function preloadContainer(){
// get bytes loaded and total from container_mc
var bytes_loaded = container_mc.getBytesLoaded();
var bytes_total = container_mc.getBytesTotal();
// stop and hide the movie so it wont play or
// be seen while progressively downloading
// (keep trying if it exists or not just to be sure)
container_mc.stop();
container_mc._visible = false;
// if bytes_total is a valid number and greater than 0
if (bytes_total > 0){
// get percent loaded
var percent_loaded = bytes_loaded/bytes_total;
// update the value in the preloader
preloader_mc.value = percent_loaded;
// check if preloading is complete
if (percent_loaded == 1){
// play and show the container clip
container_mc.play();
container_mc._visible = true;
// remove the preloader movie clip
preloader_mc.removeMovieClip();
// delete the onEnterFrame event handler running this function
delete onEnterFrame;
}
}
}
// movie 1 loads the tankoverhead swf using startPreload
movie1_btn.onPress = function(){
startPreload("load/tankoverhead.swf");
}
// movie 2 loads the tankturn swf using startPreload
movie2_btn.onPress = function(){
startPreload("load/tankturn.swf");
}
// this function begins preloading a swf url
function startPreload(url){
// use loadMovie to load the swf url into container_mc
container_mc.loadMovie(url);
// attach the preloader animation
// this will be removed when preloading is complete
attachMovie("preloader anim", "preloader_mc", 500, {_x:275, _y:165});
// set the onEnterFrame event to call preloadContainer
onEnterFrame = preloadContainer;
}
View Replies !
View Related
Refrencing A Variable
I am trying to reference a name of a variable (dynamically) but Flash doesn't thing that. Look at the attached code. I have an Array called q1o, q2o, etc. It stands for question 1 options, etc. The Arrays hold 6 strings. I need the code for a quiz I am making, so if one of the options for the current question is "x", then it shouldn't show the radio button and give the user the option to select x.
Attach Code
if (q + (current_question + 1) + o[5] == "x")
{
option6.visible = false;
} else {
option6.visible = true;
}
View Replies !
View Related
Refrencing Child(duplicated) Mc's...
allrighy then-
I have a mouse trailer,( I know, I know- mouse trailers are so '99)
my duplicating action works but I want to be able to refrence the duplicated mc's...something like this:
code:
-----------------------------
i = i+1;
if (i > 10) {
i = 1;
}
duplicateMovieClip ("_root.clip", "clip"+i, i);
ypos = getProperty(_root.clip[2],_y);
--------------------------------
(this quick example I am only trying to get the property of the third duplicate clip.)
check out my variable ypos. I want to be able to then turn around and do a setProperty according to where the mouse is on the y axis.
so if you know the answer or can direct me to a tutorial, I will once again be a happy man
thank you...
View Replies !
View Related
Help Refrencing A Movie Clip...
I am making a copy of a movie clip like so...
this is in a loop, and count is being incrimented
taskMovie.duplicateMovieClip("taskMovies"+count, count);
The following line works fine
setProperty ("taskMovies"+count, _y, (20 * count));
but now I need to change the value of a text box inside the movie clip...
"taskMovies"+count.taskTitle = "test";
this doesn't work...
I tried
["taskMovies"+count]taskTitle = "test";
Doesn;t work...
any ideas?
View Replies !
View Related
Refrencing Level1 Library
I created an swf which loads another swf at level1. The swf at level1 attaches some movieclips from its library. It runs perfect when played individually.
I added those elements which are being attached from the library in level0 swf and then level1 movie runs perfectly.
Now the issue is that
- If I add the elements to level0 library then the elements make level0 swf heavy.
- If i make a shared library then all the elenets are loaded in the library thru swf which mus be preloaded.
but by these way the elements increasing size of both swf and weather the level1 movie is loaded or not its elements are in the memory.
to make the application memory optimized I need when the level1 movie is loaded it should refrence to its level1 library.
Please help.
View Replies !
View Related
Refrencing Array Items Already On Stage
i understand how the attached code works.
Code:
for (var m = 0; m<30; m++) {
thumbNails = picts.createEmptyMovieClip("thumbNails"+m, picts.getNextHighestDepth());
thumbNails.createEmptyMovieClip("thisThumb", this.getNextHighestDepth());
thumbNails.myNumber = m;
thumbNails._alpha = 50;
thumbNails.onRollOver = function() {
this.onEnterFrame = function() {
if (this._alpha<100) {
this._alpha += 10;
}
if (this._alpha>=100) {
delete this.onEnterFrame;
}
};
};
The idea in this was to learn how to individually refrence each instance in the array, without having to write m[0],m[1],m[2]...etc , 30 times for each action. I also wanted to learn how to duplicate clips with a for loop..It makes since to me when i am creating mc's from AScipt
. But how do i do the same idea, with 5 different mc's are already on the stage. I am sure it starts with classifying them into an array, But from there, my head got a bit boggled.. So far, i am taking it in this direction:
Code:
var demos:Array= [mc1.demoScrollBar,mc1.demoButton,mc1.demoNeedle,mc1.demoSnap,mc1.demoSafetyPin];
var thisDemo:MovieClip;
for(var d=0;d<demos.length;d++){
thisDemo=demos[d].createEmptyMovieClip("helpButtons", this.getNextHighestDepth());
demos[d]._alpha=50;
thisDemo.index=d
thisDemo.onRollOver=function(){
clearInterval(nAlpha);
nAlpha=setInterval(alphaUp,50,demos[this]);
}
thisDemo.onRollOut=function(){
clearInterval(nAlpha);
nAlpha=setInterval(alphaDown,50,demos[this]);
}
thisDemo.onRelease=function(){
txDemo.text=myXML.firstChild.childNodes[this.index].attributes.words;
}
}
however, it seems that i am not getting how i can refrence each mc without writing demos[0], demo[1], etc for each i want to addres with the onRelease. was that confusing? any ideas?
View Replies !
View Related
Trouble Refrencing Parent Objects
hello,
ive never really understood the heirarchy of things in flash, so im constantly having similar problems, but i can usually work them out. this one i cant, so i come to you all on my knees, hoping someone intelligent can help me.
heres the problem:
i have a button. this button is the only thing in a movie. i use attachmovie to make a 10x10 grid of these buttons. they have depths of 1-100. in the move code (the movie that contains the button) i have an onRelease function. in this function i want to delete the movie. if i try removeMovieClip() it says it needs a parameter. if i do this.removeMovieClip() then it doesnt remove it.
so in a nutshell, how do you delete a movie clip from within a movie clip?
View Replies !
View Related
Problem With Refrencing Instance On Stage
I have an instance of a radio button on the stage named option_mc1. I have the following code in the timeline (see below). However, Flash doesn't recognize the equation as an instance name of a radio button on the stage. If the current question was 0 (the first question) then allAnswers[current_question + 1] would equal 1. NOw, I add the 1 to optin_mc to equal option_mc1 (the name of the instance on the stage). The last past of the statement then makes it complete and says option_mc1.selected == true. Flash gives me errors such as: ReferenceError: Error #1069: Property selected not found on Number and there is no default value.
at halo_quiz_fla::MainTimeline/nextQuestion()
Is there a method or something that converts the first part of the statement so Flash knows im trying to refer to a move clip on the stage? Thanks.
Attach Code
next_btn.addEventListener(MouseEvent.CLICK, nextQuestion);
function nextQuestion(event:MouseEvent):void
{
if("option_mc" + allAnswers[current_question + 1].selected == true)
{
right ++;
} else {
wrong ++;
}
current_question ++;
}
View Replies !
View Related
Refrencing Movie Clips Created With "duplicateMovieClip"
okeedokee-
I have an animation that has floating bubbles in it.
the bubbles are created usng duplicateMovieClip
each of the bubbles contains a button (several levels down). When the button is pressed i want the movie to move to another frame (popped).
the animaton is a marketing thing and If the people can click the beJesus out of the buttons- everyone's hoing to win. so when it is clicked the buttin inside the movie clip gets the parent name (a name that is dynamically generated when the movie clip was generated, i.e. bubble_1, bubble_2) when I get the name I try to tell the movie clip inside te holder to advance one frame. but I am confused and it will not work.
i get the parent name using
// pop the bubble
// get my parent name
myParentName = _parent._parent._name;
trace ("parent name = "+myParentName);
and output shows the arent name so I am sure I am using the right name
i have tried the following:
_root.myParentName.holder.gotoAndPlay("labelname") ;
_parent._parent.gotoAndPlay("labelname");
this._parent.gotoAndPlay("labelname");
_root[myParentName].holder.gotoAndPlay("labelname");
_root[myParentName.holder]gotoAndPlay("labelname");
any help would be greatly appreciated, new to AS, and it seems there are still a lot of specifics I haven't figured out yet.
thanks in advance and all apologies for the misspellings,
-nathan
View Replies !
View Related
Function Not Working
I'm using flash 5 to develop.
I am very perplexed...
Here's my code....
============================
AScript, text_box and button on main timeline
function test (txt1, txt2) {
text_box = txt1 + txt2;
}
============================
on Button click.....
on (release) {
test ("Text One", "Text Two");
}
============================
The button works fine when run on local PC, but when uploaded to server, it doesn't work. I have Player 8 when I am browsing on the web
What is wrong?
View Replies !
View Related
Function Not Working
I'm having a problem with a function called "Move"...it's not being called unless I place it outside the ParticlePositive1_mc.onRelease function...here's the code(there aren't any script errors)...
Code:
var Times_n:Number = 0;
var Interval_n:Number = setInterval(Move, 1000);
ParticlePositive1_mc.onRelease = function() {
this.stopDrag();
this.onEnterFrame = function() {
if (this.hitTest(HitTest_mc)) {
ParticleBar1_mc._x = this._x;
ParticleBar1_mc._visible = true;
}
else {
ParticleBar1_mc._visible = false;
}
if ((this.hitTest(HitTest_mc)) && (ParticlePositive2_mc.hitTest(HitTest_mc))) {
delete this.onPress;
delete ParticlePositive2_mc.onPress;
if (this._x<ParticlePositive2_mc._x) {
function Move():Void {
trace("function Move is being called");
this._x--;
ParticlePositive2_mc._x++;
Times_n++;
if (Times_n>=1) {
clearInterval(Interval_n);
}
}
View Replies !
View Related
[F8] Function Not Working
Hi everyone,
I'm trying to get the following function to work:
function door() {
door_mc.gotoAndPlay("sceneOut");
mcLoader.loadClip("business.swf", myLoader);
door_mc.gotoAndPlay("sceneIn");
}
I then call the function here:
businessBtn_mc.onRelease = function() {
door();
}
It works fine as is but I'm trying to make it work for all the other buttons as well by trying to add a parameter to the function like this:
function door(movieName) {
door_mc.gotoAndPlay("sceneOut");
mcLoader.loadClip(eval(movieName), myLoader);
door_mc.gotoAndPlay("sceneIn");
}
then call the function again with the value added:
businessBtn_mc.onRelease = function() {
door("business.swf");
}
...but it doesn't work.
I've attached the fla files so you can see the full code.
I wonder if someone could take a look and see where I've gone wrong?
Thanks so much.
View Replies !
View Related
Function Working Only Once ?
Hi I have this function that scrolls my menu back to it's original place :
Code:
//Tweens
import mx.transitions.Tween;
import mx.transitions.easing.*;
ResetMenu = function() {
ResetScrollBar = new Tween(_root.scroll_bar, "_x", Bounce.easeOut, _level0.scroll_bar_x, 42.5, 1, true);
ResetMenu = new Tween(_root.menu_holder, "_x", Bounce.easeOut, _level0.menu_holder_x, 18, 1, true);
}
I call it from a button and it works but only the first time, if I click a second time on the button (after scrolling my menu) nothing happens :cry:
Code:
on (press) {
ResetMenu ();
}
Can you please help ?
dip
View Replies !
View Related
Function Not Working...
I'm having a problem with a function called "Move"...it's not being called unless I place it outside the ParticlePositive1_mc.onRelease function...here's the code(there aren't any script errors)...
Code:
var Times_n:Number = 0;
var Interval_n:Number = setInterval(Move, 1000);
ParticlePositive1_mc.onRelease = function() {
this.stopDrag();
this.onEnterFrame = function() {
if (this.hitTest(HitTest_mc)) {
ParticleBar1_mc._x = this._x;
ParticleBar1_mc._visible = true;
}
else {
ParticleBar1_mc._visible = false;
}
if ((this.hitTest(HitTest_mc)) && (ParticlePositive2_mc.hitTest(HitTest_mc))) {
delete this.onPress;
delete ParticlePositive2_mc.onPress;
if (this._x<ParticlePositive2_mc._x) {
function Move():Void {
trace("function Move is being called");
this._x--;
ParticlePositive2_mc._x++;
Times_n++;
if (Times_n>=1) {
clearInterval(Interval_n);
}
}
View Replies !
View Related
Function Not Working
on my main timeline on the frame
ActionScript Code:
stop();
csub._alpha = 0;
bsub._alpha = 0;
function FadeIn(c) {
this.onEnterFrame = function() {
if (c._alpha < 100) {
c._alpha+= 5;
}
}
}
function FadeOut(d) {
this.onEnterFrame = function() {
if (d._alpha > 0) {
d._alpha-= 5;
}
}
}
then on my button I have
ActionScript Code:
on(release) {
FadeIn(csub);
}
This all works great. Although if I do:
ActionScript Code:
on(release) {
FadeIn(csub);
FadeOut(bsub);
}
The Fade out works great too. Although the FadeIn stops working. Anyone know what I'm missing here?
Sandman9
View Replies !
View Related
Function Not Working Right.
I have a problem with my function, it works alright but for some reason it only works once at a time..
let me explain, i have a bullet and an object, when the bullet hits the object both mc's get unloaded but after they unload and effect and an item will appear in its place... but as soon as you hit another object with a bullet the first lot of item/effect dissappear? why is this?
here is my code..
I have an MC labeled functions and in its actions are these functions...
ActionScript Code:
onClipEvent(enterFrame){
dropchance = random(2);
}
onClipEvent(load){
unloadframe = 51;
depth = 0;
itemdepth = 99998;
function attachItem(a, b) {
if (dropchance == 0){
namea = "itemdrop" + itemdepth;
_root.attachMovie("itemdrop", namea, itemdepth, {_x:a, _y:b});
_root[namea].gotoAndStop(random(3)+1);
} else {
trace('No Drop');
}
}
function effectExplode(a, b) {
nameb = "explode" + depth;
_root.attachMovie("explode", nameb, depth, {_x:a, _y:b});
_root[nameb].onEnterFrame = function () {
if (this._currentframe == unloadframe) {
this.unloadMovie();
}
}
}
}
and the hittest is as follows:
ActionScript Code:
if (this.hitTest(_root.theobject)){
_root.theobject.unloadMovie();
this.unloadMovie();
_root.functions.effectExplode(this._x, this._y);
_root.functions.attachItem(this._x, this._y);
}
so why does this only work once and then seem to remove once another hittest occurs? i dont get it..
any help is welcomed.
thanks.
View Replies !
View Related
Function Not Working
i'm trying to call a function from inside nested functions and can't get it to work. i tried directing the scope of the call to the function every way i knew how (_global, _parent, _root) and even tried declaring the function in a different way like
var myFunction = new function() { ...... }
below is the appropriate part of my code. bospv2_start() is the function that won't work. what am i doing wrong? i can call the function in other places just fine.
Attach Code
function flushLSO() {
agent_so.data.bospv2_agentName = dataAgentName;
agent_so.data.bospv2_agentEmail = dataAgentEmail;
agent_so.data.bospv2_agentGroup = dataAgentGroup;
agent_so.flush();
var twLSOundefinedOut:Tween = new Tween(LSOundefined, "_alpha", Strong.easeOut, 100, 0, 3, false);
twLSOundefined.onMotionFinished = function() {
LSOundefined.removeMovieClip();
bospv2_start();
};
}
function bospv2_start() {
View Replies !
View Related
Function Not Working
I'm making a little quiz for school. And a function I used just the other day isn't working. Why not.
ActionScript Code:
stop();countries(c1,"Morocco",p1);//more African countries.function countries(box,count,countx){ if(box==count){ countx=1; }else{ countx=0;}
That's all on frame 1.
On frame one there's also an imput text box with the instance name c1, and a next frame button.
On the next frame I have a dynamic text box witht he instance name total.
frame 2 has the AS
ActionScript Code:
//imagine p1+p2+p3+p4toatal.text=p1}
Why dosen't this work?
View Replies !
View Related
Function Not Working
I don't get why my menu dropdown function is not working. It works when I put the instance name of the dropdown menu in, but when I try to use eval for the instance name it won't work. This code is giving me the problem.
ActionScript Code:
menuopen(eval("d"+q), -219, 0);
This is most of my AS
ActionScript Code:
/////////////////////////Button Functions/////////////////////////function menuclose(item, beg, end) { var butclose:Tween = new Tween(item, "_y", Strong.easeOut, beg, end, .3, true); var maskclose:Tween = new Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, -225, .3, true); clearInterval(dropup1);};function menuopen(item, beg, end) { var butopen:Tween = new Tween(item, "_y", Strong.easeOut, beg, end, .3, true); var maskopen:Tween = new Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, end, .3, true);};function butup(item) { if(dropup1 != null){ clearInterval(dropup1); } var butin:Tween = new Tween(item, "_alpha", Strong.easeOut, 0, 12, .5, true);};function butdown(item) { var butin:Tween = new Tween(item, "_alpha", Strong.easeOut, 12, 0, .5, true);};///////////////////////Button Actions/////////////////////////Buttons on the main nav barvar q:Number = 1;b1.onEnterFrame = function(){ eval("b"+q).onRollOver = function() { butup(this); menuopen(eval("d"+q), -219, 0); }; eval("b"+q).onRollOut = function() { butdown(this); dropup1 = setInterval(menuclose, 1000, eval("d"+q), 0, -225); }; eval("b"+q).onReleaseOutside = function() { butdown(this); dropup1 = setInterval(menuclose, 1000, eval("d"+q), 0, -225); }; q++; if(q == 3){ delete this.onEnterFrame; }}
View Replies !
View Related
Function Not Working
Hello good people!
Is this right?
PHP Code:
function something(){ //code}mc.onRelease = function(){ something();}
or is it like this?
PHP Code:
something = function(){ //code}mc.onRelease = something;
Thanks!
View Replies !
View Related
Function Not Working
ok, this is my first time using a function, help me:
on frame one i made the following function:
function introClosing(){
_root.gotoAndPlay("introClosing");
_root.introTitle.gotoAndPlay("16");
}
the function is called when a button is pressed
the first line works
the second lines works to the point of bringing up that movie clip instance, but it does not play frame 16
WHY??????? what have i done wrong and do u need more information?
View Replies !
View Related
Function Not Working
hi all,
could you pls help me this is the script i put this script in to my site but it is not working properly i don't no why is, when i am testing moving in site flash i worked but when access through browser it won't work why is that could you please help me
thanx somiadiscon
function _() {
}
function url1() {
getURL("javascript:window.external.AddFavorite('(URL address blocked: See forum rules))", "");
}
Stage.scaleMode = noScale;
var expand = new ContextMenu();
expand.hideBuiltInItems();
var $tab1 = new ContextMenuItem(" site ", tab, false, false, true);
var $url1 = new ContextMenuItem("Bookmark this site ...", url1);
var $tab2 = new ContextMenuItem("------------------------------------------", tab, false, false, true);
var $url2 = new ContextMenuItem(" Pro ", url2);
expand.customItems.push($tab1, $tab2, $url1, $url2);
expand.onSelect = menuHandler;
_root.menu = expand;
View Replies !
View Related
While Function Not Working With Else If Function
I got a code (
Code:
onClipEvent (enterFrame) {
if (_root.chatbox == "buy") { while (_root.shop == "What would you like to do?") {
_root.shop = "Yes, Ok then.";
_root.items._visible = 1;
} else if (_root.chatbox == "sell") {
_root.shop = "Ok. I see you have chosen sell.";
_root.items._visible = 0;
}
}
}
)
the Else if function doesnt seem to work well with while function.
When i got rid of the while function it worked.
Any one know why this is happening?
View Replies !
View Related
Random X Function Not Working
The function is supposed to assign a random x value to a movie clip, however it is not working.
Whats wrong with this function?
This actionscript is being called from frame 1 of layer 1 on the root:
function randomX() {
x = _x.random(490)+30;
return x;
}
This script is being called from a movie clip on frame 1 of layer 1 on the root:
onClipEvent (load) {
function randomX();
}
onClipEvent (enterFrame) {
if (_root._currentframe == 1) {
_x = (randomX.x());
}
}
View Replies !
View Related
How Do I 'stop' A Function From Working?
Hi, the animation that I'm trying to build is probaly very simple, but I can't quite work it out?
What I'm trying to make is a basic drag and drop where the object ('dragt') slowly returns to it's starting point by following the target ('targett') in order to get there.
The problem is that the function I'm using to move it there 'movet' = pasted in below) keeps going. So that when you try to click on it again, it's still working and it causes a flickering between the movement it's trying to accomplish and the drag action.
I tried included a variable ('ton') to build in a basic on/off state into the function, so that it won't work until 'ton == 0', ton is made equal to 0 as part of the start drag action. However, as said, this only works once as the function is still going when you go back to click again. So the hitest (seen below) registers again and puts 'ton == 1' before the drag can even begin.
So... what I need is some way to tell the function to stop doing what it's doing when the movieclip returns to it's original co-ordinates?
Hopefully I'm explaining this in some way that makes a degree of sense and somebody can solve this, or has encountered something similar before,
thanks loads,
-Eoin McD
Here's the function:
setInterval(movet, 5);
// call the catchase function every 5 ms
function movet() {
// set x, y for cat closer to x, y of mouse
if (_root.ton == 0) {
_root.dragt._x = _root.dragt._x+(_root.targett._x-_root.dragt._x)/20;
_root.dragt._y = _root.dragt._y+(_root.targett._y-_root.dragt._y)/20;
}
if (_root.dragt.hitTest(_root.targett)) {
_root.ton = 1;
}
if (_root.ton == 1) {
gotoAndStop(1);
}
}
updateAfterEvent();
View Replies !
View Related
For Loop In A Function Is Not Working HELP
Hi,
I have a preloader scene. This scene preloads and also loads my ASP page that contains variables like baseURLs, etc. I load my asp file and then run a function. The function stores these global variables. My problem comes in when I get to the for loop in the function. The for loop does not execute. I'm positive that the reason is that the variable _root.sliderFileTotal has not been loaded from the ASP file yet. Instead the for loop runs first and cannot get the value of _root.sliderFileTotal .
I know this because I've traced _root.sliderFileTotal outside of the for loop and I get the value. But in the for loop it does not trace. I'm sure that the for loop is taking precedence in the function and is running first.
Can anyone help me with this. I've been stuck on this the entire day. Also, I don't want to take the for loop out of the function. Everything else works fine in this function so I don't really want to drastically modify all this code because my deadline is breathing down my neck.
Thank you for your help (and even reading this far).
frame1:
Code:
var fileNames = new LoadVars();
fileNames.load("Flash/getFileNames.asp");
frame2:
Code:
fileNames.onLoad = function(success) {
if (success) {
// set the baseURL global variables + get the filenames to be loaded
_root.bottomURL = fileNames.bottomURL;
_root.baseURL = fileNames.baseURL;
_root.baseXMLURL = fileNames.baseXMLURL;
_root.billBoardFile = fileNames.billBoardFile;
_root.cube1File = fileNames.cube1File;
_root.cube2File = fileNames.cube2File;
_root.cube3File = fileNames.cube3File;
_root.cube4File = fileNames.cube4File;
_root.cube5File = fileNames.cube5File;
_root.cube6File = fileNames.cube6File;
_root.cube7File = fileNames.cube7File;
_root.cube8File = fileNames.cube8File;
_root.cube9File = fileNames.cube9File;
_root.comboBoxFile = fileNames.comboBoxFile;
_root.competitionBoardFile = fileNames.competitionBoardFile;
_root.sliderFileTotal = fileNames.sliderFileTotal;
for(n=1;n<_root.sliderFileTotal+1;n++) {
_root["slider"+n+"file"] = fileNames["slider"+n+"File"];
trace(n); // here's my problem. n does not trace. it's not hitting the for loop
}
}
}
if (fileNames.loaded && _framesloaded >= _totalframes) {
gotoAndStop ("Scene 1", 1);
} else {
var loadedbytes = getBytesLoaded();
var totalbytes = getBytesTotal();
var frame = int(loadedbytes/(totalbytes/100));
loader.gotoAndStop(frame);
}
frame3:
Code:
gotoAndPlay(2);
View Replies !
View Related
On(rollover){do Function();) Not Working Right
I have a MC containing just the nav buttons for my movie. on this MC's timeline I have two functions. One opens a display, the second closes it.
I also have many buttons that each have an call to the first function to open the display and write some text when the mouse is over them.
There is also one lone button that actually closes the display. It calls the second function on mouse over.
Well up to this point all work fine (kinda). See the problem is after you mouseover one button the rest will not work. To be clearer, if I play the movie and mouseover button1 the function will execute as expected. If I then mouse over button2 nothing happens. Same thing if I start with button2, then button 1 will not work.
Here's the details
I have reduced this to be readable but even these few lines do not work.
function showHint(hintStr){
hintBoxMC.hintBox.text=hintStr;
hintBoxMC._alpha=100;
return false;
}
function resetHint(){
hintBoxMC.hintBox.text="";
hintBoxMC._alpha=0;
return false;
}
All of the buttons except for one call showHint on(mouseOver)
The other button calls resetHint();
Since all of the buttons work (as long as they are the first one pressed) I know the tergeting is correct. Also all MC's within this MC are paused at this point so that shouldn't be an issue.
Any ideas? Thanks in advance
View Replies !
View Related
Function Not Working Correctly, Please Help
the following function is returning a single value when multiple items are selected. Can anybody see why? I'm using flash mx if that matters.
function Subscribe(){
var selectedItems = new Array();
selectedItems = Subscribe_lb.getSelectedItems() ;
for ( var i = 0 ; i < selectedItems.length ; i++ ){
formData.Subscribe = selectedItems[i].label;
}
}
thanks,
Howard
View Replies !
View Related
Mx SendForm Function Not Working...please Help
Hi all,
I have this registration form which is similar to others that work just fine. I cant seem to find any errors preventing the code to work, but its not working.
here is the link to the form online registration form
here is a link to the fla
I really need another pair of eyes on this one. thanks in advance
Howard
View Replies !
View Related
Moive Function Not Working
here is the functioon:
PHP Code:
var acceleration = 17;
var friction = 0.4;
function Move (targetX, targetY) {
var xdif = targetX-this._x;
var ydif = targetY-this._y;
this.xspeed += xdif/this._parent.acceleration;
this.yspeed += ydif/this._parent.acceleration;
this.xspeed *= this._parent.friction;
this.yspeed *= this._parent.friction;
this._x += this.xspeed;
this._y += this.yspeed;
this.checkDistance();
};
function checkDistance () {
if (Math.abs(targetX-this._x)<0.2 && Math.abs(targetY-this._y)<0.2) {
if (Math.abs(this.xspeed)<0.2 && Math.abs(this.yspeed)<0.2) {
this._x = this.targetX;
this._y = this.targetY;
delete this.onEnterFrame;
}
}
};
then when the movie reaches a certain frame, I call the move function with the following code:
PHP Code:
onEnterFrame = _root.intro.main.Cail_dmask.Move(-73.2, -80.7);
But my mask pops into place instead of moving graduaally then slowly oscillating till it comes to a halt.
What's wrong with my code?
thanks
View Replies !
View Related
Simple Function Not Working
I feel kind of silly asking this, but can anyone tell me whats wrong?
code:
function overButton (ClipName) {
trace("workingOver " +ClipName);
ClipName.submenu.surroundings.heading.colorTo("0x0 099FF",.2,"easeInOutSine");
ClipName.submenu.surroundings.heading.tween("_x",5 ,.2,"easeInOutSine");
ClipName.submenu.surroundings.back.alphaTo(100,.2, "easeInOutSine");
trace("workingover complete");
}
Say ClipName is "commercial" the trace comes out fine with commercial inserted. Even when i replace ClipName with "commercial" and hard code it in, the function works! but not with the parameter.
Can anyone tell me where im going wrong?
Cheers!
EDIT: Added [ as ] tags - jbum
View Replies !
View Related
On Rollover Function Not Working, Please Help
I have created a invisible button to control my MC, I am trying to get 2 actions to work when on (rollOut) whats the best procedure to do this because the code below is not working properly. thanks in advance
Code:
on (release) {
_root.click1.gotoAndStop(13);
}
on (rollOver) {
_root.click1.gotoAndPlay(2);
}
on (rollOut) {
if (_root.click1_currentframe == 13) {
gotoAndStop(13);
} else {
_root.click1.gotoAndPlay(7);
}
}
View Replies !
View Related
LoadMovie() Function Not Working
I am trying to make a new layout for my website. My website has flash movies I made. I want to make a flash menu, that plays my movies. I am currently using the code:
on(release){
_root.watch.loadMovie("http://www.myfilestash.com/userfiles/penguinflash/andyandjake.swf", "_root.watch")
}
and the movie is not loading... before, I used the code:
onClipEvent(enterFrame){
this.loadMovieNum("http://www.myfilestash.com/userfiles/penguinflash/andyandjake.swf", 0)
}
and with that, it loads my movie, but the frame I made disappears. So, neither of my codes work. Can someone please help me?
View Replies !
View Related
Why Isnt This Function Working?
Okay I got my enemy creator, and enemyAI function done, but when i test it out, it isnt working.. It will attach the enemies, but it wont assign them to their X and Y that i have assigned, and the enemy AI function wont work for them.. Can anyone help me? Here is my enemy AI function:
function enemyAI(enemy,num) {
for(b=0;b<num;++b) {
_root["enemyHealth"+b] = 100;
}
diff = Math.ceil(hero._x-enemy._x);
if (diff > -350 && diff < 370) {
if(!Stop) {
moving = true;
if (hero._x> enemy._x) {
enemy._xscale = -100;
enemy._x += enemySpeed;
enemy.gotoAndStop("enemyRun");
}
if (hero._x< enemy._x) {
enemy._xscale = 100;
enemy._x-= enemySpeed;
enemy.gotoAndStop("enemyRun");
}
}
}else {
enemy.gotoAndStop("enemyStand");
}
/////////////////////////////
if (enemy.hitTest(hero) && attacking == false) {
thisTime = getTimer()/1000;
if (thisTime>nextStab) {
Stop = true;
nextStab = thisTime+delay2
enemy.gotoAndStop("enemyStab");
hp -= 2;
}
}else {
Stop = false;
}
if(alive == true) {
if(enemy.hitTest(hero) && attacking == true) {
_root["enemyHealth"+b] -= str*level;
if(level <= 3) {
strExp++;
}else if(level >= 4 && level <= 7) {
strExp += 2;
}else if(level >= 9 && level <= 12) {
strExp += 4;
}
}
}
if(_root["enemyHealth"+b] <= 0) {
enemy._y = enemy._x = -100;
_root["enemyHealth"+b] = 0;
alive = false;
enemy._visible = false;
}
if(enemy.hitTest(hero._x,hero._y,true) && hero._x > enemy._x) {
hero._x += moveSpeed;
}else if(enemy.hitTest(hero._x,hero._y,true) && hero._x < enemy._x) {
_hero._x -= moveSpeed;
}
}
and here is my enemy creator function:
function createEnemies(guys, xArray, yArray){
for(a=1; a<=guys; ++a){
_root.attachMovie("enemy","enemy"+a,a+99)
_root["enemy"+a].x = xArray[a-1];
_root["enemy"+a].y = yArray[a-1];
_root["enemy"+a].onEnterFrame = function() {
enemyAi(_root["enemy"+a],guys);
trace(_root["enemy"+a]);
}
}
}
and here is how im trying to do it:
createEnemies(2,[100,300],[350,350]);
View Replies !
View Related
Call To Function Not Working?
Hi,
I have a function that changes the background colour of a text field:
Code:
function changeColour() {
_root.ticker_txt.backgroundColor = "0xFFCC00";
_root.ticker_txt.background = true;
_root.ticker_txt.border = true;
}
I call this function in another function that refreshes the screen every 5 seconds:
Code:
// delay function
function unpause() {
// get XML file each time
getXML();
// change colour of text field
changeColour();
trace("Colour Change: "+changeColour);
// clear existing delay interval
clearInterval(_global.my_interval);
}
The XML feed is parsed and the text put into the textField I want:
Code:
// parse XML
function loadXML(loaded) {
if (loaded) {
// trace XML data
trace("XML Data: "+xmlData);
// get ticker & volume
_root.ticker = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
// set text box values
_root.ticker_txt.text = _root.ticker;
} else {
trace("File not loaded!");
}
}
This unpause function is called in one last function that loads XML data into my textField:
Code:
// get XML function
function getXML() {
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("xmlfeed");
trace("Requested Feed: xmlfeed");
// request ever 5 seconds
_global.my_interval = setInterval(unpause, 2000);
}
I have a textfield on the stage with an instance name of ticker_txt. I don't see why this is not working?
If I move the changeColour(); call outside of the unpause(); function - it works perfectly!?
Any ideas - I am sure it is the way I am refrencing the textField - but everything is in the same moviclip/scene/frame - so _root should work surely?
I am utterly at a loss - tried lots of things - really need some advice.
Cheers,
Chris
View Replies !
View Related
Function To AttachMC Not Working
i can't figure out why this line of code isn't working, similar function in my fla (which dont attackMCs but change frame work fine) this is the is an essential part ofthe game im making and its been eluding me for days as to how to get this working.
function checkAttack() {
if (time == 54) {
clearInterval(checkAttack)
this.attachMovie("attack", "mcAttack", this.getNextHighestDepth())
}
}
attackInterval = setInterval(checkAttack, 100);
View Replies !
View Related
Function Assignment Not Working...
I am making a top-down shooter game in Flash 8 that is nonlinear (you can fly in any direction) and I am having a hard time getting the weapon system to work. here is my code:
Code:
shots = [];
weapon = "laser";
laserspeed = 20;
onMouseDown = function () {
addon = true;
for (i=0; i<shots._length; i++) {
if (!shots[i]) {
shots[i] = true;
this[weapon].duplicateMovieClip("shot"+i, 2+i);
this["shot"+i]._x = active._x;
this["shot"+i]._y = active._y;
this["shot"+i]._rotation = 90-dir*180/Math.PI;
this["shot"+i].shotmove(dir, eval(weapon+"speed"));
addon = false;
break;
}
}
if (addon) {
this[weapon].duplicateMovieClip("shot"+shots.length, 2+shots.length);
this["shot"+shots.length]._x = active._x;
this["shot"+shots.length]._y = active._y;
this["shot"+shots.length]._rotation = 90-dir*180/Math.PI;
this["shot"+shots.length].shotMove(dir, eval(weapon+"speed"), shots.length);
shots.push(true);
}
};
MovieClip.prototype.shotMove = function(direct, sspeed, place) {
ttlcounter = 125;
this["shot"+place].onEnterFrame = function () {
ttlcounter--;
if (ttlcounter == 0) {
this.removeMovieClip();
for (i=shots.length; i>0; i--) {
if (shots[i]) {
break;
} else {
shots.pop();
}
}
}
for (i=0; i<total.length; i++) {
if (total[i].hitTest(_x, _y, true)) {
this.removeMovieClip();
for (j=shots.length; j>0; j++) {
if (shots[j]) {
break;
} else {
shots.pop();
}
}
}
}
this["shot"+place]._x += Math.cos(direct)*sspeed-_global.xspeed;
this["shot"+place]._y -= Math.sin(direct)*sspeed-_global.yspeed;
};
};
i have all the weapon type as a string stuff so that i can add different weapons later. dir is the direction the ship is facing in radians. I have tried debugging this and what seems to happen is that the function shotMove gets assigned to the shot, but only for one frame. the laser MC just stays right there in the middle of the ship. this might seem like a newbie question, but what can i do to keep shotMove assigned to the shot?
View Replies !
View Related
Visible Function Not Working
I'm trying to use the script to make movie clips candle2 - candle10 visible. instead of write out, candle2._visible = true 9 times, i figured i could create a loop. i have other movie clips that i need to do the same with. but when i run this script, it's not making anything visible. i did a trace, and var_name does equal candle2-10, the loop is working, just not the visible function. i did write out the candle2._visible = true just to test, and it works perfectly.
i'm also having this same problem on another frame trying to make the movie clips invisible. the loop seems to be functioning, but for some reason it's not liking the variable._visible. Please advise!!
var i = 2;
while (i<=10) {
var_name = "candle"+i;
var_name._visible = true;
i++;
}
View Replies !
View Related
Nested Function Not Working
Hi, i'm trying to get my gallery scroller to activate on scrollwheel instead of just button click - to do this i've added the listener code and nested the scrolling function inside, however the nested function is not being called at all, is it due to incorrect syntax or something?
Individually the components work fine, i can get traces back on the mousewheel and the scroller does work on button click...Think i am joining the two together incorrectly.
Code:
var yPositions = new Array(0, -150, -300, -450, -600);
var mouseListener = new Object();
mouseListener.onMouseWheel = function(delta) {
// this is an array for storing the positions of the slider
function jumpTo(number) {
// this function takes the variable "number" that is passed from the buttons and takes the corresponding
// value from the array of positions, then sets the new position in the slider to the new position.
slider.newY = yPositions[number];
trace(slider.newY);
trace("test");
}
};
Mouse.addListener(mouseListener);
stop();
Thanks for any help!
View Replies !
View Related
Start Function Not Working?
hey im stuck on this problem for a sonund player and was wondering if anybody could help me out
i have the following code on my start/pause button:
Code:
onClipEvent (enterFrame) {
this.onRelease = function() {
if (_root.playy == true) {
_root.screen.light.mySound.stop();
_root.playy = false;
} else if (_root.playy == false) {
_root.screen.light.mySound.start();
_root.playy = true;
}
};
}
the song starts when it loads and it will stop when the button is pressed but it wont start again when the button is pressed the second time... does anybody know what might be wrong?
thanks in advance
-yeps
View Replies !
View Related
Trace Function Not Working
I am trying some very simple code and I can't get it to work. To debug, I tried using the trace function and that doesn't even work! I opened a new doc, I added it to an old doc, but nothing seems to work!
Code sample
var myNum:Number;
pic_btn.onRelease = function () {
gotoAndPlay(2);
myNum = 0;
trace(myNum);
}
contact_btn.onRelease = function () {
gotoAndPlay(2);
myNum = 1;
trace(myNum);
}
The gotoAndPlay works but the variable doesn't get set and the trace function does not fire. What am I missing. Please help if you can!
Thanks,
Roachmoe
View Replies !
View Related
[F8] Function Not Working Properly?
Hi Ive made a function which I call - but nothing seems to happen?
Its supposed to move a movieclip - but it just dissapears?
Heres the code:
function MoveMe() {
startCoordinate = 100;
Speed = 1;
for (var i:Number = 0; i < 400; i++) {
UpCoordinate = (-Speed) * i + 0.6 * i;
MyMC._y = startCoordinate + UpCoordinate;
}
}
I guess It'smoving too fast? for me to see - but how do i slow it down?
Cheers!
View Replies !
View Related
[F8] How To Stop Working Function For A While
Hi Guys
This is my first post here, so I am saying hellow to everybody
I have such problem: There is main.swf (I made it with some tutorial) and it loads another swf, then moves it according to mouse movement in horizontal direction. You can see it here
After clicking on any button popup appears. I want to stop the horizontal animation in bacground for time when popup is shown.
I have no idea how to do that, I'v tried many ways but no result.
Is better way to try to do that with onRelease function on buttons or maybe from popup when it is showing?
The code is a little bit complicated, so if any of you wants to look at source it is here.
Cod that controls movement is in classes/Mover.as file and as controlling buttons is in library/timeline_png_v3.fla file.
Maybe someone could help me, I would appreciate it.
Thanks in advance
View Replies !
View Related
|