Reputation: 3828
My code works but its not getting the VAR in the last function. What am I missing?
Main Class Code
package {
import flash.display.MovieClip;
import flash.events.*;
import com.Bubble;
public class numberPop extends MovieClip
{
public var numberBubble:Bubble;
public function numberPop()
{
addBubble(3);
}
public function addBubble(num:Number)
{
var i:Number = num;
numberBubble = new Bubble(i);
addChild(numberBubble);
}
}
}
Second Class Code: Bubbles.as
package com {
import flash.display.MovieClip;
import flash.events.*;
public class Bubble extends MovieClip
{
public var num:Number;
public function Bubble(num:Number)
{
super();
num = num;
trace("Number is: " + num); /// WORKS !!!!!
this.addEventListener(MouseEvent.CLICK, bubbleAction);
}
public function bubbleAction(e:Event)
{
trace(num); // DOES NOT WORK BUT SHOULD.
}
}
}
Upvotes: 0
Views: 33
Reputation: 1153
Your argument in constructor is overriding class property. Change:
num = num;
to
this.num = num;
Upvotes: 1