Quantcast
Channel: Adobe Community : Popular Discussions - Using Flash Builder
Viewing all articles
Browse latest Browse all 70427

i'm building a app to read comic . I using navigator.pushview (appview.mxml ) to refesh image, but image display so slow, then i consider about caching image . So have problem with that , plz give me some solution for this app, thank you.

$
0
0

Myfirstapp.mxml

 

<?xml version="1.0" encoding="utf-8"?>

<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

  xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.MyFirstAppHomeView" applicationDPI="240"

  splashScreenImage="@Embed('Images/Sflash.jpg')"

  >

  <fx:Declarations>

  <!-- Place non-visual elements (e.g., services, value objects) here -->

  <s:ContentCache id="ldr" enableQueueing="true"

  maxActiveRequests="1" maxCacheEntries="2"/>

  </fx:Declarations>

  <fx:Script>

  <![CDATA[

  [Bindable]

  public var key:int = 0 ;

  import mx.collections.ArrayCollection;

  [Bindable]

  public var content:String= "http://3.bp.blogspot.com/-rcT0v_RCYUA/U-LrLDfTkHI/AAAAAAAAGLs/X3X7NerJG8Y/s1600/93-01.jpg; http://3.bp.blogspot.com/-zptSl-1evzI/U-LrMuVjoZI/AAAAAAAAGL0/cfJRVsobXEg/s1600/93-03.jpg; http://3.bp.blogspot.com/-IGO-Nk1UeQw/U-LrNzLb9II/AAAAAAAAGL8/X1iTBQi0CYs/s1600/93-07.jpg; http://3.bp.blogspot.com/-b8DnW4v_J0w/U-LrPWv1WRI/AAAAAAAAGME/ZdowJF3PupM/s1600/93-11-12.j pg;http://3.bp.blogspot.com/-5YLUaHt8wZE/U-LrQtbVvUI/AAAAAAAAGMM/yaEUkT7zqWY/s1600/93-19-2 0.jpg;http://3.bp.blogspot.com/-C61dLZllc8g/U-LrSLhcMJI/AAAAAAAAGMU/xQcLN4nVYQw/s1600/QQ%2 525CD%2525BC%2525C6%2525AC20140725150818.jpg;http://4.bp.blogspot.com/-6qIzw-bawt8/U9jZTZl ZabI/AAAAAAAAiMY/1VgFP8-Y8Qs/s1600/2.jpg;http://4.bp.blogspot.com/-GuunEyx0yGk/U9jZYHvi19I /AAAAAAAAiMg/ZfJyACVSSPk/s1600/3.jpg;http://1.bp.blogspot.com/-knLsbpCKhsw/U9jZcnNFOQI/AAA AAAAAiMs/OMf3AMjMHL0/s1600/4.jpg;http://2.bp.blogspot.com/-HkqIs8VJ9w4/U9jZcTcH2JI/AAAAAAA AiMo/AsYhWKypK0k/s1600/5.jpg;http://1.bp.blogspot.com/-mg4Ef7TG7Es/U9jZkwU1eQI/AAAAAAAAiM4 /YWDTMucZ6eM/s1600/6.jpg;http://1.bp.blogspot.com/-VHmeWpro-qM/U9jZso2hIbI/AAAAAAAAiNI/Hcb -JYeR18k/s1600/8.jpg;http://4.bp.blogspot.com/-QcpT9HebUIA/U9jZyoBxHgI/AAAAAAAAiNQ/2XgEOjy 11d8/s1600/9.jpg;http://2.bp.blogspot.com/-Hyar0cCpAu8/U9jYOIOuG7I/AAAAAAAAiLE/L34L59FTSsw /s1600/10.jpg;http://2.bp.blogspot.com/-eJCkT8E771k/U9jYfyfGdpI/AAAAAAAAiLY/exSiD2GkFYA/s1 600/12.jpg";

  [Bindable]

  public var tempAc:ArrayCollection=new ArrayCollection(content.split(";"));

  ]]>

  </fx:Script>

</s:ViewNavigatorApplication>

 

========MyfirstappHomeView.mxml==============

 

<?xml version="1.0" encoding="utf-8"?>

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

  xmlns:s="library://ns.adobe.com/flex/spark" title="My First App"

  creationComplete="init()">

 

  <fx:Style>

 

  @namespace s "library://ns.adobe.com/flex/spark";

  @namespace mx "library://ns.adobe.com/flex/mx";

  s|Image {

  enableLoadingState: true;

  }

  </fx:Style>

 

  <fx:Script>

  <![CDATA[

  import mx.collections.ArrayCollection;

  import mx.collections.ArrayList;

  import mx.core.FlexGlobals;

 

  protected function init():void

  {

  //add listener

  addEventListener(TransformGestureEvent.GESTURE_SWIPE , swipeHandler);

  //label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();

  //label2.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key +1 ).toString();

  //caching image array

  var rand:String = new Date().time.toString()

  var arrcaching:Array = [];

  arrcaching.push({src: FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key + 1).toString() + rand, cache:ldr});

  arrcaching.push({src: FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring() + rand, cache:ldr});

 

  var arrList:ArrayList = new ArrayList();

  arrList = new ArrayList(arrcaching);

  // dataGrp.dataProvider = arrList;

  show.source = arrcaching.pop().src;

 

  // show the first picture

  // images.source= FlexGlobals.topLevelApplication.tempAc.getItemAt( FlexGlobals.topLevelApplication.key ).toString();

  }

  protected function swipeHandler (event:TransformGestureEvent):void

  {

  // Swipe was to the right

  if (event.offsetX == 1 ) {

  if (FlexGlobals.topLevelApplication.key == 0)

  {

  FlexGlobals.topLevelApplication.key = 0;

  }

  else

  {

  FlexGlobals.topLevelApplication.key = FlexGlobals.topLevelApplication.key - 1 ;

  //label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();

  navigator.pushView(MyFirstAppHomeView);

  }

  }

  // Swipe was to the left

  if (event.offsetX == -1 ) {

 

 

  if (FlexGlobals.topLevelApplication.key == FlexGlobals.topLevelApplication.tempAc.length-1)

  {

  FlexGlobals.topLevelApplication.key = FlexGlobals.topLevelApplication.tempAc.length-1;

  }

  else

  {

  //no caching

  FlexGlobals.topLevelApplication.key= FlexGlobals.topLevelApplication.key +1 ;

  // label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();

  navigator.pushView(MyFirstAppHomeView);

  

  

  // caching

  //label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();

  // navigator.pushView(MyFirstAppHomeView);

  

  }

  }

  }

 

  ]]>

  </fx:Script>

 

  <fx:Declarations>

  <!-- Place non-visual elements (e.g., services, value objects) here -->

  <s:ContentCache id="ldr" enableQueueing="true"

  maxActiveRequests="1" maxCacheEntries="2"/>

  </fx:Declarations>

  <s:Image id="show" left="0" right="0" top="0" bottom="0" contentLoader="{ldr}" />

 

</s:View>


Viewing all articles
Browse latest Browse all 70427


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>