Jump to content
Search Community

dandoen last won the day on October 13 2012

dandoen had the most liked content!

dandoen

Members
  • Posts

    8
  • Joined

  • Last visited

  • Days Won

    1

dandoen last won the day on October 13 2012

dandoen had the most liked content!

dandoen's Achievements

1

Reputation

  1. The best solution seems to be doing applyItemXML to create a placeholder sprite along with adding it to the queue and using the placeholder sprite as the container for the LoaderMax item. Below's the code - just in case someone else finds it useful. Thanks Jack, could not have done it without you! import com.greensock.*; import com.greensock.easing.*; import com.greensock.transform.TransformItem; import com.greensock.transform.TransformManager; import com.greensock.events.TransformEvent; import com.greensock.loading.*; import flash.display.Sprite; import flash.text.TextField; var XMLLive:XML = <transformManager> <settings allowDelete="1" allowMultiSelect="0" autoDeselect="1" constrainScale="0" lockScale="0" scaleFromCenter="0" lockRotation="0" lockPosition="0" arrowKeysMove="0" forceSelectionToFront="1" lineColor="3381759" handleColor="16777215" lineThickness="1" handleSize="8" paddingForRotation="12" hideCenterHandle="0"/> <items> <item id="1" type="static" forall="0" user_id="1" name="logo.swf" link="" url="" state="1" user="" level="1" a="1.0000000000000000" b="0.0000000000000000" c="0.0000000000000000" d="1.0000000000000000" tx="2" ty="160" xOffset="-7" yOffset="-8" rawWidth="417" rawHeight="108" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"><![CDATA[]]></item> <item id="2" type="text" forall="0" user_id="2" name="tf2" link="" url="" state="1" user="" level="0" a="1.0000000000000000" b="0.0000000000000000" c="0.0000000000000000" d="1.0000000000000000" tx="120" ty="200" xOffset="0" yOffset="0" rawWidth="200" rawHeight="100" scaleMode="scaleWidthAndHeight" hasSelectableText="1" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"><![CDATA[<P ALIGN="CENTER">Some text</P>]]></item> <item id="3" type="video" forall="0" user_id="2" name="UAOxCqSxRD0" link="" url="" state="1" user="" level="2" a="1.0000000000000000" b="0.0000000000000000" c="0.0000000000000000" d="1.0000000000000000" tx="0" ty="190" xOffset="0" yOffset="0" rawWidth="600" rawHeight="400" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"><![CDATA[]]></item> </items> </transformManager> var manager = new TransformManager(); var queue = new LoaderMax({name:"mainQueue"}); for each (var item in XMLLive.items.*) { if (item.@type == "static") { queue.append(new SWFLoader("media/"+item.@name, { name:item.@id, container: prepareStaticAsset(item), onComplete: createStaticAsset })); } else if (item.@type == "text") { createTextAsset(item); } else if (item.@type == "video") { createVideoAsset(item); } } queue.load(); function assetData(mc) { var data = XMLLive.items.item.(@id==mc.name)[0]; return data; } function prepareStaticAsset(item) { var mc = manager.applyItemXML(item,stage); return mc; } function createStaticAsset(e) { //var mc = stage.getChildByName(e.target.name); } function createTextAsset(item) { var tf = new TextField(); tf.name = item.@name; tf.htmlText = item; stage.addChild(tf); var mc = manager.applyItemXML(item,stage); } function createVideoAsset(item) { var player = new Sprite(); player.name = item.@name; stage.addChild(player); var mc = manager.applyItemXML(item,stage); }
  2. Thanks. The reason why I was taking the route of adding it to the placeholder sprite was because of another issue that is occurring now (which I vaguely explained in my initial post). Correct me if I'm wrong but this is what is currently happening: 1. Loop function goes through all assets and adds text and video assets to stage while adding "static" assets to the LoaderMax queue 2. The queue is loaded after the loop is done with adding the text/video assets to stage The issue here is that the levels as defined in the XML file won't match the "real" levels on stage. For example, a textfield has level 2 (out of 3 items, which means that it should be on top of everything else). applyItemXML is called for the textfield before the queue is loaded and so before the static item (with a lower level) is on stage. Which means applyItemXML sets the level to the highest childIndex, which is 0 at that time. This results in the video assets & text assets always be below the static assets due to the way it's been added to stage - ignoring the levels of the XML. Hope I managed to be a bit more clear this time, thanks again.
  3. Thanks, I understand that when the sprite container is being resized the contents (in this case the textfield) is being resized as well. But am not really sure what to do in order to work around this. This is the simplest example I can come up with: import com.greensock.*; import com.greensock.easing.*; import com.greensock.transform.TransformItem; import com.greensock.transform.TransformManager; import com.greensock.events.TransformEvent; import com.greensock.loading.*; import flash.display.Sprite; import flash.text.TextField; var XMLLive:XML = <transformManager> <settings allowDelete="1" allowMultiSelect="0" autoDeselect="1" constrainScale="0" lockScale="0" scaleFromCenter="0" lockRotation="0" lockPosition="0" arrowKeysMove="0" forceSelectionToFront="1" lineColor="3381759" handleColor="16777215" lineThickness="1" handleSize="8" paddingForRotation="12" hideCenterHandle="0"/> <items> <item id="1" type="static" forall="0" user_id="1" name="logo.swf" link="" url="" state="1" user="" level="1" a="1.0000000000000000" b="0.0000000000000000" c="0.0000000000000000" d="1.0000000000000000" tx="292" ty="322" xOffset="-7" yOffset="-8" rawWidth="417" rawHeight="108" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"><![CDATA[]]></item> <item id="2" type="text" forall="0" user_id="2" name="" link="" url="" state="1" user="" level="0" a="1.0000000000000000" b="0.0000000000000000" c="0.0000000000000000" d="1.0000000000000000" tx="0" ty="0" xOffset="0" yOffset="0" rawWidth="200" rawHeight="100" scaleMode="scaleWidthAndHeight" hasSelectableText="1" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"><![CDATA[<P ALIGN="CENTER">Some text</P>]]></item> <item id="3" type="video" forall="0" user_id="2" name="UAOxCqSxRD0" link="" url="" state="1" user="" level="2" a="1.0000000000000000" b="0.0000000000000000" c="0.0000000000000000" d="1.0000000000000000" tx="0" ty="190" xOffset="0" yOffset="0" rawWidth="600" rawHeight="400" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"><![CDATA[]]></item> </items> </transformManager> var manager = new TransformManager(); var queue = new LoaderMax({name:"mainQueue"}); for each (var item in XMLLive.items.*) { if (item.@type == "static") { queue.append(new SWFLoader("media/"+item.@name, { name:item.@id, container:stage, onComplete: createStaticAsset })); } else if (item.@type == "text") { createTextAsset(item); } else if (item.@type == "video") { createVideoAsset(item); } } queue.load(); function assetData(mc) { var data = XMLLive.items.item.(@id==mc.name)[0]; return data; } function createStaticAsset(e) { var mc = stage.getChildByName(e.target.name); manager.applyItemXML(assetData(mc),stage,0xFF0000); } function createTextAsset(item) { var tf = new TextField(); tf.htmlText = item; tf.width = item.@rawWidth; tf.height = item.@rawHeight; var mc = manager.applyItemXML(item,stage,0xFF0000); mc.addChild(tf); } function createVideoAsset(item) { var player = new Sprite(); var mc = manager.applyItemXML(item,stage,0xFF0000); mc.addChild(player); }
  4. I'm looping through all the items of my XML and use LoaderMax to load my SWFs onto stage, and trigger a function to generate video items and text items. This looks like this: for each (var item in Main.XMLLiveItems.items.*) { if (item.@type == "static") { Main.queue.insert(new SWFLoader("media/"+item.@name, { name:item.@id, container:area, alpha: 0, onComplete: itemLoaded }),item.@level); } else if (item.@type == "text") { createTextAsset(item); } else if (item.@type == "video") { createVideoAsset(item); } } However, this messes up the levels since LoaderMax loads the queue after my textassets and videos have been loaded onto stage. I can't add the text assets or the video assets to my stage (called area) when specifying the index, because the number of children is still zero when the createTextAsset and createVideoAsset functions are called. I've tried to first use 'applyFullXML' and then add the textfields and videoloaders as a child to the placeholders. This turned out the way I wanted, except the textfields did not scale properly (using the scaleWidthAndHeight property) since they were now a child of a sprite. I am currently not sure what to do so was hoping for a push in the right direction. Thanks again.
  5. I've been having this issue as well. In the browser everything seems to run fine, though. Every now and then my cursor disappears in the player. When this happens, I just press the right mouse button and everything runs normally again. Hopefully either Adobe or Apple releases an update soon!
  6. Hi there, I've been having a bit of an issue with trying to add a youtube video to the manager. The video is added correctly on the stage and starts playing as it should. But when you try to move it around somehow the Youtube player's mouse event listeners seem to be in conflict with the TransformManager's. Because when you try to drag the TransformItem, the item sticks to the mouse position (with some lag) and you can't stop the drag. Here's my code: function loadYoutubeVideo() { var my_loader:Loader = new Loader(); my_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3")); my_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit); } function onLoaderInit(e:Event):void{ my_player = e.target.content; my_player.addEventListener("onReady", onPlayerReady); } function onPlayerReady(e:Event):void{ my_player.setSize(640,360); my_player.loadVideoById("_OBlgSz8sSM",0); stage.addChild(my_player); var item = manager.addItem(my_player); } Thanks!
  7. After getting slightly upset over this, I found out I made a stupid mistake when generating the XML from my mySQL database. If you look at the preview of my XML, you'll see that I don't have maxScaleX attribute and the minScaleX attribute contains the value of maxScaleX. After fixing this, I'd say: case closed. Thanks anyway. Keep up the great work!
  8. Hi, I'm trying to use the applyFullXML functionality and am doing everything according to the documentation but somehow I can't manage to make it work properly. So this is how my XML looks like: <transformManager> <settings allowDelete="1" allowMultiSelect="1" autoDeselect="1" constrainScale="0" lockScale="1" scaleFromCenter="0" lockRotation="0" lockPosition="0" arrowKeysMove="0" forceSelectionToFront="1" lineColor="3381759" handleColor="16777215" handleSize="8" paddingForRotation="12" hideCenterHandle="0"/> <items> <item name="achilles.png" level="2" a="1" b="0" c="0" d="1" tx="420" ty="339" xOffset="0" yOffset="0" rawWidth="345" rawHeight="272" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"/> <item name="logo.swf" level="2" a="1" b="0" c="0" d="1" tx="321" ty="347" xOffset="0" yOffset="0" rawWidth="402" rawHeight="94" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"/> </items> </transformManager> I am loading the assets using your LoaderMax class as following: for each (var item:XML in XMLItems.items.*) { Main.queue.append( new SWFLoader("media/"+item.@name, { name:item.@name, container:area }) ); } After the entire queue is loaded, I am doing this: manager.applyFullXML(XMLItems, area); But somehow, the width of the TransformItem and the DisplayObject are both returning 1, even though the rawWidth is loaded correctly from the XML. Just before doing applyFullXML the objects' sizes are correct, so my implementation of LoaderMax can't be the problem. What makes it strange is that the height seems to be exactly as defined in the XML, while the width is 1... Any idea what I'm doing wrong? Thanks!
×
×
  • Create New...