Copy link to clipboard
Copied
Hello !
I have a document with main class.
I also have some movieclips which have their own class and functions.
I am trying to pass a variable from my main class to one of these MovieClips.
I tried some stuff, nothing worked.
Who can help ?
Match_Easy looks like a class name. you need to use the instance name.
Copy link to clipboard
Copied
are the moveiclips instantiated in your document class? if so, they have access to main class variables.
if the movieclips are added in the ide, they'll have to reference the root cast as a movieclip: MovieClip(root).mainVar (if the code is on the main timeline)
Copy link to clipboard
Copied
I wasn't being very clear.
My problem exactly is that, I want to run a function of my MovieClip from my MainClass.
myMovieClip.DoYourFunction(withMyClassVariable)
and in the MovieClip's class :
public function DoYourFunction(WhatVariable:String) {
}
Again sorry for not being clear.
How can I do this scenario?
Copy link to clipboard
Copied
how/where is myMovieClip instantiated?
Copy link to clipboard
Copied
It is put on stage on one frame.
Copy link to clipboard
Copied
if that movieclip method is public, you can use:
MovieClip(root).yourmovieclipinstancename.DoYourFunction(somestring);
Copy link to clipboard
Copied
It gives me :
Property Match_Easy not found on ControlUnit and there is no default value.
ControlUnit is my main Class.
Match Easy is the movieClip which is on frame 4 of my timeline and it has it's AS Linkage as Match_Easy.
If I put an instane name for it I get this error:
Type was not found or was not a compile-time constant: Match_Easy.
What can I do. I'm frustrated.
Copy link to clipboard
Copied
you probably have more than 1 error. respond to each of the following:
1. are you checking if the main timeline is on frame 4 so your movieclip exists?
2. is your method public?
3. show the code you're using to reference that method.
Copy link to clipboard
Copied
Alright ...everything seems fine to me.
Here's the code in my Main Class :
public function BonusClicked(e:MouseEvent) {
trace(currentFrame);
MovieClip(root).Match_Easy.Hint(myBonus);
}
And the code in Match_Easy :
public function Hint(WhatKind:String) {
if (WhatKind == 'Time') {//Bonus ne kohe ...Hiqen disa sekonda.
gameTime += TimeBonus;
} else if (WhatKind == 'Score') {//Bonus ne pike ...Shtohen disa pike.
gameScore += pointsForMatch;
} else {//Bonus qe shfaq te gjithe letrat dhe me pas i kthen sic ishin.
HintTimer = new Timer(250,2);
HintTimer.addEventListener(TimerEvent.TIMER_COMPLETE, hideCards);//Hiqe kete me nje lloj menyre !?
for (var i:uint = 0; i < BunchOfCards.length; i++) {
BunchOfCards.startFlip(BunchOfCards.cardface + 2);
}
function hideCards(e:MouseEvent):void {
for (var i:uint = 0; i < BunchOfCards.length; i++) {
BunchOfCards.startFlip(1);
}
}
HintTimer.start();
}
}
Methods are public, frame is 4 so movieclip exists.
Copy link to clipboard
Copied
Match_Easy looks like a class name. you need to use the instance name.
Copy link to clipboard
Copied
Sorry but it seems I did something foolish before.
I put the instance name same as the class name. :S
Sorry and thank you.
Copy link to clipboard
Copied
you're welcome.