PDA

View Full Version : import problem and SWFContainer problem


platteau
09-14-2009, 08:41 AM
Hi,

I use Flex Builder 3.

First problem :
I'm trying to import the same .as file in 3 or more mxml files. But for some reason flex doesn't recognize the content of the file when included in more than 2 files.
So, this gives me errors in the compilation (objects/functions are not recognized).

Second problem :
I have a main MXML file with a SWFContainer in which I load an SWF (also based on a MXML).
Now i want to load another SWF based on an action from the first loaded SWF. the problem is that the first loaded SWF doesn't recognize the SWFContainer in the code, so I can't reach to it.

Is there a way to solve these problems?

- Joepie

Peter Cowling
09-14-2009, 09:30 AM
I would post code, because the issue seems to be miscoding.

platteau
09-14-2009, 11:14 AM
Problem 1 :
3 files : temp.mxml, temp2.mxml and alg.as :
temp.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="alg.as" />
<mx:Button x="420" y="202" label="Shout" click="shout('testing')"/>
<mx:TextArea x="420" y="232" id="ta1"/>
</mx:Application>

temp2.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="alg.as" />
<mx:Button label="Button" click="shout('temp2')"/>
</mx:Application>

and alg.as :
public function shout1(text:String):void {
Alert.show(text);
ta1.text = "oktje";
}
public function shout2(text:String):void {
Alert.show(text);
}

The function shout1 is being called from the page in which a field ta1 exists.
It doesn't exist in the second MXML, so here's the problem.
-----

Problem 2 :
5 files : 3 .mxml files and 2 .as files
When I type the code in swfLoading2.as, i get an error that SWFContainer has not been defined.

test1.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="swfLoading1.as" />
<mx:SWFLoader id="SWFContainer" />
<mx:Button x="347" y="327" label="import flash" click="setSWF1()"/>
</mx:Application>

swfLoading1.as :
private function setSWF1():void {
SWFContainer.load("test2.swf");
}

test2.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="swfLoading2.as" />
<mx:Label x="10" y="10" text="Test2"/>
<mx:Button x="10" y="36" label="import flash" click="setSWF2()"/>
</mx:Application>

swfLoading2.as :
private function setSWF2():void {
SWFContainer.load("test3.swf");
}

test3.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Label x="407" y="326" text="Test 3 : YEY"/>
</mx:Application>

Peter Cowling
09-14-2009, 08:35 PM
Problem 1 :
3 files : temp.mxml, temp2.mxml and alg.as :
temp.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="alg.as" />
<mx:Button x="420" y="202" label="Shout" click="shout('testing')"/>
<mx:TextArea x="420" y="232" id="ta1"/>
</mx:Application>

temp2.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="alg.as" />
<mx:Button label="Button" click="shout('temp2')"/>
</mx:Application>

and alg.as :
public function shout1(text:String):void {
Alert.show(text);
ta1.text = "oktje";
}
public function shout2(text:String):void {
Alert.show(text);
}

The function shout1 is being called from the page in which a field ta1 exists.
It doesn't exist in the second MXML, so here's the problem.
-----


shout1 is not called in the application that also contains ta1. shout() is being called.

If that is just a typo, its not clear that the class alg is actually present in the application. Is this something that you know how to do etc.



test1.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="swfLoading1.as" />
<mx:SWFLoader id="SWFContainer" />
<mx:Button x="347" y="327" label="import flash" click="setSWF1()"/>
</mx:Application>

swfLoading1.as :
private function setSWF1():void {
SWFContainer.load("test2.swf");
}

test2.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="swfLoading2.as" />
<mx:Label x="10" y="10" text="Test2"/>
<mx:Button x="10" y="36" label="import flash" click="setSWF2()"/>
</mx:Application>

swfLoading2.as :
private function setSWF2():void {
SWFContainer.load("test3.swf");
}

test3.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Label x="407" y="326" text="Test 3 : YEY"/>
</mx:Application>

Problem 2 :
5 files : 3 .mxml files and 2 .as files
When I type the code in swfLoading2.as, i get an error that SWFContainer has not been defined.



It is defined in the application. The code does not indicate that swfLoading2.as should know anything about the Loader identified as SWFContainer.

I would recommend a read through Adobe livedocs to get some answers.