求助

卟惹尘埃 2011-01-17 05:02:45

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:comonent="comonent.*" xmlns:component="component.*"
creationComplete="windowedapplication1_creationCompleteHandler(event)">
<fx:Style source="./style/greenstyle.css"/>
<fx:Style source="./style/bluestyle.css"/<!--这里的css样式调用了,起作用了===============-->
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.events.MenuEvent;
import mx.rpc.events.ResultEvent;


//接受数据
protected function httpservice1_resultHandler(event:ResultEvent):void
{
myMenu.listMenu=XML(event.result);
myMenu.BindMenuData();
}

//创建完成时发生
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
hs.send();
myMenu.addEventListener(mx.events.MenuEvent.ITEM_CLICK,OnMenuItemClick,true);
}

//菜单项选择改变时发生
private function OnMenuItemClick(event:MenuEvent):void
{
var obj:Object=event.item.@data;
Alert.show(obj.toString());
}
private function changestyle()
{
StyleManager.loadStyleDeclarations("./style/greenstyle.swf");
<!--但是这里这样调用却不行,点击按钮有错误提示,提示在下面。-->

}

]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<s:HTTPService url="D:\MenuItem.xml" resultFormat="e4x" result="httpservice1_resultHandler(event)" id="hs"/>

</fx:Declarations>
<fx:Script>
<![CDATA[

]]>
</fx:Script>
<component:SMenuBar id="myMenu" width="100%"/>
<s:Button x="761" y="2" label="按钮" width="47" click="changestyle()"/>
</s:WindowedApplication>

路径是没有问题的 跟css文件在一个包下面,但是.swf文件无法调用,请各位看看是为什么
-------------------------------------
错误提示
A actionscript error has occurred
-------------------------------------
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at <anonymous>()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\styles\StyleManagerImpl.as:1499]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ModuleInfoProxy/load()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\modules\ModuleManager.as:1121]
at <anonymous>()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\styles\StyleManagerImpl.as:1546]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()


...全文
74 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
卟惹尘埃 2011-01-24
  • 打赏
  • 举报
回复
我的神啊 怎么没人啊
herowach 2011-01-20
  • 打赏
  • 举报
回复
错误明显是空指针,看StyleManagerImpl.as:1499的源码,应该是安全域的问题
public function loadStyleDeclarations2(
url:String, update:Boolean = true,
applicationDomain:ApplicationDomain = null,
securityDomain:SecurityDomain = null):
IEventDispatcher

module.load(applicationDomain, securityDomain);
卟惹尘埃 2011-01-20
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 herowach 的回复:]
错误明显是空指针,看StyleManagerImpl.as:1499的源码,应该是安全域的问题
public function loadStyleDeclarations2(
url:String, update:Boolean = true,
applicationDomain:ApplicationDomain = null,
securityDomain:SecurityDomain……
[/Quote]
你好。我的是RIA应用程序,我想用按钮事件触发样式的改变,StyleManager.loadStyleDeclarations("./style/greenstyle.swf");这样用是错的,你能帮我写一个简单的例子吗?谢谢
passself 2011-01-19
  • 打赏
  • 举报
回复
http://hi.baidu.com/zwnjiejie/blog/item/3209eb4c5f93a6f2d62afcfe.html
1009错误很特殊,楼主看一下上面这个
「已注销」 2011-01-19
  • 打赏
  • 举报
回复
有没有把css文件。编译成swf格式啊????


右击css文件。。选编译成swf格式啊··
卟惹尘埃 2011-01-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lieri111 的回复:]
http://hi.baidu.com/zwnjiejie/blog/item/3209eb4c5f93a6f2d62afcfe.html
1009错误很特殊,楼主看一下上面这个
[/Quote]
不是啊 那个是解决全屏问题的 ,我要达到的效果是想换皮肤。你有好方法吗?在AIR下运行的
卟惹尘埃 2011-01-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lasimmm 的回复:]
有没有把css文件。编译成swf格式啊????


右击css文件。。选编译成swf格式啊··
[/Quote]
编译了的:StyleManager.loadStyleDeclarations("./style/greenstyle.swf");

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧