OOP In Flash: Calling A Function W/in A Function Class?
Okay so I am reading through sens tutorial on OOP and updating my game that I am making. It is much easier to code this way (IMO) but still hitting snags. I am trying to get through this code:
ActionScript Code: House = function(){ this.floors = 4; this.siding = "Red"; this.outputSiding = function(){ trace(this.siding); }; }; // create an instance of the House class myHouse = new House(); myHouse.outputSiding(); // traces "Red"
Now as it seems to me, I have nearly the same thing (I will condense this to save space):
ActionScript Code: //set new character function()character = function (depth, x, y, charType, name, HP, MP) { //sets stats used; this works fine :) //attachMovie and set x/y _root.attachMovie(this.name+"_mc", this.name+"MC", this.depth, {_x:this.x,_y:this.y}); /*this is where I am having trouble; it won't do anything!I have tried tracing to no availalso, can I set the x and y coords somehow with thealready made object x and y? I am tired right now andcan't think of a way but what I have done, which doesnothing as this function won't go!*/ statsBox = function(depth) { this.depth = depth; trace(this.depth+newline+'hello'); this.x = enemy._x+130; this.y = enemy._y-50; _root.attachMovie("stats_mc", statsNameMC, this.depth, {_x:this.x,_y:this.y}); };};enemy = new character(30, 350, 200, 'enemy', 'genericName', _root.EHP, _root.EMP);enemy.statsBox(50);
that's it, pretty much. So what's wrong? Maybe I'm too tired for this right now... thanks.
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 05-12-2004, 06:56 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
OOP In Flash: Calling A Function W/in A Function Class?
Okay so I am reading through sens tutorial on OOP and updating my game that I am making. It is much easier to code this way (IMO) but still hitting snags.
I am trying to get through this code:
ActionScript Code:
House = function(){ this.floors = 4; this.siding = "Red"; this.outputSiding = function(){ trace(this.siding); }; }; // create an instance of the House class myHouse = new House(); myHouse.outputSiding(); // traces "Red"
Now as it seems to me, I have nearly the same thing (I will condense this to save space):
ActionScript Code:
//set new character function()character = function (depth, x, y, charType, name, HP, MP) { //sets stats used; this works fine :) //attachMovie and set x/y _root.attachMovie(this.name+"_mc", this.name+"MC", this.depth, {_x:this.x,_y:this.y}); /*this is where I am having trouble; it won't do anything!I have tried tracing to no availalso, can I set the x and y coords somehow with thealready made object x and y? I am tired right now andcan't think of a way but what I have done, which doesnothing as this function won't go!*/ statsBox = function(depth) { this.depth = depth; trace(this.depth+newline+'hello'); this.x = enemy._x+130; this.y = enemy._y-50; _root.attachMovie("stats_mc", statsNameMC, this.depth, {_x:this.x,_y:this.y}); };};enemy = new character(30, 350, 200, 'enemy', 'genericName', _root.EHP, _root.EMP);enemy.statsBox(50);
that's it, pretty much. So what's wrong? Maybe I'm too tired for this right now...
thanks.
Calling A Function, External To The Calling Class
hello to everyone, who looks at this post
So there's a class, that needs to call/access an external function.
'External' (imho) in this case would be any function, declared outside of the class.
How is it possible to:
1) call a function declared in the main timeline.
2) call a function in another class (i suppose, the only way of doing it is by importing the class having this function into the calling class?)
Calling A Function In A Class
Hi guys,
I currently have this class:
A lot of it has been removed since they are not relevant:
Code:
class ProcessRss {
//declare public properties
public var targetClip:MovieClip;
public var textTarget:TextField;
//constructor
function ProcessRss (_mc:MovieClip, _ta:TextField, _proxy) {
targetClip = _mc;
textTarget = _ta;
proxyPath = _proxy;
_xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad = Delegate.create(this, processFeed);
}
public function timer():Void {
myInterval = setInterval(this, "ticker", delay);
}
public function stoptimer():Void{
clearInterval(myInterval);
}
}
On my timeline:
Code:
//bring in the parsing class
import ProcessRss;
//create instance of the parsing class
var pcnews:ProcessRss = new ProcessRss(holder.reader, holder.reader.reader, "rss.php");
Now, let's say i have a button on my stage called setScroll.
How do I make it call timer() (which is in the class) when it is pressed?
thanks!
Calling A Function Within A Class
Hi I have created a basic class that says hello when the runs but I want to know how to call the sayGoodBye() function with a mouse click on a button or movieclip.
Thanks,
package {
import flash.display.*;
import flash.events.*;
import fl.transitions.*;
import flash.display.MovieClip;
public class Greetings extends MovieClip
{
public function Greetings()
{
trace('hello');
}
public function sayGoodBye()
{
trace('see ya');
}
Calling A Function On The Timeline From A Class
Here is my problem, i have a class and function on the timeline, which I want to call from within the class on certain event but the function is not being executed. what am I doing wrong- this is what I have on my timeline:
Code
var myXML:xmlLoader=new xmlLoader("managment.xml");
myXML.dothisFunction=function(){
trace("hello");
}
this is my xmlLoader class definition:
Code:
class xmlLoader {
public var xmlFeed:XML;
private var doFunction:Function;
public function xmlLoader(xmlUrl:String) {
xmlFeed = new XML();
xmlFeed.ignoreWhite = true;
xmlFeed.onLoad =init;
xmlFeed.load(xmlUrl);
}
public function set dothisFunction(callBack:Function):Void{
doFunction=callBack;
};
private function init(success:Boolean) {
if (success) {
doFunction;
} else {
trace("oops");
}
}
}
As3, Calling A Function On Stage From A Class?
Hi guys could one of you tell me how I can call a function on the stage from within a class? I am getting "Error #1007: Instantiation attempted on a non-constructor" by trying to do it. This is a dirty as2 to as3 conversion so the path of least resistance would be best. If anyone could help it would be great
Calling A Function Within A Class From Root
On my main timeline, I have a movie Clip called mp3Player that has a class mp3player.
The mp3player class has all of the functions controlling the buttons, playback, etc.
The site also contains a flv player. If someone clicks to load the flv player, I need to stop playback of the mp3 player.
Is it possible to call functions within the class from the main timeline? Or to trigger a mouse event on the stop button?
I've tried calling the instance but I can't figure out how to access anything within that movie clip.
I've tried root.mp3Player.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
... but I get a Error 1010: A Term Is Undefined or Has No Properties.
Anyone know how to accomplish this?
Thanks!
Calling A Function In Parent Class?
Simple question:
I have class that controls a container MC (Tree). Inside this class I add new profiles.
var profile:Profile = new Profile();
The profile can be dragged around and repositioned in the container grid. When the profile is released I want to notify the parent where is was dropped.
If make this call from the profile class: parent.positionNode(lev,pos);
I get an error: 1061: Call to a possibly undefined method positionNode through a reference with static type flash.displayisplayObjectContainer.
If it possible to call a parent like this or is there some other way?
Calling A Timeline Function From A Class
I am finally migrating to AS3 and having some issues doing some of the fundamental things I used to do with AS2. I figure what I want to do here should be simple enough, but I've been searching everywhere for an answer and have not found one.
I've created a class for buttons so they all have the same properties and rollovers. I have a global function on my main timeline that will set up all the animations I want to transition to a new page in my website, once the button is clicked.
I just want to call this function once the CLICK event is dispatched from within my as file.
Something like this (pulled from my ButtonClass.as file):
ActionScript Code:
this.addEventListener(MouseEvent.CLICK,goPage); // from constructor function
public function goPage(event:MouseEvent):void {
root.goTransition() // this function resides on my main timeline
}
Any help is greatly appreciated.
Calling Constructor Function Within Same Class
Dear users,
I have a document class name elevator and my constructor is also elevator as usual
How to call this constructor function within elevator class? Is is possible or not?
Please guide me on this.
Calling A Function From Method In Class
Is this possible, I create an instance of an object - This is on my main.fla
ActionScript Code:
var newClass:MovieClip = new myClass;
newClass.myFunction();
function myMainFunction () {
trace("works");
}
now lets say this is the class file called myClass.as
ActionScript Code:
public class myClass extends MovieClip {
public function myFunction () {
myMainFunction(); //this is where I want it to run on the function on main timeline
}
}
any ideas? I've tried putting parent. before it etc - just to note this isnt my actual code I'm working on but a simplified version of it.
cheers
Problem Calling Function Of A Class
I have done this type of thing a million times before, but I cannot for the life of me figure out why it isn't working this time. As of now I have three classes: Main, UI, and Bear.
Main creates an instance of UI and puts it on the stage. UI has, among other stuff, 7 instances of the Bear class sitting on the stage. The Bear class has a public function:
Code:
public function setType(type:Number):Void
{
trace("here");
_type = type;
switch(_type)
{
case Main.NORMAL:
bear.gotoAndStop(NORMAL);
break;
case Main.BLOCKER:
bear.gotoAndStop(BLOCKER_IDLE)
break;
case Main.BOMBER:
bear.gotoAndStop(BOMBER_WALK);
break;
case Main.BOXER:
bear.gotoAndStop(BOXER_IDLE);
break;
case Main.FOIL:
bear.gotoAndStop(FOIL_WALK);
break;
case Main.GENIUS:
bear.gotoAndStop(GENIUS_WALK);
break;
case Main.JACKHAMMER:
bear.gotoAndStop(JACKHAMMER_IDLE);
break;
case Main.PARACHUTE:
bear.gotoAndStop(PARACHUTE_WALK);
break;
}
}
in an init() function of UI, I call setType on all 7 of the Bear instances so that the MovieClips associated with it will go to a frame and stop there. I get NO errors when I compile, but the setType function is never being called. I know that the class itself is being instantiated though because I can trace out from the constructor of Bear and that traces fine.
HELP... if you can please! haha
Thanks,
Kyle
Calling Class-function Issue
I have a really strange problem accessing a memberfunction of a class I made.
Essentially, when I create a class-instance just using regular code:
ActionScript Code:
var myClassInstance:myClass = new myClass ();
..I can access memberfunctions without any problem.
But (and here is where it goes crazy), when I write a function that will create this class-instance, and calls it to create an instance, it is impossible for me to access the member-functions.
ActionScript Code:
CreateInstance();
function CreateInstance(){
var myClassInstance:myClass = new myClass ();
}
I mean, it just seems insane that there would be any diffrerence wether I create an instance using a function or not.
Here is the fla-file. In the .as-file there are the two alternatives for creating the instance at load. The button then tries to use the member-function of the class to move the class-instance (which is a movieclip) horisontally.
http://www.kirupaforum.com/forums/at...achmentid=2465
Class's Movieclip Calling A Function In It's Own Class
For the life of me I can't find an internet source that explains why this doesn't work. I know it's a scope problem but I know no other way around it and there must be a way to do it, I'm thinking.
I have a class. Inside this class I create a movieclip which I have a class variable link to. The movieclip is created on _root. When I click on this movieclip, I want it to call a function inside the class. Here's what it looks like.
Code:
class Whatever extends Movieclip {
private var mc:MovieClip;
public function Whatever() {
this.mc = _root.createEmptyMovieClip("rootmc",_root.getNextHighestDepth());
[code for drawing a square]
this.mc.onPress = this.doSomething();
}
public function doSomething {
[do something]
}
In the above sample, when I click on the movieclip, the "doSomething" function is not called, obviously because the movieclip is on root and has nothing to do with the class. Is there a way to do what I want to do?
Calling A Static Class Function From The Timeline
Hi there!
I have a (small?) problem when calling a static function in a class from the timeline:
In AS2 I used to do it like this (this code is in frame 1 of the _root timeline):
ActionScript Code:
import com.mypackage.Application;
// call to a static function main() in Application
com.mypackage.Application.main();
how do I do this in AS3, I always get this compiler error:
1202: Access of undefined property Application in package com.mypackage.
thanks for your help!!
Calling A Function In The Root File From Another Class
I've got a root file with let's say the public function MyFunction():void... then in a different file, let's say secondClass.as class, I need to call that function. I have tried everything I can think of to call it and I can't seem to do it. This seems like such a dumb question! Thanks for the help.
Calling Actionslistener Function On The Stage From A Class
I have a sound class that calls an actionlistener when the sound has finished playing (Event.SOUND_COMPLETE), but I can't seem to figure out how to make the sound complete event call a function on the stage.
I've searched around and the usual solution is to addChild() with the class first or else the stage is null, but I can't use addChild() in sound classes. What I've been doing instead is calling a function in the class adding the property isDone=true, then looping on the stage every frame until it sees it's true. There's gotta be a more efficient way. Please help
channel=this.play(...);
channel.addEventListener(Event.SOUND_COMPLETE, stage.someStageFunction)
Calling A Function With A Argument In The ContextMenuItem Class, How?
hi,
im tryng to call a function with a argument in the ContextMenuItem class.
code:
ActionScript Code:
function down(id){ txt.text = id; //trace(id);};var my_cm = new ContextMenu();menuItem_cmi = Array();for (i=1;i<6;i++){ menuItem_cmi[i] = new ContextMenuItem("product: "+i, down(i)); my_cm.customItems.push(menuItem_cmi[i]);}my_cm.hideBuiltInItems();cart.menu = my_cm;
It seems that when ever I try to send an argument with the down function, it simpley dont work and without it, it does work
Calling Parent Class Function Problem
Hello, I have 2 Classes
main.as
and
gallery.as
in main.as i'm creating new object for example:
gl:Object = new gal(); // gallery.as class
in gallery class i have fadeOut function that fades out img, i want to make something like event onFadeOut to call from main as .
i want to know when img fadeout is done in main.as.
sorry for my english
[FMX04] Calling Function On Movieclip From Class Method
Is it possible to call a function defined in a movie clip from a class?
Here's a sample project setup I'm trying to achieve this simple feat:
func.fla
- Has one movieclip "fooinst" which is library item "foo".
- The "foo" library item has linkage is to the "Foo" class
- The "foo" library item has one script on it's first frame:
ActionScript Code:
function bar() { trace("bar() called"); }
- The "Foo" class only has this:
ActionScript Code:
class Foo extends MovieClip{ public function Foo() { trace("Foo() constructed."); var mc : MovieClip = this; mc.bar(); }}
When run, bar() is never called. (I believe it's undefined.)
How do I call bar() from inside the class?
ActionScript Class Problem Calling A Function From A Method
I'm relatively new to the wonderful world of ActionScript 2.0 OOP. I'm hoping this problem is an easy one to solve, though I cannot seem to find the answer anywhere.
It would seem that you cannot call a method from a function contained within another method. For instance, the following would be contained in a class that displays and manipulates images:
Code:
private function fadeIn (target:MovieClip):Void {
var a:Number = 0;
var incr:Number = Math.round(100/fadeDur); // fadeDur is a static var set earlier in the class
container_mc.onEnterFrame = function() { // container_mc is the movie clip containing the image that we're fading
// fade the movie clip in
this._alpha = a;
a += incr;
if(a>=100) {
pauseMC(); // this is the offending critter
delete this.onEnterFrame; // stop the fade
}
}
}
public function pauseMC ():Void {
trace("waiting...");
var dur:Number = getDuration(); // a function that returns num of milliseconds
var b:Number = 0;
function endWait(myIntervalId) {
trace("ending wait. Attempting to unpause");
unpauseMC(myIntervalId); // another instance of a method that doesn't get called
}
// unpause the mc after the random duration period
var myIntervalID = setInterval(endWait, dur);
}
So in the example above, the two method calls, pauseMC and unpauseMC, never fire off. Any non-method calls such as 'delete this.onEnterFrame' fire off just fine. And if I move the method calls out of the sub-functions, they work just fine. It's only when the method call is contained within the subfunction that it does not work. For the life of me, I can't figure out why.
Can anyone provide some insight?
Many thanks,
Steve
Calling Constructor In Condition: A Function Call On A Non-function Was Attempted.
Hi guys,
Please help me somebody with this cos I have really no idea. I have made a simply condition calling a constructor of a class. Today I had to add an "else if", what caused the compilator to show me "A function call on a non-function was attempted."...
ActionScript Code:
function loadIt() { if (var1 == "1") { var a:SomeClass = new SomeClass(true); } else if(var2 == "1"){ var a:SomeClass = new SomeClass(false); //<- if this is not here, everything works fine } else { var b:SomeOtherClass = new SomeOtherClass(); b.init(); }}
Any ideas? Thanks for any help!
Poco
Function Calling From The _root But Call A Function Within A Instance
I have created a new instance 'Check_1' to work as a checkbox with a set of propertys and functions.
All ive done is created the functions in a script in the first frame of the instance-movie these are...
Simple......
================================================== =======
selected = -1;
function select_frame (FrameNum) {
gotoAndPlay (FrameNum);
}
function change_select () {
select_frame(2);
trace (selected);
}
function change_unselect () {
select_frame(1);
selected = -1;
}
================================================== =======
now from the _root i wish to call the above functions to change the instance propertys, it all works fine from within the instance but i also need to use the functions for that instance from the _root...
iv'e tried the follow with no joy...
_level0.Check_1.change_select()
Any light would be greatly appreciated.
[F8] Calling A Function Froma Function
Please excuse my ignorance, but can i call a function from a different function. I'm not sure how to do it.
eg:
myBut.onPress = function ()
{
_root.currentimage=1;
_root.crumb.titles="/fashion&lifestyle";
_root.loadLeft._visible=0;
FashStrip.mc01._alpha = 60;
}
how do i integrate this into the above function?:
function fadeOut()
{
extendTween = new TweenExtended(_root.loadLeft.fashThumb,["_alpha"],
easingType4,[_root.loadLeft.fashThumb._alpha],[0],1,true);
}
i know i could put it straight in the button function but i want to reuse the fadeOut function again many times!!! (just learning to keep my code nice and neat)
Rat
Calling Function From Within A Nested Function
Hi guys,
I current have this piece of code:
Code:
var parentObj:Object = this;
this.form.submit.onRelease = function() {
parentObj.processingIn();
}
function processingAnimationIn():Void{
//DO STUFF
}
But I can't get this to work. Does anyone know what's going on?
Thanks!
Calling A Function Inside Another Function
Hi All,
I've set up two functions (friendsClick and policyLink) I would like to use everything inside of friendsClick inside of policyLink but I'm not sure how to go about doing it. I get the following error:
1136: Incorrect number of arguments. Expected 1.
My code looks similar to:
Code:
function policyLink(e:MouseEvent){
friendsClick();
"all my other info here"
}
I can just copy everything from the friendsClick function and paste, but I'm trying to limit my amount of repetitive code (I'm trying to get better at that). Please Help.
Calling A Function Inside Another Function
Hi i've created some functions that run when diffrenent buttons are pressed, and they work fine, but i want something else to do the same thing when any of the buttons are pressed, i thought the easiest way to do it was to create a function and call it each time one of the buttons are pressed. but what is the code to run the function??
all the code is on the main timeline..
i've wrote this and it doesn't work....
the function i want to run is:
brentGandS = function (){
_root.menu_mc.brent_mc.tween("_width",200,5,"easeoutelastic")
}
and the on press function is:
menu_mc.contact_btn.onPress = function() {
window_mc.resizeTo(250, 350, speed, "easeoutelastic", onEnda);
brentGandS
};
any ideas????????
Help On Calling A Flash Function From PHP
Hi,
I am working on an application that interacts with the Flash file and makes certain actions possible. The flash file has been tested and is stable, and I cannot access the flash source. I have access to only SWF
I want to call the actionscript functions from the javascript/php code and make certain actions like dropdown value change possible.
I tried to look into different sites, but could not find any possible solution. I am new to php and flash. I am a testing person, who is switching to development now.
Any small help will be really helpful.
Thanks
Anvitha
(Flash 8) Calling A Function
How do you call a function on the main timeline from a an onRealease in a nested mc? Does that make sense?
I have created a function that resides on the main timline, and when a button is released I want to call it, but the button is nested in a movie clip.
Calling PHP Function From Flash
Hi Guys! I've got a query here. Is it possible to call a php function from flash ? I have a php code that contains a function that accepts two parameters, username and password, the value of these variables are sent to php through flash. Now php accepts these values and returns true or false if the depending upon the value of the two parameters.
Flash has to fetch the output of the php function for further processing. I am stuck on this part, can anyone help me out ?
Calling A VB Function From Flash?
Does anybody know how to (if possible) communicate between flash to Visual Basic?
E.g If we have a Flash movie(object) embeded on a VB form, is it possible to open a new VB form directly from flash?
Or is it possible to send variables from flash to VB?
Please if anybody knows give me a tip.
Thanks
.NET Calling A Flash Function
I've got a .NET application sitting within the windows OS and a Flash .exe running off the OS, as well (not in a webpage). One of the features we're doing is to notify Flash from .NET that XML is ready on the OS to be ingested. Can someone suggest a best approach to allow Flash to pull the XML data (when told to pull it). Ideally, I would not like to have Flash initiate the call to absorb data. I would like .NET to provide a function call to kick flash into action, or perhaps through a web service.
I believe this can be done through a web service and Flash's "Web Service Connector". Is this true? Can I set up .NET to send Flash a command to ingest XML?
Flash 5: Calling Function
I've placed a movieclip named 'plate' 50 times at the same level and same frame in my timeline. This movieclip holds six instances (pl1, pl2, pl3, pr1, pr2 and pr3) of a movieclip called 'pole'. Now I want to be able to seperately set which (or a combination) of the six should be visible in each of the 50 movieclips.
To do this I created the following function:
ActionScript Code:
function poles (a, b, c, d, e, f) {
if (a == 1) {
pl1._visible = true;
} else {
pl1._visible = false;
}
if (b == 1) {
pl2._visible = true;
} else {
pl2._visible = false;
}
if (c == 1) {
pl3._visible = true;
} else {
pl3._visible = false;
}
if (d == 1) {
pr1._visible = true;
} else {
pr1._visible = false;
}
if (e == 1) {
pr2._visible = true;
} else {
pr2._visible = false;
}
if (f == 1) {
pr3._visible = true;
} else {
pr3._visible = false;
}
}
The problem is that I'm not able to call this function if it is placed in the main timeline from the timeline of my movieclip 'plate'.
I already tried to place the following in the timeline of 'plate', but it didn't work:
ActionScript Code:
_root.poles(1, 2, 2, 2, 1, 1);
It failed to set the visibility of the 6 movieclips contained in the movieclip plate.
Now I could create 50 different movieclips of plate with each containing this function in it's timeline, but that would take a lot of work and increase the file size a lot. Does anybody know a solution?
Calling Flash-Function From JavaScript
Hello!
In the tutorial:
http://www.flashkit.com/tutorials/In...77/index.shtml
there is just this line used:
window.document.FlashTest.SetVariable("jtext", text);
to set a flash-variable out of JavaScript.
What I want to do is call a Flash-Function out of JavaScript. How is this possible?
IE Crashes On Calling A Js Function From Flash
I have an html file that has three frames(three rows). In the middle frame i have window
that has two frame(column). Left frame has a tree structured TOC. TOC has eight modules and
each module has few Topics. On Clicking each topic a swf file should get loaded on the right
frame(of the middle row). This course is autorun. once it is started(one swf is loaded by
clicking on any of the topic) all the swf files will come one after other. We have two
navigation buttons (next and back as well) in bottom frame which should also help in
navigatingh forth and back ward between the shockwave.
We have created a layer in right frame and creating swf object using innerHTML property of
this layer.
We are using two function next and back for navigation. These functions change the values of
some variables and then call the function openShockwave. This openShockwave function open a
swf file depending on the value of these variable. all of these functions are in bottom
frame.
For next and back navigation we are using these function onClick of next and back button.
There these functions are working well. But if we are calling the same functions from the
swf files for autorun purpose out Internet Explorer window crashes down. I am using the
following code on the last frame of swf file:
stop();
getURL("javascript:nav.next()", "_top");
Sometimes if it dose not crashes, it calles the function twice.
Is there any solution.
Calling Javascript Function In Flash Mx
I'm trying to call a (Javascript 1.2) function shake(n) when my flash mx movie reaches a certain key frame. The flash movie is embedded into a html document. I've tried using the getURL command but cannot get this to work, what is the deal!!!!!!!
Calling Flash Function From Html
How can I call a function within my flash movie from the html. I tried to use asfunction but for some reason it hasn't worked for me.
Thanks.
Calling JS Function From Flash Works In IE Not FF
Hi,
I have the following JavaScript function at the top of my HTML page:
Code:
<script type="text/javascript">
<!--
function setLogo() {
logoimg.src = "img/logo.gif";
}
//-->
</script>
And call it from my Flash movie like this:
Code:
getURL("JavaScript:setLogo();");
This works in IE - the image with the name logoimg changes to the desired image. But in Firefox nothing happens. The JavaScript console says "logoimg not defined".
Any ideas?
Thanks!
/Flip
FLA8: Calling A JS Function From Flash
Hi. I am using this to place my flash elements:
http://blog.deconcept.com/swfobject/
> to avoid the click to activate issue.
But when using it - I cannot seam to call JS functions from within flash using:
getURL('javascript:fromFlash()');
Anyone else noticed this?
M@)
Flash 8 - Function Calling Problem
I'm having some problems with calling functions to some movieclips from onEnterFrame. Here's a portion of the code to illustrate my problem(the actually code has been manipulated):
Code:
onEnterFrame {
//skipped a few lines
for (i=0; i<4; i++) {
mySquares = this["square" + i];
if (!dragging) {
mySquares.throw();
mySquares.checkBounds()
}
}
function throw() {
//for example
this._x += 3;
this._y += 2;
}
function checkBounds() {
}
I've also tried saying something like "throw(mySquares)," but this gave me some weird effect. This might be due to the code contained within the throw function but I've checked everything and it seems like it should work. Anyone have any suggestions please? (I can also post the file if needed)
thanks
Calling A Function From Flash To Javascript
Is there something wrong with this code? It is calling a Javascript function in the html. Its funny because I have another FLA that that is exactly the same code word for word and it works and this one does not!
Code:
on(press)
{
getURL("javascript:testing()");
}
Calling Flash Function With Javascript
I have a button that calls a Javascript function and passes a parameter to the function.
ActionScript Code:
on (rollOver) {
getURL("javascript:self.cswmShow(12)");
}
Here's the Javascript function.
Code:
<script language=javascript>
<!--
function cswmShow(mod){
self.movie.SetVariable("mod", mod);
}
-->
</script>
So what I'm doing here is simply grabbing the parameter and passing it back into Flash using SetVariable.
Back in Flash I have an onEnterFrame method that grabs the variable and sends myMovie to frame 2.
ActionScript Code:
this.onEnterFrame = function(){
if (mod == 12){
myMovie.gotoAndStop(2);
}
}
Here's my problem. I don't want to use an onEnterFrame to constantly check if the condition is met. Instead I'd like to simply call the Flash function from Javascript and pass the parameters to the Flash function. Although it isn't exactly calling the function directly I found a solution using watch.
ActionScript Code:
function myCallback(){
if (mod == 12){
myMovie.gotoAndStop(2);
}
}
this.watch("mod", myCallback);
The function is called properly but the value of mod is lost. I know the function is called because if I take out the conditional statement, myMovie is sent to frame when the button is rolled over.
I have swLiveConnect set to true and all of the parameters correct. I don't think I'm properly using watch.
I have MX 2004 too so if there's a solution with the newer version feel free to post that and I'll ask a moderator to move the thread. Thanks!
Calling Javascript Function From Flash IE Help
Hey everyone,
I have a javascript function:
Code:
function startLytebox(thumb, caption, image) {
I want to call it from flash. I have been calling it like this:
Code:
getURL("javascript:startLytebox(""+lightBoxImg+"", "blank", ""+lightBoxImg+"");");
That works fine in FF, Safari, and IE7. but in IE6 all the variables for the function parameters get dropped. Is there a better way to call Javascript functions from flash maybe FScommand or something? Or some Hack for IE6 thanks in advance.
FLA8: Calling A JS Function From Flash
Hi. When I use SWF Object to embedd flash in the page
http://blog.deconcept.com/swfobject/
It seams that I can no-longer call JS function from inside flash using:
getURL('javascript:fromFlashS2F()');
Is there another way?
M@)
Calling Flash Function From Javascript
I can't seem to get this to work.
I have an SWF. In that SWF there is an empty movieclip that has an onEnterFrame with a function that I specified: myFunction.
Now I want to call this function from a new window that I opened. So here is what I did:
==
window.opener.mySwf.myMC.myFunction();
==
that didnt work
So I put the function on the root:
==
window.opener.mySwf.myFunction();
==
That didn't work either.
Can't someone please enlighten me on how to get this to work?
thanks guys
G.
|