I don’t really know how to explain well here.
Basically I have 3 as files. Let’s call it A, B & C
A is the menu files
B is the files that gets the data from A, and tell C and others what to do
C is the data
After I’ve been trying around the scripts for a very long time,
i only manage to realise that if I did not use addChild at the main layers of files,
the object will not be shown in the stage.
for example,
ActionScript Code:
[LEFT][COLOR=#0000ff]private[/COLOR] [COLOR=#0000ff]static[/COLOR] [COLOR=#000000]var[/COLOR] zoomer:theZoom = [COLOR=#000000]new[/COLOR] theZoomCOLOR=#000000[/COLOR];
[COLOR=#0000ff]public[/COLOR] [COLOR=#0000ff]static[/COLOR] [COLOR=#000000]function[/COLOR] somethingCOLOR=#000000[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]
zoomer.[COLOR=#000080]zoomOut[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
I’m using direct calling instead of addChild B to A, because B doesn’t really have any object in it.
it just a function that communicates between A & C.
now after C get the data of A from B, even i use addChild in it, the object doesnt add on to the stage. any idea how i can solve this through files C?
C’s AS
package classes{
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
import flash.geom.*;
public class theData extends MovieClip {
private var dataMC:MovieClip = new MovieClip();
private var req:URLRequest=new URLRequest("datas/data.xml");
private var loader:URLLoader = new URLLoader();
private var loadData:XML;
private static var dataText:TextField = new TextField();
private var dataTextFormat:TextFormat=new TextFormat("Century Gothic",13,0x000000);
private static var square:Shape=new Shape();
public function theData():void {
//addEventListener(Event.ADDED_TO_STAGE, add2Stage);
}
public function runData():void {
addEventListener(Event.RESIZE,stageResize);
dispatchEvent(new Event(Event.RESIZE));
loader.addEventListener(Event.COMPLETE,dataLoaded);
loader.load(req);
addChild(dataMC);
}
private function stageResize(event:Event):void {
trace("resize");
}
private function dataLoaded(event:Event):void {
var menu:theMenu = new theMenu();
loadData=new XML(loader.data);
switch (menu.currentPage) {
case "Who We Are" :
dataText.text=loadData.whoweare.info;
break;
case "What We Do" :
dataText.text=loadData.whatwedo.info;
break;
case "Careers" :
dataText.text="4444444444444444444";
break;
case "Contact Us" :
//menuTitleTop.text=menuTitleTopArray[3];
break;
}
trace(dataText.text);
dataText.defaultTextFormat=dataTextFormat;
dataTextFormat.align=TextFormatAlign.JUSTIFY;
dataText.autoSize=TextFieldAutoSize.LEFT;
dataText.wordWrap=true;
dataText.selectable=false;
dataText.width=660;
dataText.x=0;
dataText.y=0;
dataBox();
dataMC.addChild(dataText);
}
private function dataBox():void {
square.graphics.clear();
// Glowing Background
var type:String=GradientType.LINEAR;
var colors:Array=[0xFFFFFF,0xFFFFFF];
var alphas:Array=[0.7,1];
var ratios:Array=[0,255];
var spreadMethod:String=SpreadMethod.PAD;
var interp:String=InterpolationMethod.LINEAR_RGB;
var focalPtRatio:Number=0;
var matrix:Matrix=new Matrix ;
var boxWidth:Number=dataText.width+20;
var boxHeight:Number=dataText.height+20;
var boxX:Number=dataText.x-10;
var boxY:Number=dataText.y-10;
//var boxHeight:Number=500;
var boxRotation:Number=Math.PI/2;// 90¡ã
var tx:Number=0;
var ty:Number=0;
matrix.createGradientBox(boxWidth,boxHeight,boxRotation,tx,ty);
square.graphics.beginGradientFill(type,colors,alphas,ratios,matrix,spreadMethod,interp,focalPtRatio);
square.graphics.drawRect(boxX,boxY,boxWidth,boxHeight);
dataMC.addChild(square);
}
public function removeData():void {
//removeChild(dataMC);
}
}
}