Help This Has To Be Simple: How Do I Call A Function Inside A SmartClip?
I have not been able to figure out something that should be *very easy*... :-(
IN SHORT: When I call SmartClip functions from a button, it works fine (e.g. on release), but when I call the same SmartClip functions directly from ActionScript in another layer, it only works after a series of error messages. Why this difference?
LITTLE BIT MORE DETAIL:
When you have a SmartClip, and in the first frame of that clip you have the following actions:
Code: function start() { gotoAndPlay (2); }
function fadeout() { gotoAndPlay ("fadeout"); }
stop();
Then HOW can I call these start() and fadeout() functions from my main timeline? Here's what I tried:
I dragged an instance of this smartclip to Layer 1 of my main timeline. I named this instance "test". In Layer 2 of my main timeline I insert the following actionscript:
test.start();
And in a key frame several frames later in that same layer:
test.stop();
The result is that for several seconds nothing happens, then a series of error messages show up:
Target not found: Target="anim107" Base="_level0.test" Target not found: Target="anim108" Base="_level0.test" Target not found: Target="anim109" Base="_level0.test" Target not found: Target="anim110" Base="_level0.test"
Funnily enough, after a long series of errors like above, the SmartClip animates correctly.
There must be something very basic here that I am just not understanding. I can find plenty of info on SmartClips on the Internet and how to use them, but I can not find information on calling functions that are embedded in those SmartClips.
Any help is really appreciated...
Thanks in advance!
- Erik [Edited by vanderneut on 09-21-2002 at 02:47 PM]
FlashKit > Flash Help > Flash ActionScript
Posted on: 09-21-2002, 03:28 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Inside XmlOnload Function Can Not Call Other Function Directly
I have a question, why the test function can not be called ?
Thanks.
Code:
class testClass {
public function testClass() {
var XMLData:XML = new XML();
XMLData.load("coonfig.xml");
XMLData.onLoad = this.xmlOnLoad;
}
public function xmlOnLoad(success:Boolean) {
if (success) {
// this.test();
test();
}
}
public function test () {
trace("test success");
}
}
As3 Call A Function Inside Swf
I am loading an external swf like that. In the extrnal swf I have a function called "foo". how can I call "foo" function from the main swf?
Thanks
How To Call A Function Inside A Class?
Hello, i am trying to fire a function onPress .. this function is inside a class.
In this function i refer to another function inside the calss to call a Tween. It never arrives in the second function.
I tried to make an example.
In the fla file i have:
var test:makeMovie = new makeMovie(this);
You will see a red squere and you can press on it. It should run the tween class. Am i using the delegate class wrong?
Attach Code
import mx.transitions.Tween;
import mx.transitions.easing.*;
import mx.utils.Delegate;
class makeMovie extends MovieClip {
private var parentMc:MovieClip;
private var Container:MovieClip;
function makeMovie(parentMc:MovieClip) {
this.parentMc = parentMc;
makeSquare();
}
private function makeSquare() {
var Container:MovieClip = parentMc.createEmptyMovieClip("container_MC", parentMc.getNextHighestDepth());
Container.beginFill(0xFF0000);
Container.moveTo(0,0);
Container.lineTo(200,0);
Container.lineTo(200,200);
Container.lineTo(0,200);
Container.lineTo(0,0);
Container.endFill();
Container.onPress = setAlpha;
}
private function setAlpha() {
trace("init this?");
Delegate.create(this,setTween);
}
private function setTween() {
trace("tween");
var alphaTween:Tween = new Tween(Container, "_alpha", Strong.easeOut, 0, 100, 2, true);
}
}
Call A Function Inside A Movieclip...
Hello. How can I call a function when I want inside a movie clip? Can't find any one that suits among onClipEvent() since they go off automaticly from some defined actions... I need to call the function at certain times!
This code is inside a movieclip and I want to be able to change temp when I want to!
Code:
onClipEvent(load){
var temp;
}
How can I accomplish that?
regards
/henrik
Call Function Inside A Class
Hello.
I've got some problems trying to call a function inside a mc in a class.
For example:
Code:
class Foo {
private my_mc:MovieClip;
private my_mc2:MovieClip;
public function Foo(mc:MovieClip, mc2:MovieClip) {
my_mc = mc; // call the class, passing as parameter a movie clip
my_mc2 = mc2;
applyAS();
}
public function applyAS():Void {
getMC2Height(); // Here the trace output prints the my_mc2._height
my_mc.onEnterFrame = function():Void {
getMC2Height(); // Here, doesnt =/
}
}
public function getMC2Height():Void {
trace(my_mc2._height);
}
}
I didnt have such experience on AS2 OOP, but this is make me real crazy... Any suggestions about the class are welcome too.
Call A Function Inside A Movieclip...
Hello. How can I call a function when I want inside a movie clip? Can't find any one that suits among onClipEvent() since they go off automaticly from some defined actions... I need to call the function at certain times!
This code is inside a movieclip and I want to be able to change temp when I want to!
Code:
onClipEvent(load){
var temp;
}
How can I accomplish that?
regards
/henrik
Can I Call Functions From Inside SetInterval Function?
Hi there.
I have the following code that is meant to create 54 boxes on the screen, one after the other. My code doesn't seem to get to the creation of the boxes (where the trace command is.) I have tested the interval and it seems to be working ok.
Here's the code:
Code:
Movieclip.prototype.drawSquare = function(xpos,ypos,sidelgth,fillcolour){
trace("here");
xcord = xpos;
ycord = ypos;
sl = sidelgth;
fc = fillcolour;
this.lineStyle(1,0,100);
this.beginFill(fc,100);
this.moveTo(xcord,ycord);
this.lineTo(xcord+sl,ycord);
this.lineTo(xcord+sl,ycord+sl);
this.lineTo(xcord,ycord+sl);
this.lineTo(xcord,ycord);
this.endFill;
};
i=1;
x=100;
y=100;
squareInterval = setInterval(function(){
sinvalue = Math.random();
colour = (Math.sin(sinvalue) * 10000)/2;
_root.createEmptyMovieClip("mc"+i);
_root["mc"+i].drawSquare(0,0,50,colour);
_root["mc"+i]._x = x;
_root["mc"+i]._y = y;
x+=70;
i++;
if(x==520){
y+=70;
x=100;
};
if(i==54){
clearInterval(squareInterval);
};
},100);
Thanks for your help,
Graeme
How Do I Call A Function From Inside A Child Movieclip?
hi,
i have a function on the root timeline, and i have a movieclip on the timeline. i want to call a function that is on the root timeline (so the movieclips parent). the function is called nextImage.
i have tried:
parent.nextImage();
root.nextImage();
and
var p:MovieClip = parent as MovieClip;
p.nextImage();
why don't these work, and why is it so hard in AS3.0 to do things to the root and parent timelines? i miss being able to just type parent.parent.gotoAndStop(2);
Anyway, any help would be great.
Thanks
Ben
Call A Function From Inside Another Function?
Hey Guys,
Having a bit of a problem here
Just say this was the case on the main timeline
ActionScript Code:
function topFunction(){
trace("you just called the topFunction")
}
function testFunction(){
function nestedFunction(){
topFunction();
}
}
How the hell do i run the topFunction from inside nestedFunction();. In AS2 if i wanted to reference it i would type _root.topFunction(); but now I don't know how to get to it.
I just need to know how to reference variables and functions from anywhere in my actionscript if i'm in another scope or in another MC.
Thanks guys
Call A Function Inside A Function
I have a function that attaches a movie clip and names it movieClip_1. I now need the to call the same function again to create movieClip_2 when you click movieClip_1.
[CS3] Call Function Inside Flash From External Movie
Hi,
I wanted to know whether its possible or not.
The thing that I have is:
1. An SWF movie in my website (can not be edited)
2. An EXE movie in the computer
The thing that I want is:
1. When the options in EXE file are chosen, it would call a function of the SWF Movie in the website, ** provided that the webpage containing the SWF is open in a browser.
That would be really helpful for me if you can provide me any info.
Thanks
Shiblee
How To Call A Function On Main Stage From Inside A Symbol Instance
Hi everyone,
I have a silly AS3 question for you.. though I've looked and can't find the answer.. maybe it's too obvious!!
How do I call a global function which I defined in my main stage from inside an instance of a symbol, which sits on the main stage?
ie the function in the main stage:
function doSomething(x:String):void
{
trace ("woohoo");
}
and inside the symbol:
function callDoSomething(:xString):void
{
doSomething(x);
}
Do I have to... create a default document class.. or a custom one perhaps? do I have to put this.parent or this.stage in front of doSomething(x)??? I dunno...
Thanks a lot!
Simple Function Call?
Hi guys,
have a very simple problem....i can't call functions????!!!. can tell em what am i doing wrong here??? isn't working....puzzled!
code on main time line
*******************
namevar = "0";
area = 0;
_root.one.name();
_root.one.Circle(10);
trace ("name="+namevar);
trace ("area="+area);
********************
code on the timeline of mc one, instance name is also one
*********************
function name () {
_root.namevar = "mayavi";
}
function Circle (radius) {
this.radius = radius;
this.area = Math.PI*radius*radius;
_root.area = this.area;
}
************************
works fine when function has been defined inside the maintimeline??? is my function reference wrong? what??
cheers
mayavi
Simple Function Call
Think I'm going nuts, but I'm just trying to run a function in a nested movie. I even tested something really simple, and it doesnt seem to work.
-On my root timeline is a MC instance named newMovie.
-In newMovie here is the function.
function thisIsMine() {
trace("doing");
}
on the root timeline, I have this script:
newMovie.thisIsMine();
Its not running the function. I've also tried calling it with an absolute target, _root.newMovie.thisIsMine();
and it didn't seem to work.
Should Be VERY Simple Function Call
I am new to AS3 and I know this is probably obvious but...
I want to call a function I defined on the main timeline from inside a movie clip instance.
here is my function:
function imAFunction():void
{
trace("I am a function wheeeee!");
}
inside the timeline of a movie clip I have tried to call it in all sorts of ways
root.imAFunction();
this.stage.imAFunction();
this.parent.imAFunction();
etc etc
but I keep getting this error:
1061: Call to a possibly undefined method imAFunction through a reference with static type flash.displayisplayObject.
Simple Function Call
I am new to AS3 and I know this is probably obvious but...
I want to call a function I defined on the main timeline from inside a movie clip instance.
here is my function:
function imAFunction():void
{
trace("I am a function wheeeee!");
}
inside the timeline of a movie clip I have tried to call it in all sorts of ways
root.imAFunction();
this.stage.imAFunction();
this.parent.imAFunction();
etc etc
but I keep getting this error:
1061: Call to a possibly undefined method imAFunction through a reference with static type flash.displayObject.
Buttons Inside Clip Instances Shoudl Call Proper Function
hi,
i've been looking for this for a while:
I have a button inside a movieclip, multiple instances of that clip on the stage. When the button is pressed, i want it to call a function that is assigned to that instance only.
How can i do that ?(without duplicating the clip in the library
thanks a lot
Buttons Inside Clip Instances Shoudl Call Proper Function
hi,
i've been looking for this for a while:
I have a button inside a movieclip, multiple instances of that clip on the stage. When the button is pressed, i want it to call a function that is assigned to that instance only.
How can i do that ?(without duplicating the clip in the library
thanks a lot
Simple Call Function With MouseDown
Wow my AS is rusty...
basically I have an MC menu that I want to move to the left when you click and hold on another MC called leftButton, here's what I have.
In main timeline:
Code:
menu.moveLeft = function() {
this._x -= 4;
}
triggerMotion = function() {
this.onEnterFrame = this.moveLeft;
}
Then in the leftButton MC:
Code:
onClipEvent (mouseDown) {
triggerMotion;
}
This obviously doesnt work, but I know its close, could someone help slap me back into writing AS
Thanks
Simple Function Call Problem
I feel kind of silly asking this, but can anyone tell me whats wrong?
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" (no quotation marks) and hard code it in, the function works! but not with the parameter.
this is my code when I call the function:
on (rollOver){
_root.overButton(commercial);
}
Can anyone tell me where im going wrong?
Cheers!
Simple Call Function With MouseDown
Wow my AS is rusty...
basically I have an MC menu that I want to move to the left when you click and hold on another MC called leftButton, here's what I have.
In main timeline:
Code:
menu.moveLeft = function() {
this._x -= 4;
}
triggerMotion = function() {
this.onEnterFrame = this.moveLeft;
}
Then in the leftButton MC:
Code:
onClipEvent (mouseDown) {
triggerMotion;
}
This obviously doesnt work, but I know its close, could someone help slap me back into writing AS
Thanks
Simple Function Call Problem
I feel kind of silly asking this, but can anyone tell me whats wrong?
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" (no quotation marks) and hard code it in, the function works! but not with the parameter.
this is my code when I call the function:
on (rollOver){
_root.overButton(commercial);
}
Can anyone tell me where im going wrong?
Cheers!
Listener VS Simple Object.function Call
I know that listeners allow multiple Class to listen to one object. In the other way if there is only one object that must listen or react when an event is triggered, we can simply use the object reference and by that reference calling the function. For example if we have 2 Classes A & B.
First Option : Class A is the object that dispatch an event when a transition is completed. CLass B can listen all events from Class A and the execute a function when the Class A transition is done.
Second Option : Class A has a reference of Class B. When Class A transition is completed, Class A use the Class B reference to execute a function in the Class B.
The 2 options does the same thing. The only diffrence is that in the first option, many objects can react to the end of the Class A transition.
What I'd like to know, is what is the best way. I mean, If I only have one Object that listen to the Class A Events. Is that a better way to use object reference? Does the Listener are slower to execute instead of a function call from a reference? Does...
Listeners take more code to execute, must be removed when the Class is removed. May be I there is more to know then that.
Any opinion or suggestion?
Dropdown Smartclip To Auto Activate Function
Hello,
Is there a way to immediately activate a function upon selecting an entry from the Macromedia menu smart clip?
I would like the selected value to immediately cause changes to other information without subsequently having to click a button.
Can't Call Function Created Via Eval Using ExternalInterface.call
I have created a flash movie that acts as an MP3 player. Using ExternalInterface, I pass an array containing cue points in the song to the flash move so that it makes a callback to javascript when it hits certain points in the song. Since I want to deal with these callbacks differently for each song, I have made it so that I can dyanmically change the function that is called from Flash (to Javascript). Here is the code for that piece:
ExternalInterface.addCallback("setCuePointFunction ToCall", this, setCuePointFunctionToCall);
var cuePointFunctionToCall:String='';
var intCurrentCuePoint:Number=0;
function setCuePointFunctionToCall(strFunctionName){
_root.cuePointFunctionToCall=strFunctionName;
}
function reportToJavascript_CuePoint(intCuePointID:Number){
ExternalInterface.call(_root.cuePointFunctionToCal l, intCuePointID);
_root.intCurrentCuePoint++;
}
This works perfectly as long as the function that cuePointFunctionToCall refers to is defined in a script block on the HTML page. However, this project is an AJAX-style thing, and I need to be able to define the function that is triggered on a cue point in code that is dynamically executed at run-time via an "eval' call.
Here's the code that talks to actionscript. This appears in a script block on the main page (not via eval).
function setCuePointFunctionToCall(strFunctionName) {
thisMovie("PushPuppets_Media_Center").setCuePointF unctionToCall(strFunctionName);
//alert(strURL);
}
function thisMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
Here's the code that is dyamically being executed via an eval statement in javascript:
setCuePointFunctionToCall("cuePointNew");
function cuePointNew(lngCuePointID) {
alert('New function, cue point: ' + lngCuePointID);
}
This does not work. But if I copy the above function block to the main page (not in the code that is executed via an eval) it does work. I am certain that setCuePointFunctionToCall is being executed properly via the eval - it is definitely changing the function that actionscript will call. This is apparent since it is calling the right function when the function is declared on the HTML page (not in the AJAX-style eval call). So I'm guessing that this has something to do with the scope in which eval operates.
I encountered a very similar problem when I tried redefining a function in the eval call that was already defined on the main page. It just didn't take.
Please let me know if you have any suggestions.
Thanks,
Erich
Call A Function In A Duplicated Movie Clip Form Another Function : (
i have a movie clip on my root name "pl".
on command, it duplicates with instance name as "y0","y1", etc.
here is the method :
function callPL(transmit,receive,addy,level) {
var newName = "y"+_root.x;
duplicateMovieClip("_root.pl",newName,101);
_root[newName]._x = 400;
_root[newName]._y = 400;
_root.[newName].start(transmit,receive,addy,level); //look here
}
there i attempt to call a function of the newly duplicated clip call "start()".
Start() function is written on the first frame of the movieclip like this :
function start(a,b,address,level) {
a.sendAndLoad(address,b,"Post");
this.path = b;
b.onLoad=function(success) {
gotoAndPlay("start");
}
}
however it seems like the function callPL() could not invoke function start() of the new movieClip.I have no idea how is it so.
Even when i trigger it with a onLoad handler it still doesnt work
pls shed some light.
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
Filling Function Arguments With Array Items, Function.call()
HI!
I have this code but I cannot work out how to fill in function parameters based on an array and it's length, see line 7
ActionScript Code:
import com.robertpenner.easing.Cubic;MovieClip.prototype.framesTimeout = function(func:Function, frames:Number, args:Array) { var t:Number = 0; var mc:MovieClip = this.createEmptyMovieClip(String(new Date().getTime()), this.getNextHighestDepth()); mc.onEnterFrame = function() { if (t == frames) { func.call(this._parent,args); delete this.onEnterFrame; this.removeMovieClip(); } else { t++; } };};MovieClip.prototype.movex = function(x:Number, frames:Number) { trace(x+" "+frames) delete this.movex.onEnterFrame; this.movex.removeMovieClip(); if (!frames) { frames = 20; } var t:Number = 0; var sx:Number = this._x; var ax:Number = x-this._x; var mc:MovieClip = this.createEmptyMovieClip("movex", this.getNextHighestDepth()); mc.onEnterFrame = function() { if (t == frames) { delete this.onEnterFrame; this.removeMovieClip(); } else { t++; this._parent._x = Cubic.easeOut(t, sx, ax, frames); } };};MovieClip.prototype.otherfunction = function(param1, param2, param3, param4){ trace(param1+" "+param2+" "+param3+" "+param4)}mc.framesTimeout(movex, 50, [100, 50]) mc.framesTimeout(otherfunction, 200, ["asd", 1, 2, 55])
Is it possible to call a function and fill in the parameters based on an array and it's lenth?
My Function Isn't Functioning/Actionscript To Call A Function Flash MX 2004
Hello,
Well in theory I know how to create a function but for some reason I am unable to call it.
Can someone take a look at it and tell me what went wrong. Basically when I go to "a certain page" I want to click on a button and have it go to another page known as "pics" it then will load a jpeg there known as jpeg loader. Now I know it works properly without a functin, but because I am lazy I do not want to write more code than I have to, there are like 300 differnt jpegs I have to load. Thus I need to create a function.
here is my AS
ActionScript Code:
//this is on frame one of my root timeline
//I am trying to call the function "display" on release of my button
omnihotelButton.onRelease = display ("J010 Omni Hotel.jpg");
//this is my function that I set up it is also on my root, but on a different frame
//this function is named display and it goes to the "pics" page and stops
where it then loads a jpeg which is et up as my variable.
//the xscale and the yscale are just setting up my size of the jpeg.
function display(jpeg){
_root.gotoAndStop("pics");
jpegLoad_mc.loadMovie(jpeg);
jpegLoad_mc._xscale=90;
jpegLoad_mc._yscale=90;
}
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.
Cannot Call Button Function Within Another Event Function
Hopefully someone can help me out with this one. I'm importing XML in order to draw images into an animated scrollbar, and would like to nest a button function within the function urlLoaded as listed below:
import caurina.transitions.*;
var urlCall:URLRequest = new URLRequest("pics/hotel_dreams/hotel_dreams.xml");
var urlLoader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList;
urlLoader.load(urlCall);
urlLoader.addEventListener(Event.COMPLETE,urlLoade d);
var arrayThumb:Array = new Array();
var photoContainer:Sprite = new Sprite();
addChild(photoContainer);
photoContainer.mask=thumb_holder;
function urlLoaded(event:Event):void {
xml = XML(event.target.data);
xmlList = xml.children();
trace(xmlList.length())
for (var i:int=0; i<xmlList.length(); i++) {
var thumb:Thumbnail = new Thumbnail(xmlList[i].url);
arrayThumb.push(thumb);
arrayThumb[i].y = 67.5;
arrayThumb[i].x = xml.children().x_position[i];
photoContainer.addChild(thumb);
arrayThumb[i].gallery = xml.children().gallery[i];
trace(arrayThumb[i].gallery);
}
}
my hope is to create a button that looks something similar to the following in order to execute an if then statement within the function controlling the visibility of images from the XML based on their gallery property value.
btn_gallery_2.addEventListener(MouseEvent.CLICK, open_gallery_2);
function open_gallery_2(event:MouseEvent) {
if (arrayThumb[i].gallery == 2) {
arrayThumb[i].visible = true
}
}
I have been trying to nest within the urlLoaded function to no avail. By running trace statements I can see that [i] is inaccessible when nested within another function within urlLoaded and when completely outside of the urlLoaded function.
The Thumbnail class referenced is in an .as file that looks like this:
package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
public class Thumbnail extends Sprite {
private var url:String;
private var loader:Loader;
private var urlRequest:URLRequest;
public var gallery:Number
function Thumbnail(source:String):void {
gallery = 0
url=source;
drawLoader();
}
{
private function drawLoader():void {
urlRequest=new URLRequest(url);
loader=new Loader ;
loader.mouseEnabled=false;
loader.load(urlRequest);
loader.x=-0;
loader.y=-68
;
addChild(loader);
}}}}
I have the suspicion that I am missing something very basic. If anyone out there might be able to give me some insight, then I would be appreciative.
thanks very much
SetInterval Inside A Loop Inside A Function - Am I Crazy?
I've got a menu loading from XML data - however I'd like the mc's to appear sequentially, maybe 1/10th second apart. I know setInterval should do this, but I'm still new to flash and despite trawling Google for 24 hrs solid, nothing seems to show me the right way.
Here's the script:
Code:
function CreatePortMenu(port_xml)
{
var portClients = port_xml.firstChild.childNodes;
var xPos = 0;
var yPos = 0;
var xSpacing:Number = 90;
var ySpacing:Number = 35;
var i = 0;
for ( i = 0; i < portClients.length; i++ )
{
switch (i) //splits the menu items into columns of 4 (max 12 items)
{
case 0:
case 1:
case 2:
case 3:
yPos = ySpacing * i;
break;
case 4:
case 5:
case 6:
case 7:
xPos = xSpacing * 2;
yPos = ySpacing * (i - 4);
break;
case 8:
case 9:
case 10:
case 11:
xPos = xSpacing * 3;
yPos = ySpacing * (i - 8);
}
var currentClient = portClients[i];
var portHold = portHolder_mc.attachMovie( "jobOption", "pb"+i, i, {_x:xPos, _y:yPos});
portHold.jobTitle.jobText.text = currentClient.attributes.title;
}
}
So I *think* I should be inserting two lines, one creating a setInterval, and one clearing it, but where? Some guides say inside the function, some say outside, some say only the clearInterval should be inside, some have the function inside the loop... I also *think* I've tried every possible combination, but no soap. Please help!?
How 2 Call GetURL From Inside Of A MC
Hello,
I am making a story that on everyline you roll over it gets bigger and and there is a yellow background I got that so far and on the story there are certain words that are in blue which when the user clicks on them it should get them to a certain page but I can't get this to work, what im saying is that to call a url only works when you press a MC that is on the main frame but when the MC is inside another MC it won't do nothing, I'll make it a little bit more clear
this is a MC (MC1)
++++++++
++++++++
++++++++
if I put on the MC above :
on(press){
getURL("http://www.kirupa.com");
}
This will work
---------------
but if I make another MC inside MC1 and put the same script in the new MC it will not work how do I make it work?
+++++++++
======== +
= scritpt = +
======== +
+++++++++
Thanks,
I hope you like my visual aid
How 2 Call GetURL From Inside Of A MC
Hello,
I am making a story that on everyline you roll over it gets bigger and and there is a yellow background I got that so far and on the story there are certain words that are in blue which when the user clicks on them it should get them to a certain page but I can't get this to work, what im saying is that to call a url only works when you press a MC that is on the main frame but when the MC is inside another MC it won't do nothing, I'll make it a little bit more clear
this is a MC (MC1)
++++++++
++++++++
++++++++
if I put on the MC above :
on(press){
getURL("http://www.kirupa.com");
}
This will work
---------------
but if I make another MC inside MC1 and put the same script in the new MC it will not work how do I make it work?
+++++++++
======== +
= scritpt = +
======== +
+++++++++
Thanks,
I hope you like my visual aid
Using SetInterval Inside A Function, Inside A Loop
I'm very confused by this now
I'm trying to use setInterval to delay what happens on a rollOut function, which is added to every button inside a loop.
Can anyone help me with the syntax, I'm totally lost!
Thanks,
James
PHP Code:
for (var i = 0; i<=(node.length); i++) {
currentButton.num = i-1;
//----attach the projectButton movieclip from the library----//
attachMovie("projectButton", "projectButton"+i, i);
//----move the button to the right place----//
currentButton = _parent.portfolio["projectButton"+i];
currentButton._y = 1+(26*k);
currentButton._x = 2+(230*j);
//----put the name of the project onto the button----//
currentButton.projectID.text += node[i].attributes.title;
//----rollover function----//
currentButton.onRollOver = function() {
currentButtonNow = _parent.portfolio["projectButton"+this.num];
currentButtonNow.projectID.text = "";
currentButtonNow.projectID.text += node[this.num].attributes.description;
};
//----rollout function----//
currentButton.onRollOut = function() {
APause = setInterval(GoBack2, 500);
//calls a function called GoBack every 'x' seconds//
function GoBack2() {
// SOME FUNCTION HERE!!!!!!!!
clearInterval(APause);
trace('clearing interval of '+currentButton.num);
}
currentButtonNow = _parent.portfolio["projectButton"+this.num];
currentButtonNow.projectID.text = "";
currentButtonNow.projectID.text += node[this.num].attributes.title;
};
//----release function----//
currentButton.onRelease = function() {
loadMe = node[this.num].attributes.id;
gotoAndPlay(10);
//gotoAndStop("portfolio");
};
//---- take out the leftover one idiot ----///
if (currentButton.projectID.text == "undefined") {
_parent.portfolio["projectButton"+i].removeMovieClip();
}
//---- watch the old variables mr greig ----//
k++;
//---- slit the list into 2 columns at which point? ----///
if (i == (8)) {
j = 1;
k = 0;
}
[F8] How Do You Call A Function In A Function In A Class?
I have this class..
class Bob {
function Bob(){
initiate code
}
function loadImages(){
Load images code...
image.onEnterFrame = function(){
if loaded {
this.nextFunction();
}
}
}
function nextFunction(){
do this
}
}
basically, i have a function that loads images.. and i need to have it automatically do another function in that class once the images are loaded..
how do i wait til they're loaded in the class? cause if i put it in "onEnterFrame" , 'this' no longer refers to the class, it refers to the onEnterFrame..
so how do i refer back to the class?
or how do i determine if the images are loaded all in the one class?
Call Function From A Function In A Class?
i havee..
class testClass
{
function testClass()
{
giveFunctions(mc1);
}
function traceIt(tag)
{
trace(tag);
}
function giveFunctions(mc:MovieClip)
{
mc.onRollOver = function()
{
traceIt("SUP");
}
}
}
How do i make the giveFunctions function access the class?
cause it defines a rollover function for an MC.. but in that rollover function, it has to re-reference a different function in the class..
how does that work?
there'll be more variables and it'll be more complex..
I had like,
function giveFunction(mc:MovieClip,tag)
{
mc.sett = this.traceIt;
mc.mca = mc;
mc.tag = tag;
mc.onRollOver = function()
{
this.sett(this.mca,this.tag);
}
}
that works, but it like.. pulls the traceIt function out of the class so it couldn't reference any other variables if it needed to
String With Function Name To Call Function?
hi guys,
it so happened that I have to call some function from XML. What is the best way to do this??
say i have a class "ABC.as" with a function "def()" can I do this:
Code:
var abc:ABC = new ABC();
var strg:String = "def()";
//then i call the function...
abc.strg;
is this going to work?? else is there any solution can let me do something similiar?
thanks!
[AS]Call A Function After Another Function Ends
Hi,
I have a question: How i make (if it's possible to do this) to call a function after another function is finished. I have 4 function:
ActionScript Code:
function tween1 () {//some tweens}function tween2 () {//some tweens}function tween3 () {//some tweens}function tween4 () {//some tweens}
And i want to play first tween1 and then tween2, when tween2 ends then play tween3 and so on!
It's this possible?
Thanks, btibia.
Pass Function Name To Function And Call
bit stuck on this.
any help much appreciated!
ActionScript Code:
func_1(mc10, 'func_2',[id1, add]);
function func_1(tofade, oncompletecall, var){
//fade out 'tofade'
//then call oncompletecall(func_2) function..
how do i form the call to func_2?
}
function fun_2(id1, add){
do something...
}
How To Call Flash Inside Html
I have a flash inside html file in some folder. I want to call another flash that is located in other folder from my flash.
how to do it?
thanks
Rami
Can I Call Html Inside Flash...etc?
http://www.louisdilello.com/staging/riggedproductions/
Im trying to make a site similar to this one. I want to have a flash shell with the navigation on the top and bottom, but the inside call html pages that can be scrolled inside of it. In the version on that site, its all html. I though of even doing seperate pages with just a flash navigation on the bottom of each, but i dont know how ot make the html scrollable in that case. Let me know.
Also if there are good sites that have navigation bars like this or templates, point me in the right direction!
Email: ram29@drexel.edu
Can I Call Html Inside Flash?
http://www.louisdilello.com/staging/riggedproductions/
Im trying to make a site similar to this one. I want to have a flash shell with the navigation on the top and bottom, but the inside call html pages that can be scrolled inside of it. In the version on that site, its all html. I though of even doing seperate pages with just a flash navigation on the bottom of each, but i dont know how ot make the html scrollable in that case. Let me know.
Also if there are good sites that have navigation bars like this or templates, point me in the right direction!
Email: ram29@drexel.edu
Please Help On How To Use Variables Inside A Method Call
Hello guys,
How's it goin?
Pardon me if you find my question silly, but I am relatively new in ActionScript 2.0 programming.
I have here a simple problem. It seems I can't use a variable inside a method call of an object. Here's the code:
import AkamaiConnection;
import mx.services.WebService;
var GeneratedToken:String;
var authParams:String;
// Create a Web Service object
var TokGenService:WebService = new WebService("http://webservice.asmx?wsdl");
// Call the web service method
var myToken:Object = TokGenService.GenerateToken();
// Create an AkamaiConnection object
var connection:AkamaiConnection = new AkamaiConnection();
connection.addEventListener("onConnect", this);
connection.addEventListener("onError", this);
// If you get a result from the web service, save the result in a variable
myToken.onResult = function(result)
{
// If you get a result from the web service, save the result in a variable
myToken.onResult = function(result)
{
GeneratedToken = result;
authParams = GeneratedToken + "&aifp=v001&slist=37414/test/Streaming/";
//Call the Connect method of the AkamaiConnection class
connection.connect("cp37414.edgefcs.net/ondemand",true,true,5,true,false,"443","rtmpt",authParams);
};
But then, if I use a hard-coded string value in lieu of the variable, the method call works!
connection.connect("cp37414.edgefcs.net/ondemand",true,true,5,true,false,"443","rtmpt","testStringvalue");
I don't know what I'm missing or what I'm doing wrong... Can somebody help me please? I am using a 30-day trial version of Adobe Flash CS3. Also, when I Trace output the variables, the values are there. It just that they can't be read or recognize inside the method call. Is this a ActionScript limitation?
Thanks so much in advance!
Call Method Inside Event
Hello, I've a quick question. I want to call a method of a class when an event occurs which is built from inside the class. Here's an example:
PHP Code:
class myClass{
function myClass(){
var thisMC:MovieClip = _root.createEmptyMovieClip(...);
thisMC.onRelease = function(){
//THIS IS WHERE I WANT TO CALL THE METHOD 'otherMethod'
this.otherMethod();
// 'this' now refers to 'thisMC' and not 'myClass'
// how can I target 'myClass' like this?
}
}
private function otherMethod(){
// ...
}
}
Any help appreciated. Thanks!
Please Help On How To Use Variables Inside A Method Call
Hello guys,
How's it goin?
Pardon me if you find my question silly, but I am relatively new in ActionScript 2.0 programming.
I have here a simple problem. It seems I can't use a variable inside a method call of an object. Here's the code. Please note of the authParams string variable below.
import AkamaiConnection;
import mx.services.WebService;
var GeneratedToken:String;
var authParams:String;
// Create a Web Service object
var TokGenService:WebService = new WebService("
|